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 84821e9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 45 deletions.
31 changes: 24 additions & 7 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ on:

jobs:
build:
env:
GRPC_BUILD_ENABLE_CCACHE: "ON"
runs-on: ${{matrix.host}}
strategy:
fail-fast: false
matrix:
target: [Linux, Windows, OSX]
target: [OSX, Android, iOS]
build_type: [Debug, Release]
include:
- target: Linux
host: ubuntu-latest
- target: Windows
host: windows-latest
# - target: Linux
# host: ubuntu-latest
# - target: Windows
# 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 Down Expand Up @@ -47,16 +53,27 @@ jobs:
- name: Install Darwin dependencies
if: ${{ matrix.host == 'macos-latest'}}
run: |
brew install ccache
brew install ccache
- name: Install bindgen
run: cargo install cbindgen

- name: Add iOS toolchain
if: ${{ matrix.target == 'iOS' }}
run: |
rustup toolchain install 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: Add Rust target
run: rustup target add wasm32-unknown-emscripten

- name: Configure CMake
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
2 changes: 1 addition & 1 deletion build/Android/Boost-for-Android
2 changes: 1 addition & 1 deletion 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
6 changes: 6 additions & 0 deletions build/CommonCompilerOptions.CMake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ get_filename_component(PROJECT_SRC_FOLDER "${PROJECT_BUILD_FOLDER}" DIRECTORY AB
include(${PROJECT_BUILD_FOLDER}/cmake.in/functions.cmake)
include(ExternalProject)

# ProcessorCount
include(ProcessorCount)
ProcessorCount(PROCESSOR_COUNT)

# 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/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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${CMAKE_EXECUTABLE_SUFFIX} ${BOOST_B2_FLAGS} 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=<INSTALL_DIR> install
BUILD_COMMAND <SOURCE_DIR>/b2${CMAKE_EXECUTABLE_SUFFIX} ${BOOST_B2_FLAGS} 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=<INSTALL_DIR> -j ${PROCESSOR_COUNT} install
BUILD_IN_SOURCE TRUE

INSTALL_COMMAND ""
Expand Down
4 changes: 3 additions & 1 deletion build/OSX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.22)

message(WARNING "Using ${CMAKE_GENERATOR} as the generator!")

if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
message(FATAL_ERROR "${CMAKE_HOST_SYSTEM_NAME} host system name does not match OSX Darwin - Please select the correct folder for configuring project")
endif()
Expand Down Expand Up @@ -45,7 +47,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} -j ${PROCESSOR_COUNT} install
BUILD_IN_SOURCE TRUE

INSTALL_COMMAND ""
Expand Down
2 changes: 1 addition & 1 deletion build/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ExternalProject_Add(Boost

CONFIGURE_COMMAND ./bootstrap.bat ${VC_PLATFORMTOOLSET}

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

INSTALL_COMMAND ""
Expand Down

0 comments on commit 84821e9

Please sign in to comment.