Skip to content

Commit

Permalink
Attempt to fix OSX CI by using module compatible protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed Jul 3, 2024
1 parent dc6be8f commit 6267fe3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 43 deletions.
33 changes: 27 additions & 6 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:

jobs:
build:
env:
GRPC_BUILD_ENABLE_CCACHE: "ON"
runs-on: ${{matrix.host}}
strategy:
fail-fast: false
matrix:
target: [Linux, Windows, OSX]
target: [Linux, Windows, OSX, Android, iOS]
build_type: [Debug, Release]
include:
- target: Linux
Expand All @@ -18,6 +20,10 @@ jobs:
host: windows-latest
- target: OSX
host: macos-latest
- target: Android
host: ubuntu-latest
- target: iOS
host: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -32,22 +38,37 @@ jobs:
sudo update-alternatives --set cc $(which clang)
sudo update-alternatives --set c++ $(which clang++)
- name: Install Linux dependencies
- name: Install Linux host dependencies
if: ${{ matrix.host == 'ubuntu-latest'}}
run: |
sudo apt install ccache -y
sudo apt install ninja-build -y
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
- name: Install Windows dependencies
- name: Install Windows host dependencies
if: ${{ matrix.host == 'windows-latest'}}
run: |
choco install ccache -A
- name: Install Darwin dependencies
- name: Install Darwin host dependencies
if: ${{ matrix.host == 'macos-latest'}}
run: |
brew install ccache
brew install ccache
- name: Add Darwin toolchain
run: rustup target add x86_64-apple-darwin

