diff --git a/.github/workflows/cortex-build.yml b/.github/workflows/cortex-build.yml index 453ed1180..8f6c51edc 100644 --- a/.github/workflows/cortex-build.yml +++ b/.github/workflows/cortex-build.yml @@ -45,7 +45,6 @@ jobs: runs-on: "ubuntu-20-04" cmake-flags: "" build-deps-cmake-flags: "" - ccache-dir: "" arch: "x64" platform: "linux" - os: "mac" @@ -53,7 +52,6 @@ jobs: runs-on: "macos-13" cmake-flags: "" build-deps-cmake-flags: "" - ccache-dir: "" arch: "x64" platform: "darwin" - os: "mac" @@ -61,7 +59,6 @@ jobs: runs-on: "macos-latest" cmake-flags: "-DMAC_ARM64=ON" build-deps-cmake-flags: "" - ccache-dir: "" arch: "arm64" platform: "darwin" - os: "windows" @@ -69,7 +66,6 @@ jobs: runs-on: "windows-cuda-12-0" cmake-flags: "-DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja" build-deps-cmake-flags: "-DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja" - ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache' arch: "x64" platform: "windows" @@ -184,7 +180,6 @@ jobs: - name: "Update version by tag" working-directory: cortex-cpp - shell: bash run: | echo "Version: ${{ needs.create-draft-release.outputs.version }}" # Update the version in package.json @@ -212,6 +207,7 @@ jobs: # Setup .npmrc file to publish to npm - upload only once - run: npm publish --access public + continue-on-error: true if: runner.os == 'linux' env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/cortex-cpp/CMakeLists.txt b/cortex-cpp/CMakeLists.txt index ef7ae2da6..031428263 100644 --- a/cortex-cpp/CMakeLists.txt +++ b/cortex-cpp/CMakeLists.txt @@ -1,12 +1,6 @@ cmake_minimum_required(VERSION 3.5) -cmake_policy(SET CMP0091 NEW) -cmake_policy(SET CMP0042 NEW) -project(cortex-cpp C CXX) -# Build using CMAKE-JS -if(DEFINED CMAKE_JS_INC) - include_directories(${CMAKE_JS_INC}) -endif() +project(cortex-cpp C CXX) # Build using CMAKE-JS if(DEFINED CMAKE_JS_INC) @@ -97,9 +91,23 @@ endif() # and comment out the following lines find_package(Drogon CONFIG REQUIRED) -target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon - ${CMAKE_THREAD_LIBS_INIT}) + +# Build using CMAKE-JS +if(DEFINED CMAKE_JS_INC) + set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") + + target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon + ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_JS_LIB}) + + if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET) + # Generate node.lib + execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS}) + endif() +else() + target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon + ${CMAKE_THREAD_LIBS_INIT}) +endif() # ############################################################################## if(CMAKE_CXX_STANDARD LESS 17) @@ -132,15 +140,3 @@ target_sources(${PROJECT_NAME} PRIVATE ${CTL_SRC} ${COMMON_SRC}) # ############################################################################## # uncomment the following line for dynamically loading views set_property(TARGET # ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON) - -# Build using CMAKE-JS -if(DEFINED CMAKE_JS_INC) - set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") - - target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) - - if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET) - # Generate node.lib - execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS}) - endif() -endif() \ No newline at end of file diff --git a/cortex-cpp/package.json b/cortex-cpp/package.json index a3a0fbd79..4a121be75 100644 --- a/cortex-cpp/package.json +++ b/cortex-cpp/package.json @@ -9,10 +9,10 @@ "url": "git+https://github.com/janhq/cortex.git" }, "scripts": { - "install": "prebuild-install --runtime napi --backend cmake-js || cmake-js rebuild", - "build": "cmake-js configure && cmake-js build", - "rebuild": "cmake-js rebuild", - "prebuild": "prebuild --runtime napi --backend cmake-js --all --strip --verbose", + "install": "prebuild-install --runtime napi --backend cmake-js --config Release || cmake-js rebuild --config Release", + "build": "cmake-js configure --config Release && cmake-js build --config Release", + "rebuild": "cmake-js rebuild --config Release", + "prebuild": "prebuild --runtime napi --backend cmake-js --all --strip --verbose --config Release", "upload": "prebuild --runtime napi --backend cmake-js --upload ${GITHUB_TOKEN}" }, "author": "Jan ", @@ -35,7 +35,7 @@ ] }, "files": [ - "*.js", - "*.d.ts" + "binding/*.js", + "binding/*.d.ts" ] }