Skip to content

Commit 1f8cbc4

Browse files
committed
Update ONNX script
1 parent 09d4296 commit 1f8cbc4

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

tools/onnx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ clean() {
2525
echo "onnx clean"
2626
rm -rf "${env_dir}"
2727
rm -rf "${src_dir}"
28+
rm -rf "./third_party/bin/protobuf"
2829
}
2930

3031
sync() {
@@ -76,21 +77,28 @@ install() {
7677
# export PATH="${protoc_dir}\bin":${PATH}
7778
# ;;
7879
msys*|cygwin*|mingw*)
79-
# winget install -e --id=Microsoft.VisualStudio.2019.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
80-
programfiles_x86_dir=$(env | grep "^ProgramFiles(x86)=" | cut -d '=' -f 2)
81-
build_tools_dir="${programfiles_x86_dir}\Microsoft Visual Studio\2019\BuildTools"
80+
# winget install -e --id=Microsoft.VisualStudio.2026.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
81+
programfiles_x86=$(env | grep "^ProgramFiles(x86)=" | cut -d '=' -f 2)
82+
vswhere="${programfiles_x86}\Microsoft Visual Studio\Installer\vswhere.exe"
83+
build_tools_dir=$("${vswhere}" -latest -products '*' -property installationPath)
84+
case "$(uname -s)" in
85+
*ARM64*) cmake_arch="ARM64" ;;
86+
*) cmake_arch="x64" ;;
87+
esac
8288
cmake_dir="${build_tools_dir}\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
8389
protobuf="protobuf==${protobuf_version}"
8490
${python} -m pip install --quiet --upgrade ${protobuf}
8591
export PATH="$(cygpath -u "${cmake_dir}")":${PATH}
86-
msbuild_dir="${build_tools_dir}\MSBuild\Current\Bin"
8792
if [ ! -f "${protoc_dir}/bin/protoc.exe" ]; then
8893
rm -rf ${protoc_dir}
89-
git clone --quiet -c advice.detachedHead=false -b v${protobuf_version} https://github.com/protocolbuffers/protobuf.git ${protoc_dir}/src
90-
pushd "${protoc_dir}/src/cmake" > /dev/null
91-
"${cmake_dir}\cmake.exe" -G "Visual Studio 16 2019" -A x64 -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX="..\..\.." . > /dev/null
92-
"${msbuild_dir}\MSBuild.exe" protobuf.sln //m //p:Configuration=Release > /dev/null
93-
"${msbuild_dir}\MSBuild.exe" INSTALL.vcxproj //p:Configuration=Release > /dev/null
94+
git init --quiet ${protoc_dir}/src
95+
git -C ${protoc_dir}/src fetch --quiet --depth=1 https://github.com/protocolbuffers/protobuf.git v${protobuf_version}
96+
git -C ${protoc_dir}/src checkout --quiet FETCH_HEAD
97+
git -C ${protoc_dir}/src submodule update --quiet --init --recursive --depth=1
98+
pushd "${protoc_dir}/src" > /dev/null
99+
"${cmake_dir}\cmake.exe" -Wno-deprecated -A ${cmake_arch} -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DABSL_PROPAGATE_CXX_STD=ON -DCMAKE_INSTALL_PREFIX="$(cygpath -w "${protoc_dir}")" . > /dev/null
100+
"${cmake_dir}\cmake.exe" --build . --config Release > /dev/null
101+
"${cmake_dir}\cmake.exe" --install . --config Release > /dev/null
94102
popd > /dev/null
95103
fi
96104
export PATH="${protoc_dir}\bin":${PATH}

0 commit comments

Comments
 (0)