onnxruntime/tools/ci_build/github/windows/install_third_party_deps.ps1
Yi Zhang 80f807c03d
upgrade protobuf to 3.20.2 and onnx to 1.13 (#14279)
### Description
upgrade protobuf to 3.20.2, same as onnx 1.13.0

### Motivation and Context
Per component governance requirement and Fixes #14060

unused-parameter error occurs in 2 conditions.
1. compile protolbuf

`onnxruntime_src/cmake/external/protobuf/src/google/protobuf/repeated_ptr_field.h:752:66:
error: unused parameter ‘prototype’ [-Werror=unused-parameter]`
2. include onnx_pb.h
```
2023-01-28T10:20:15.0410853Z FAILED: CMakeFiles/onnxruntime_pybind11_state.dir/onnxruntime_src/onnxruntime/python/onnxruntime_pybind_iobinding.cc.o 
......
2023-01-28T10:20:15.0466024Z                  from /build/Debug/_deps/onnx-src/onnx/onnx_pb.h:51,
2023-01-28T10:20:15.0466958Z                  from /onnxruntime_src/include/onnxruntime/core/framework/to_tensor_proto_element_type.h:10,
....
2023-01-28T10:20:15.0609678Z /build/Debug/_deps/onnx-build/onnx/onnx-operators-ml.pb.h:1178:25:   required from here
2023-01-28T10:20:15.0610895Z /onnxruntime_src/cmake/external/protobuf/src/google/protobuf/repeated_ptr_field.h:752:66: error: unused parameter ‘prototype’ [-Werror=unused-parameter]
2023-01-28T10:20:15.0611707Z cc1plus: all warnings being treated as errors

```

https://dev.azure.com/onnxruntime/2a773b67-e88b-4c7f-9fc0-87d31fea8ef2/_apis/build/builds/874605/logs/22
2023-01-31 12:55:09 -08:00

82 lines
2.8 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This script depends on python.exe, cmake.exe and Visual C++ spectre-mitigated libs.
# Please setup AGENT_TEMPDIRECTORY env variable before running this script
param (
[string]$cpu_arch = "x64",
[string]$build_config = "RelWithDebInfo",
[string]$install_prefix = ".",
[switch]$use_cache
)
. "$PSScriptRoot\helpers.ps1"
$ort_src_root = (Get-Item $PSScriptRoot).parent.parent.parent.parent.FullName
Write-Host "ONNX Runtime src root: $ort_src_root"
$ErrorActionPreference = "Stop"
$Env:Path = "$install_prefix\bin;" + $env:Path
$Env:MSBUILDDISABLENODEREUSE=1
New-Item -Path "$install_prefix" -ItemType Directory -Force
# Setup compile flags
$compile_flags = '/MP /guard:cf /Qspectre /DWIN32 /D_WINDOWS /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DNTDDI_VERSION=0x06010000 /W3 '
$linker_flags=@('/guard:cf')
if ($use_cache) {
$debug_info_format = "/Z7"
}
else {
$debug_info_format = "/Zi"
}
if($build_config -eq 'Release'){
$compile_flags += "/O2", "/Ob2", "/DNDEBUG", "/Gw", "/GL"
} elseif($build_config -eq 'RelWithDebInfo'){
$compile_flags += "$debug_info_format", "/O2", "/Ob1", "/DNDEBUG", "/Gw", "/GL"
} elseif($build_config -eq 'Debug'){
$compile_flags += "$debug_info_format", "/Ob0", "/Od", "/RTC1"
} elseif($build_config -eq 'MinSizeRel'){
$compile_flags += "/O1", "/Ob1", "/DNDEBUG", "/Gw", "/GL"
}
Write-Host $compile_flags
# cmake args that applies to every 3rd-party library
[string[]]$cmake_extra_args="-DCMAKE_CXX_STANDARD=17 `"-DCMAKE_CXX_FLAGS=$compile_flags /EHsc`" ", "`"-DCMAKE_C_FLAGS=$compile_flags`"", "--compile-no-warning-as-error", "--fresh", "-Wno-dev"
if($cpu_arch -eq 'x86'){
$cmake_extra_args += "-A", "Win32", "-T", "host=x64"
$linker_flags += '/machine:x86'
} elseif($cpu_arch -eq 'x64') {
$linker_flags += '/machine:x64'
} else {
throw "$cpu_arch is not supported"
}
if ($use_cache) {
if ($build_config -eq 'RelWithDebInfo') {
$cmake_extra_args += "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=`"/MD /Z7 /O2 /Ob1 /DNDEBUG`""
}
elseif ($build_config -eq 'Debug') {
$cmake_extra_args += "-DCMAKE_CXX_FLAGS_DEBUG=`"/MDd /Z7 /Ob0 /Od /RTC1`""
}
}
$cmake_extra_args += "-DCMAKE_EXE_LINKER_FLAGS=`"$linker_flags`""
# Find the full path of cmake.exe
$cmake_command = (Get-Command -CommandType Application cmake)[0]
$cmake_path = $cmake_command.Path
Install-Pybind -cmake_path $cmake_path -src_root $ort_src_root -build_config $build_config -cmake_extra_args $cmake_extra_args
Install-Protobuf -cmake_path $cmake_path -src_root $ort_src_root -build_config $build_config -cmake_extra_args $cmake_extra_args
# TODO: parse it from deps.txt
$protobuf_version="3.20.2"
# ONNX doesn't allow us to specify CMake's path
Install-ONNX -build_config $build_config -src_root $ort_src_root -protobuf_version $protobuf_version