diff --git a/.gitignore b/.gitignore index fce837e45..8e63d8bf0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ node_modules/ npm-debug.log yarn-error.log yarn.lock +artifacts # Emacs temp files *~ @@ -15,6 +16,7 @@ yarn.lock reports/ package-lock.json +pnpm-lock.yaml # Test generated files coverage diff --git a/packages/grpc-tools/.gitignore b/packages/grpc-tools/.gitignore new file mode 100644 index 000000000..5be16bd8a --- /dev/null +++ b/packages/grpc-tools/.gitignore @@ -0,0 +1,7 @@ +CMakeFiles/ +cmake_install.cmake +CMakeCache.txt +Makefile +grpc_node_plugin +protoc +deps/protobuf diff --git a/packages/grpc-tools/CMakeLists.txt b/packages/grpc-tools/CMakeLists.txt index 60dcdb675..2b54eac2b 100644 --- a/packages/grpc-tools/CMakeLists.txt +++ b/packages/grpc-tools/CMakeLists.txt @@ -1,55 +1,60 @@ -cmake_minimum_required(VERSION 3.7) -set(CMAKE_OSX_DEPLOYMENT_TARGET "11.7" CACHE STRING "Minimum OS X deployment version" FORCE) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) +CMAKE_MINIMUM_REQUIRED(VERSION 3.7) +PROJECT("grpc-tools") + +SET(CMAKE_OSX_DEPLOYMENT_TARGET "11.7" CACHE STRING "Minimum OS X deployment version" FORCE) + +if(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) +ENDIF(COMMAND CMAKE_POLICY) # MSVC runtime library flags are selected by an abstraction. -if(COMMAND cmake_policy AND POLICY CMP0091) - cmake_policy(SET CMP0091 NEW) -endif() +if(COMMAND CMAKE_POLICY AND POLICY CMP0091) + CMAKE_POLICY(SET CMP0091 NEW) +ENDIF() + +SET(CMAKE_CXX_STANDARD 11) +SET(CMAKE_CXX_STANDARD_REQUIRED ON) +SET(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +SET(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") +SET(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") +SET(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/protobuf) -set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") -set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") -set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/protobuf) -add_subdirectory(${PROTOBUF_ROOT_DIR}/cmake deps/protobuf) +ADD_SUBDIRECTORY(${PROTOBUF_ROOT_DIR}/cmake deps/protobuf) -set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector") +SET(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector") -add_executable(grpc_node_plugin - src/node_generator.cc - src/node_plugin.cc +ADD_EXECUTABLE(grpc_node_plugin + src/node_generator.cc + src/node_plugin.cc ) -if (MSVC) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) - set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) - else () - foreach (flag_var - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if (${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif (${flag_var} MATCHES "/MD") - endforeach (flag_var) - endif () -endif (MVC) - -target_include_directories(grpc_node_plugin +IF(MSVC) + IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) + SET(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) + ELSE() + FOREACH(flag_var + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELWITHDEBINFO + ) + IF(${flag_var} MATCHES "/MD") + STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + ENDIF(${flag_var} MATCHES "/MD") + ENDFOREACH(flag_var) + ENDIF() +ENDIF(MSVC) + +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 +TARGET_LINK_LIBRARIES(grpc_node_plugin libprotoc libprotobuf ) diff --git a/packages/grpc-tools/build_binaries.sh b/packages/grpc-tools/build_binaries.sh index d22bbc4ff..e98743ba1 100755 --- a/packages/grpc-tools/build_binaries.sh +++ b/packages/grpc-tools/build_binaries.sh @@ -17,29 +17,33 @@ set -e uname -a -cd $(dirname $0) +cd "$(dirname "$0")" base=$(pwd) protobuf_base=$base/deps/protobuf -tools_version=$(jq '.version' < package.json | tr -d '"') +tools_version=$(jq '.version'