diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2c85f58f..19371e28 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -92,12 +92,6 @@ jobs: with: packages: tools platform-tools ndk;${{ env.NDK_VERSION }} - run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim - # macOS runners ship a newer CMake than the project supports; pin it to match the version used elsewhere in CI - - name: Install compatible CMake version - if: runner.os == 'macOS' - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: ${{ env.CMAKE_VERSION }} - run: npm ci - run: npm run bootstrap - run: npm test @@ -125,12 +119,6 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.job }}-${{ runner.os }} - # macOS runners ship a newer CMake than the project supports; pin it to match the version used elsewhere in CI - - name: Install compatible CMake version - if: runner.os == 'macOS' - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: ${{ env.CMAKE_VERSION }} - run: npm ci - run: npm run build - name: Prepare weak-node-api @@ -168,11 +156,6 @@ jobs: with: packages: tools platform-tools ndk;${{ env.NDK_VERSION }} - run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim - # macOS runners ship a newer CMake than the project supports; pin it to match the version used elsewhere in CI - - name: Install compatible CMake version - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: ${{ env.CMAKE_VERSION }} - run: npm ci - run: npm run bootstrap env: @@ -209,10 +192,6 @@ jobs: with: java-version: "17" distribution: "temurin" - - name: Install compatible CMake version - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: ${{ env.CMAKE_VERSION }} - run: rustup target add x86_64-apple-darwin - run: npm ci - run: npm run bootstrap @@ -345,11 +324,6 @@ jobs: distribution: "temurin" - run: rustup target add x86_64-apple-darwin x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim - run: rustup toolchain install nightly --component rust-src - # macOS runners ship a newer CMake than the project supports; pin it to match the version used elsewhere in CI - - name: Install compatible CMake version - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: ${{ env.CMAKE_VERSION }} - run: npm ci - run: npm run build - name: Build weak-node-api for all Apple architectures diff --git a/packages/weak-node-api/CMakeLists.txt b/packages/weak-node-api/CMakeLists.txt index 90525434..29080360 100644 --- a/packages/weak-node-api/CMakeLists.txt +++ b/packages/weak-node-api/CMakeLists.txt @@ -10,24 +10,32 @@ add_library(${PROJECT_NAME} SHARED) set(INCLUDE_DIR "include") set(GENERATED_SOURCE_DIR "generated") +set(PUBLIC_HEADER_FILES + ${GENERATED_SOURCE_DIR}/weak_node_api.hpp + ${GENERATED_SOURCE_DIR}/NodeApiHost.hpp + ${INCLUDE_DIR}/js_native_api_types.h + ${INCLUDE_DIR}/js_native_api.h + ${INCLUDE_DIR}/node_api_types.h + ${INCLUDE_DIR}/node_api.h +) + target_sources(${PROJECT_NAME} PUBLIC ${GENERATED_SOURCE_DIR}/weak_node_api.cpp - PUBLIC FILE_SET HEADERS - BASE_DIRS ${GENERATED_SOURCE_DIR} ${INCLUDE_DIR} FILES - ${GENERATED_SOURCE_DIR}/weak_node_api.hpp - ${GENERATED_SOURCE_DIR}/NodeApiHost.hpp - ${INCLUDE_DIR}/js_native_api_types.h - ${INCLUDE_DIR}/js_native_api.h - ${INCLUDE_DIR}/node_api_types.h - ${INCLUDE_DIR}/node_api.h ) -get_target_property(PUBLIC_HEADER_FILES ${PROJECT_NAME} HEADER_SET) +# Expose the public headers to consumers within the build tree (e.g. the tests) +# regardless of how they are packaged below. +target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ +) # Stripping the prefix from the library name # to make sure the name of the XCFramework will match the name of the library if(APPLE) + # Frameworks ship their public headers via the PUBLIC_HEADER property. set_target_properties(${PROJECT_NAME} PROPERTIES FRAMEWORK TRUE MACOSX_FRAMEWORK_IDENTIFIER com.callstack.${PROJECT_NAME} @@ -37,6 +45,13 @@ if(APPLE) XCODE_ATTRIBUTE_SKIP_INSTALL NO PUBLIC_HEADER "${PUBLIC_HEADER_FILES}" ) +else() + # Elsewhere, ship the public headers via a HEADERS file set for install packaging. + target_sources(${PROJECT_NAME} + PUBLIC FILE_SET HEADERS + BASE_DIRS ${GENERATED_SOURCE_DIR} ${INCLUDE_DIR} FILES + ${PUBLIC_HEADER_FILES} + ) endif() # C++20 is needed to use designated initializers