From 35e7a7575a2c16e3c524e4e5ca2a45479fcac004 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 7 Feb 2019 10:57:40 -0800 Subject: [PATCH] Fix build script issues --- packages/grpc-tools/CMakeLists.txt | 3 +++ packages/grpc-tools/build_binaries.ps1 | 22 ++++++++++++---------- tools/release/kokoro-grpc-tools.bat | 2 +- tools/release/kokoro-grpc-tools.sh | 12 +++++++++++- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/packages/grpc-tools/CMakeLists.txt b/packages/grpc-tools/CMakeLists.txt index a7d58176..8d38e4e0 100644 --- a/packages/grpc-tools/CMakeLists.txt +++ b/packages/grpc-tools/CMakeLists.txt @@ -3,6 +3,9 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/protobuf) add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake deps/protobuf) diff --git a/packages/grpc-tools/build_binaries.ps1 b/packages/grpc-tools/build_binaries.ps1 index 77a4064e..7861ebeb 100644 --- a/packages/grpc-tools/build_binaries.ps1 +++ b/packages/grpc-tools/build_binaries.ps1 @@ -1,3 +1,5 @@ +Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force +Import-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 Install-Module -Name 7Zip4Powershell function MkDir-p($Path) { @@ -9,10 +11,10 @@ function MkDir-p($Path) { $WellKnownProtos = "any","api","compiler/plugin","descriptor","duration","empty","field_mask","source_context","struct","timestamp","type","wrappers" -$Base = %~dp0 +$Base = $PSScriptRoot cd $Base $ProtobufBase = $Base + "/deps/protobuf" -MkDir-p $Base + "/build/bin" +MkDir-p ($Base + "/build/bin") $PackageFile = $Base + "/package.json" $ToolsVersion = (Get-Content $PackageFile) -join "`n" | ConvertFrom-Json | Get-Member -Name version @@ -21,7 +23,7 @@ $OutDir = $Env:ARTIFACTS_OUT + "/grpc-tools/v" + $ToolsVersion Mkdir-p $OutDir foreach ($Proto in $WellKnownProtos) { - Copy-Item $ProtobufBase + "/src/google/protobuf/" + $Proto + ".proto" -Destination $Base + "/build/bin/google/protobuf/" + $Proto + ".proto" + Copy-Item ($ProtobufBase + "/src/google/protobuf/" + $Proto + ".proto") -Destination ($Base + "/build/bin/google/protobuf/" + $Proto + ".proto") } $ArchList = "ia32","x64" @@ -32,16 +34,16 @@ foreach ($Arch in $ArchList) { } else { $Generator = "Visual Studio 14 2015" } - Remove-Item $Base + "/build/bin/protoc.exe" - Remove-Item $Base + "/build/bin/grpc_node_plugin.exe" - Remove-Item $Base + "CMakeCache.txt" + Remove-Item ($Base + "/build/bin/protoc.exe") + Remove-Item ($Base + "/build/bin/grpc_node_plugin.exe") + Remove-Item ($Base + "CMakeCache.txt") Invoke-Expression "cmake ." Invoke-Expression "cmake --build ." - Copy-Item $ProtobufBase + "/protoc.exe" -Destination $Base + "/build/bin/protoc.exe" - Copy-Item $Base + "/grpc_node_plugin.exe" -Destination $Base + "/build/bin/grpc_node_plugin.exe" + Copy-Item ($ProtobufBase + "/protoc.exe") -Destination ($Base + "/build/bin/protoc.exe") + Copy-Item ($Base + "/grpc_node_plugin.exe") -Destination ($Base + "/build/bin/grpc_node_plugin.exe") - Compress-7Zip -Path $Base + "/build" -Format Tar -ArchiveFileName $Base + "/Archive.tar" - Compress-7Zip -Path $Base + "/Archive.tar" -Format GZip -ArchiveFileName $OutDir + "/windows-x64.tar.gz" + Compress-7Zip -Path ($Base + "/build") -Format Tar -ArchiveFileName ($Base + "/Archive.tar") + Compress-7Zip -Path ($Base + "/Archive.tar") -Format GZip -ArchiveFileName ($OutDir + "/windows-x64.tar.gz") } \ No newline at end of file diff --git a/tools/release/kokoro-grpc-tools.bat b/tools/release/kokoro-grpc-tools.bat index 4a85823f..d62a9e0a 100644 --- a/tools/release/kokoro-grpc-tools.bat +++ b/tools/release/kokoro-grpc-tools.bat @@ -2,4 +2,4 @@ cd /d %~dp0 cd ../.. set ARTIFACTS_OUT=artifacts -powershell -File ./packages/grpc-tools/build_binaries.ps1 \ No newline at end of file +powershell -File ./packages/grpc-tools/build_binaries.ps1 || exit /b 1 \ No newline at end of file diff --git a/tools/release/kokoro-grpc-tools.sh b/tools/release/kokoro-grpc-tools.sh index b4fcb266..c77e3f3c 100755 --- a/tools/release/kokoro-grpc-tools.sh +++ b/tools/release/kokoro-grpc-tools.sh @@ -2,4 +2,14 @@ set -e cd $(dirname $0)/../.. base_dir=$(pwd) -ARTIFACTS_OUT=$base_dir/artifacts ./packages/grpc-tools/build_binaries.sh \ No newline at end of file +OS=$(uname) + +case $OS in +Linux) + docker build -t kokoro-native-image tools/release/native + docker run -v /var/run/docker.sock:/var/run/docker.sock -v $base_dir:$base_dir kokoro-native-image -e ARTIFACTS_OUT=$base_dir/artifacts $base_dir/packages/grpc-tools/build_binaries.sh + ;; +Darwin) + ARTIFACTS_OUT=$base_dir/artifacts ./packages/grpc-tools/build_binaries.sh + ;; +esac \ No newline at end of file