- name: Add iOS toolchain
if: ${{ matrix.target == 'iOS' }}
run: |
rustup toolchain install nightly-aarch64-apple-darwin
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
rustup target add aarch64-apple-ios
- name: Add Android toolchain
if: ${{ matrix.target == 'Android' }}
run: |
rustup target add aarch64-linux-android
- name: Install bindgen
run: cargo install cbindgen
Expand All @@ -59,4 +80,4 @@ 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}}
run: cmake --build build/${{matrix.target}}/${{matrix.build_type}} --config ${{matrix.build_type}} --target wallet-core --verbose
4 changes: 2 additions & 2 deletions build/Android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ExternalProject_Add(Boost

CONFIGURE_COMMAND ""
PATCH_COMMAND ""
BUILD_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/Boost-for-Android/build-android.sh" ${CMAKE_ANDROID_NDK} --src-dir="${THIRDPARTY_DIR}/boost" --boost="${BOOST_VERSION}" --arch="${ANDROID_ABI}" --target-version="${ANDROID_PLATFORM_LEVEL}" --prefix="${BOOST_ROOT}" --with-libraries="${BOOST_INCLUDE_LIBRARIES_COMMA_SEPARATED}" --extra="--build-type=minimal,visibility=global,cxxstd=${CMAKE_CXX_STANDARD}"
BUILD_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Boost-for-Android/build-android.sh ${CMAKE_ANDROID_NDK} --src-dir="${THIRDPARTY_DIR}/boost" --boost="${BOOST_VERSION}" --arch="${ANDROID_ABI}" --target-version="${ANDROID_PLATFORM_LEVEL}" --prefix="${BOOST_ROOT}" --with-libraries="${BOOST_INCLUDE_LIBRARIES_COMMA_SEPARATED}" --extra="--build-type=minimal,visibility=global,cxxstd=${CMAKE_CXX_STANDARD}"
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
Expand Down Expand Up @@ -114,7 +114,7 @@ elseif(ANDROID_ABI STREQUAL "x86_64")
set(OPENSSL_ABI android-x86_64)
endif()

set(OPENSSL_VARIANT "$<$<CONFIG:Debug>:--debug>")
set(OPENSSL_VARIANT $<$<CONFIG:Debug>:--debug>)

set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/openssl/build/Android/${ANDROID_ABI}")

Expand Down
1 change: 1 addition & 0 deletions build/CommonCompilerOptions.CMake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ get_filename_component(PROJECT_SRC_FOLDER "${PROJECT_BUILD_FOLDER}" DIRECTORY AB
include(${PROJECT_BUILD_FOLDER}/cmake.in/functions.cmake)
include(ExternalProject)

# Boost
set(BOOST_VARIANT $<IF:$<CONFIG:Debug>,debug,release>)

# Workaround for on GitHub actions, probably permission error - get_BOOST_version(BOOST_VERSION "${THIRDPARTY_DIR}/boost/boost/version.hpp")
Expand Down
62 changes: 29 additions & 33 deletions build/CommonTargets.CMake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ 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`.
if(CMAKE_CROSSCOMPILING)
Expand All @@ -36,23 +58,7 @@ if(CMAKE_CROSSCOMPILING)
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
CMAKE_CACHE_ARGS
-DABSL_ENABLE_INSTALL: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_MSVC_STATIC_RUNTIME:BOOL=ON
-DRE2_BUILD_TESTING:BOOL=OFF
${_MSVC_RUNTIME_LIBRARY}
${COMMON_GRPC_CACHE_ARGS}
)

set(_grpc_EXTRA_PARAM
Expand Down Expand Up @@ -118,21 +124,9 @@ ExternalProject_Add(grpc
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
CMAKE_CACHE_ARGS
${_CMAKE_COMMON_CACHE_ARGS}
-DABSL_PROPAGATE_CXX_STD:BOOL=ON
${COMMON_GRPC_CACHE_ARGS}
-DgRPC_BUILD_CODEGEN:BOOL=${gRPC_BUILD_CODEGEN}
-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
-DgRPC_ZLIB_PROVIDER:STRING=package
-Dprotobuf_ABSL_PROVIDER:STRING=package
-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
Expand Down Expand Up @@ -357,6 +351,7 @@ ExternalProject_Add(libp2p
-Dfmt_DIR:PATH=${_FINDPACKAGE_FMT_CONFIG_DIR}
-DHUNTER_ENABLED:BOOL=OFF
-DProtobuf_DIR:PATH=${Protobuf_DIR}
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC_EXECUTABLE}
-Dsoralog_DIR:PATH=${_FINDPACKAGE_SORALOG_CONFIG_DIR}
-Dsqlite3_DIR:PATH=${_FINDPACKAGE_SQLITE3_CONFIG_DIR}
Expand Down Expand Up @@ -604,8 +599,10 @@ ExternalProject_Add(protobuf-plugin
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-Dabsl_DIR:PATH=${absl_HOST_DIR}
-DProtobuf_DIR:PATH=${Protobuf_HOST_DIR}
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-DTW_USE_EXTERNAL_PROTOC:BOOL=TRUE
-Dutf8_range_DIR:PATH=${utf8_range_HOST_DIR}
-DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
${_MSVC_RUNTIME_LIBRARY}
DEPENDS ${PROTOBUF_TARGET}
)
Expand All @@ -631,9 +628,8 @@ ExternalProject_Add(wallet-core
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-Dabsl_DIR:PATH=${absl_DIR}
-DBoost.DI_DIR:PATH=${_FINDPACKAGE_BOOST_DI_CONFIG_DIR}
-DProtobuf_DIR:PATH=${Protobuf_DIR}
-DProtobuf_LIB_DIR:PATH=${PROTOBUF_HOST_LIB_DIR}
-Dprotobuf_MODULE_COMPATIBLE:BOOL=ON
-DTESTING:BOOL=${TESTING}
-DTW_STATIC_LIBRARY:BOOL=TRUE
-DTW_UNIT_TESTS:BOOL=FALSE
Expand All @@ -643,7 +639,7 @@ ExternalProject_Add(wallet-core
${_BOOST_CACHE_ARGS}
${_OPENSSL_CACHE_ARGS}
${_GRPC_CACHE_ARGS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}\ -I\ ${Boost_INCLUDE_DIR}\ -I\ ${OPENSSL_INCLUDE_DIR}\ -I\ ${Protobuf_INCLUDE_DIR}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}\ -I\ ${OPENSSL_INCLUDE_DIR}
PATCH_COMMAND ${_WALLET_CORE_GENERATE_SCRIPT} --target-os=${_WALLET_CORE_ARCH} --arch-abi=${WALLET_CORE_ARCH_ABI} --protobuf-dir=${PROTOBUF_HOST_PREFIX} --out-dir=<INSTALL_DIR> --plugin-dir=${ProtobufPlugin_DIR}/bin
DEPENDS Boost grpc openssl protobuf-plugin
)
Expand Down
2 changes: 1 addition & 1 deletion build/OSX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ExternalProject_Add(Boost

CONFIGURE_COMMAND <SOURCE_DIR>/bootstrap.sh --with-toolset=clang --with-libraries=${BOOST_INCLUDE_LIBRARIES_COMMA_SEPARATED} --prefix=${BOOST_ROOT}

BUILD_COMMAND <SOURCE_DIR>/b2 ${BOOST_B2_FLAGS} toolset=darwin cxxstd=${CMAKE_CXX_STANDARD} visibility=global runtime-link=static link=static threading=multi --build-type=minimal address-model=64 architecture=x86 variant=${BOOST_VARIANT} --prefix=${BOOST_ROOT} install
BUILD_COMMAND <SOURCE_DIR>/b2${CMAKE_EXECUTABLE_SUFFIX} ${BOOST_B2_FLAGS} toolset=darwin cxxstd=${CMAKE_CXX_STANDARD} visibility=global runtime-link=static link=static threading=multi --build-type=minimal address-model=64 architecture=x86 variant=${BOOST_VARIANT} --prefix=${BOOST_ROOT} install
BUILD_IN_SOURCE TRUE

INSTALL_COMMAND ""
Expand Down

0 comments on commit 6267fe3

Please sign in to comment.