mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Add build files for grpc-tools and tests for those builds
This commit is contained in:
parent
a10c534b01
commit
c137ca6849
27
packages/grpc-tools/CMakeLists.txt
Normal file
27
packages/grpc-tools/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
endif(COMMAND cmake_policy)
|
||||
|
||||
set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/protobuf)
|
||||
add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake deps/protobuf)
|
||||
|
||||
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
|
||||
set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.")
|
||||
|
||||
add_executable(grpc_node_plugin
|
||||
src/node_generator.cc
|
||||
src/node_plugin.cc
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(grpc_node_plugin
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
PRIVATE ${PROTOBUF_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(grpc_node_plugin
|
||||
libprotoc
|
||||
libprotobuf
|
||||
)
|
||||
47
packages/grpc-tools/build_binaries.ps1
Normal file
47
packages/grpc-tools/build_binaries.ps1
Normal file
@ -0,0 +1,47 @@
|
||||
Install-Module -Name 7Zip4Powershell
|
||||
|
||||
function MkDir-p($Path) {
|
||||
$FullPath = "\\?\" + $Path
|
||||
if (-not (Test-Path -Path $FullPath)) {
|
||||
New-Item -ItemType directory -Path $FullPath | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
$WellKnownProtos = "any","api","compiler/plugin","descriptor","duration","empty","field_mask","source_context","struct","timestamp","type","wrappers"
|
||||
|
||||
$Base = %~dp0
|
||||
cd $Base
|
||||
$ProtobufBase = $Base + "/deps/protobuf"
|
||||
MkDir-p $Base + "/build/bin"
|
||||
|
||||
$PackageFile = $Base + "/package.json"
|
||||
$ToolsVersion = (Get-Content $PackageFile) -join "`n" | ConvertFrom-Json | Get-Member -Name version
|
||||
|
||||
$OutDir = $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"
|
||||
}
|
||||
|
||||
$ArchList = "ia32","x64"
|
||||
|
||||
foreach ($Arch in $ArchList) {
|
||||
if ($Arch -eq "x64") {
|
||||
$Generator = "Visual Studio 14 2015 Win64"
|
||||
} 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"
|
||||
|
||||
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"
|
||||
|
||||
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"
|
||||
}
|
||||
50
packages/grpc-tools/build_binaries.sh
Executable file
50
packages/grpc-tools/build_binaries.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
well_known_protos=( any api compiler/plugin descriptor duration empty field_mask source_context struct timestamp type wrappers )
|
||||
|
||||
cd $(dirname $0)
|
||||
base=$(pwd)
|
||||
protobuf_base=$base/deps/protobuf
|
||||
|
||||
tools_version=$(jq '.version' < package.json | tr -d '"')
|
||||
|
||||
out_dir=$ARTIFACTS_OUT/grpc-tools/v$tools_version
|
||||
mkdir -p "$out_dir"
|
||||
|
||||
mkdir -p "$base/build/bin/google/protobuf/compiler"
|
||||
for proto in "${well_known_protos[@]}"; do
|
||||
cp "$protobuf_base/src/google/protobuf/$proto.proto" "$base/build/bin/google/protobuf/$proto.proto"
|
||||
done
|
||||
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
platform=linux
|
||||
arch_list=( ia32 x64 )
|
||||
;;
|
||||
Darwin)
|
||||
platform=darwin
|
||||
arch_list=( x64 )
|
||||
;;
|
||||
esac
|
||||
|
||||
for arch in "${arch_list[@]}"; do
|
||||
case $arch in
|
||||
ia32)
|
||||
toolchain_flag=-DCMAKE_TOOLCHAIN_FILE=linux_32bit.toolchain.cmake
|
||||
;;
|
||||
*)
|
||||
toolchain_flag=
|
||||
;;
|
||||
esac
|
||||
rm -f $base/build/bin/protoc
|
||||
rm -f $base/build/bin/grpc_node_plugin
|
||||
rm -f CMakeCache.txt
|
||||
cmake $toolchain_flag . && cmake --build . --target clean && cmake --build . -- -j 12
|
||||
cp -L $protobuf_base/protoc $base/build/bin/protoc
|
||||
cp $base/grpc_node_plugin $base/build/bin/
|
||||
cd $base/build
|
||||
tar -czf "$out_dir/$platform-$arch.tar.gz" bin/
|
||||
cd $base
|
||||
done
|
||||
3
packages/grpc-tools/linux_32bit.toolchain.cmake
Normal file
3
packages/grpc-tools/linux_32bit.toolchain.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" CACHE STRING "ld flags")
|
||||
5
test/kokoro-nodejs-build-test.bat
Normal file
5
test/kokoro-nodejs-build-test.bat
Normal file
@ -0,0 +1,5 @@
|
||||
cd /d %~dp0
|
||||
cd ..
|
||||
|
||||
call ./tools/release/kokoro-nodejs.bat
|
||||
powershell -File ./packages/grpc-tools/build_binaries.ps1
|
||||
6
test/kokoro-nodejs-build-test.sh
Normal file
6
test/kokoro-nodejs-build-test.sh
Normal file
@ -0,0 +1,6 @@
|
||||
set -e
|
||||
cd $(dirname $0)/..
|
||||
base_dir=$(pwd)
|
||||
|
||||
./tools/release/kokoro-nodejs.sh
|
||||
ARTIFACTS_OUT=$base_dir/artifacts ./packages/grpc-tools/build_binaries.sh
|
||||
@ -15,5 +15,5 @@
|
||||
# Config file for Kokoro (in protobuf text format)
|
||||
|
||||
# Location of the continuous shell script in repository.
|
||||
build_file: "grpc-node/tools/release/kokoro-nodejs.sh"
|
||||
build_file: "grpc-node/test/kokoro-nodejs-build-test.sh"
|
||||
timeout_mins: 60
|
||||
|
||||
@ -15,5 +15,5 @@
|
||||
# Config file for Kokoro (in protobuf text format)
|
||||
|
||||
# Location of the continuous shell script in repository.
|
||||
build_file: "grpc-node/tools/release/kokoro-nodejs.sh"
|
||||
build_file: "grpc-node/test/kokoro-nodejs-build-test.sh"
|
||||
timeout_mins: 60
|
||||
|
||||
@ -15,5 +15,5 @@
|
||||
# Config file for Kokoro (in protobuf text format)
|
||||
|
||||
# Location of the continuous shell script in repository.
|
||||
build_file: "grpc-node/tools/release/kokoro-nodejs.bat"
|
||||
build_file: "grpc-node/test/kokoro-nodejs-build-test.bat"
|
||||
timeout_mins: 60
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user