Skip to content

Commit

Permalink
Disabled whole gRPC_host build for protbuf only
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed Jul 18, 2024
1 parent 80c26fb commit aa66485
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 52 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ jobs:
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/${{matrix.build_type}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}}

- name: Build project
run: cmake --build build/${{matrix.target}}/${{matrix.build_type}} --config ${{matrix.build_type}} -j
run: cmake --build build/${{matrix.target}}/${{matrix.build_type}} --config ${{matrix.build_type}} -j --target protobuf-plugin
continue-on-error: true

- name: See protobuf-host cache
if: ${{matrix.target == 'Android'}}
run: cat build/${{matrix.target}}/${{matrix.build_type}}/protobuf_host/src/protobuf_host-build/CMakeCache.txt
91 changes: 40 additions & 51 deletions build/CommonTargets.CMake
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,38 @@ ExternalProject_Add(GTest
)
set(_FINDPACKAGE_GTEST_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/GTest/lib/cmake/GTest")

set(COMMON_GRPC_CACHE_ARGS
-DABSL_ENABLE_INSTALL:BOOL=ON
-DABSL_PROPAGATE_CXX_STD:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DgRPC_BUILD_CSHARP_EXT:BOOL=OFF
-DgRPC_BUILD_GRPC_CPP_PLUGIN:BOOL=ON
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_NODE_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_PHP_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_RUBY_PLUGIN:BOOL=OFF
-DgRPC_INSTALL:BOOL=ON
-Dprotobuf_ABSL_PROVIDER:STRING=package
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=ON
-DRE2_BUILD_TESTING:BOOL=OFF
${_MSVC_RUNTIME_LIBRARY}
)

# Build gRPC and protoc for host OS.
# gRPC build is needed for `grpc_plugin_cpp`.
# Build protoc for host OS.
if(CMAKE_CROSSCOMPILING)
set(GRPC_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gRPC_host")
set(PROTOBUF_TARGET gRPC_host)
set(GRPC_HOST_TARGET gRPC_host)
set(gRPC_BUILD_CODEGEN OFF)

ExternalProject_Add(gRPC_host
PREFIX ${GRPC_HOST_PREFIX}
SOURCE_DIR "${THIRDPARTY_DIR}/grpc"
set(PROTOBUF_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/protobuf_host")
set(PROTOBUF_TARGET protobuf_host)

ExternalProject_Add(protobuf_host
PREFIX ${PROTOBUF_HOST_PREFIX}
SOURCE_DIR "${THIRDPARTY_DIR}/grpc/third_party/protobuf"
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
CMAKE_CACHE_ARGS
${COMMON_GRPC_CACHE_ARGS}
)

set(_grpc_EXTRA_PARAM
-DgRPC_BUILD_GRPC_CPP_PLUGIN:BOOL=OFF
-DCMAKE_PROGRAM_PATH:STRING=${GRPC_HOST_PREFIX}/bin;${CMAKE_PROGRAM_PATH}
-DABSL_BUILD_TESTING:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-Dprotobuf_BUILD_TESTS:BOOL=OFF
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-Dprotobuf_INSTALL:BOOL=ON
)
else()
set(GRPC_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc")
set(PROTOBUF_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc")
set(PROTOBUF_TARGET grpc)
set(gRPC_BUILD_CODEGEN ON)
endif()

set(PROTOBUF_HOST_PREFIX "${GRPC_HOST_PREFIX}")

if(MSVC)
set(Protobuf_HOST_DIR "${PROTOBUF_HOST_PREFIX}/cmake")
else()
set(Protobuf_HOST_DIR "${PROTOBUF_HOST_PREFIX}/lib/cmake/protobuf")
endif()

set(absl_HOST_DIR "${GRPC_HOST_PREFIX}/lib/cmake/absl")
set(utf8_range_HOST_DIR "${GRPC_HOST_PREFIX}/lib/cmake/utf8_range")
set(absl_HOST_DIR "${PROTOBUF_HOST_PREFIX}/lib/cmake/absl")
set(utf8_range_HOST_DIR "${PROTOBUF_HOST_PREFIX}/lib/cmake/utf8_range")

set(PROTOBUF_HOST_INCLUDE_DIR "${PROTOBUF_HOST_PREFIX}/include")
set(PROTOBUF_HOST_LIB_DIR "${PROTOBUF_HOST_PREFIX}/lib")
Expand Down Expand Up @@ -110,17 +83,33 @@ ExternalProject_Add(grpc
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
CMAKE_CACHE_ARGS
${_CMAKE_COMMON_CACHE_ARGS}
${COMMON_GRPC_CACHE_ARGS}
-DgRPC_BUILD_CODEGEN:BOOL=${gRPC_BUILD_CODEGEN}
-DABSL_ENABLE_INSTALL:BOOL=ON
-DABSL_PROPAGATE_CXX_STD:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-Dc-ares_DIR:PATH=${_FINDPACKAGE_CARES_CONFIG_DIR}
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DgRPC_BUILD_CODEGEN:BOOL=OFF
-DgRPC_BUILD_CSHARP_EXT:BOOL=OFF
-DgRPC_BUILD_GRPC_CPP_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_NODE_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_PHP_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN:BOOL=OFF
-DgRPC_BUILD_GRPC_RUBY_PLUGIN:BOOL=OFF
-DgRPC_CARES_PROVIDER:STRING=package
-DgRPC_INSTALL:BOOL=ON
-DgRPC_SSL_PROVIDER:STRING=package
-DgRPC_ZLIB_PROVIDER:STRING=package
-Dprotobuf_ABSL_PROVIDER:STRING=package
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=ON
-DRE2_BUILD_TESTING:BOOL=OFF
-DZLIB_ROOT:PATH=${ZLIB_ROOT}
-DZLIB_USE_STATIC_LIBS:BOOL=ON
-DgRPC_SSL_PROVIDER:STRING=package
-DgRPC_CARES_PROVIDER:STRING=package
-Dc-ares_DIR:PATH=${_FINDPACKAGE_CARES_CONFIG_DIR}
${_OPENSSL_CACHE_ARGS}
${_grpc_EXTRA_PARAM}
DEPENDS openssl ${GRPC_HOST_TARGET} zlib cares
DEPENDS openssl zlib cares
)

ExternalProject_Get_Property(grpc INSTALL_DIR)
Expand Down

0 comments on commit aa66485

Please sign in to comment.