diff --git a/ports/node-addon-api/unofficial-node-addon-api-config.cmake b/ports/node-addon-api/unofficial-node-addon-api-config.cmake index ace4d47b75..57e2a2625f 100644 --- a/ports/node-addon-api/unofficial-node-addon-api-config.cmake +++ b/ports/node-addon-api/unofficial-node-addon-api-config.cmake @@ -1,9 +1,9 @@ if(NOT TARGET unofficial::node-addon-api::node-addon-api) include(CMakeFindDependencyMacro) - find_dependency(unofficial-node-api CONFIG) + find_dependency(unofficial-node-api-headers CONFIG) add_library(unofficial::node-addon-api::node-addon-api IMPORTED INTERFACE) - target_link_libraries(unofficial::node-addon-api::node-addon-api INTERFACE unofficial::node-api::node-api) + target_link_libraries(unofficial::node-addon-api::node-addon-api INTERFACE unofficial::node-api-headers::node-api-headers) set_target_properties(unofficial::node-addon-api::node-addon-api PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../include/" diff --git a/ports/node-addon-api/vcpkg.json b/ports/node-addon-api/vcpkg.json index b1a236d1d3..03bdd1a4e0 100644 --- a/ports/node-addon-api/vcpkg.json +++ b/ports/node-addon-api/vcpkg.json @@ -1,12 +1,13 @@ { "name": "node-addon-api", "version": "6.0.0", + "port-version": 1, "description": "Module for using Node-API from C++", "homepage": "https://github.com/nodejs/node-addon-api", "license": "MIT", "supports": "((windows & !arm) | linux | osx) & !uwp", "dependencies": [ - "node-api", + "node-api-headers", { "name": "vcpkg-cmake", "host": true diff --git a/ports/node-api-headers/CMakeLists.txt b/ports/node-api-headers/CMakeLists.txt new file mode 100644 index 0000000000..8360555407 --- /dev/null +++ b/ports/node-api-headers/CMakeLists.txt @@ -0,0 +1,15 @@ +project(nodelib C) + +add_custom_target(nodelib ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/node.lib) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/node.lib + COMMAND ${CMAKE_AR} + /def:${CMAKE_CURRENT_SOURCE_DIR}/def/node_api.def + /out:${CMAKE_CURRENT_BINARY_DIR}/node.lib + ${CMAKE_STATIC_LINKER_FLAGS} + $<$:${CMAKE_STATIC_LINKER_FLAGS_DEBUG}> + $<$:${CMAKE_STATIC_LINKER_FLAGS_RELEASE}> + COMMENT "Building import library for NodeJS" +) + +install(FILES ${CMAKE_BINARY_DIR}/node.lib DESTINATION lib) diff --git a/ports/node-api-headers/portfile.cmake b/ports/node-api-headers/portfile.cmake new file mode 100644 index 0000000000..934e64c0dd --- /dev/null +++ b/ports/node-api-headers/portfile.cmake @@ -0,0 +1,19 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO nodejs/node-api-headers + REF "v${VERSION}" + SHA512 095cff78b1bc4ca7cc81de30e941fb369f41596b3ae9d092100b1a5baf2c00ef9a4ac14016605346bc0532eb459b6a7dea10ed53fa595cf65825010ce75fcb67 + HEAD_REF main +) + +if(VCPKG_TARGET_IS_WINDOWS) + file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") + vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}") + vcpkg_cmake_install() +endif() + +file(INSTALL "${SOURCE_PATH}/include" DESTINATION "${CURRENT_PACKAGES_DIR}/include" RENAME "node") + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) + +configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-${PORT}-config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" @ONLY) diff --git a/ports/node-api-headers/unofficial-node-api-headers-config.cmake.in b/ports/node-api-headers/unofficial-node-api-headers-config.cmake.in new file mode 100644 index 0000000000..50d9a45aa2 --- /dev/null +++ b/ports/node-api-headers/unofficial-node-api-headers-config.cmake.in @@ -0,0 +1,34 @@ +if(NOT TARGET unofficial::node-api-headers::node-api-headers) + if(WIN32) + add_library(unofficial::node-api-headers::node-api-headers UNKNOWN IMPORTED) + else() + add_library(unofficial::node-api-headers::node-api-headers INTERFACE IMPORTED) + endif() + + set(node-api-headers_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../include/node) + + set_target_properties(unofficial::node-api-headers::node-api-headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${node-api-headers_INCLUDE_DIR}" + ) + + if(APPLE) + set_target_properties(unofficial::node-api-headers::node-api-headers PROPERTIES + INTERFACE_LINK_OPTIONS "LINKER:SHELL:-undefined dynamic_lookup" + ) + endif() + + if(WIN32) + find_library(node-api-headers_LIBRARY_RELEASE NAMES node PATHS "${CMAKE_CURRENT_LIST_DIR}/../../lib" NO_DEFAULT_PATH REQUIRED) + set_target_properties(unofficial::node-api-headers::node-api-headers PROPERTIES + IMPORTED_LOCATION_RELEASE "${node-api-headers_LIBRARY_RELEASE}" + IMPORTED_CONFIGURATIONS RELEASE + ) + if("@VCPKG_BUILD_TYPE@" STREQUAL "") + find_library(node-api-headers_LIBRARY_DEBUG NAMES node PATHS "${CMAKE_CURRENT_LIST_DIR}/../../debug/lib" NO_DEFAULT_PATH REQUIRED) + set_target_properties(unofficial::node-api-headers::node-api-headers PROPERTIES + IMPORTED_LOCATION_DEBUG "${node-api-headers_LIBRARY_DEBUG}" + ) + set_property(TARGET unofficial::node-api-headers::node-api-headers APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + endif() + endif() +endif() diff --git a/ports/node-api/vcpkg.json b/ports/node-api-headers/vcpkg.json similarity index 50% rename from ports/node-api/vcpkg.json rename to ports/node-api-headers/vcpkg.json index 1aa1c247fb..1b5a538d9d 100644 --- a/ports/node-api/vcpkg.json +++ b/ports/node-api-headers/vcpkg.json @@ -1,19 +1,20 @@ { - "name": "node-api", - "version-semver": "18.12.1", - "port-version": 2, + "name": "node-api-headers", + "version": "0.0.5", "description": "NodeJS API for writing modules in C++", "homepage": "https://nodejs.org/api/addons.html", - "license": null, - "supports": "((windows & !arm) | linux | osx) & !uwp", + "license": "MIT", + "supports": "(windows & !arm & !uwp) | linux | osx", "dependencies": [ { "name": "vcpkg-cmake", - "host": true + "host": true, + "platform": "windows" }, { "name": "vcpkg-cmake-config", - "host": true + "host": true, + "platform": "windows" } ] } diff --git a/ports/node-api/portfile.cmake b/ports/node-api/portfile.cmake deleted file mode 100644 index 53a4f17e82..0000000000 --- a/ports/node-api/portfile.cmake +++ /dev/null @@ -1,76 +0,0 @@ -set(SHA512 0) - -if(VCPKG_TARGET_IS_WINDOWS) - set(SHA512 ee66d0c03d2e48046a42616abf7639a3983e7db24c04d8643b9141cb9209a50643e31873c5a4918853a4344e822d653480558510a4db9a2ab481396891d79917) - set(DIST_URL "https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-headers.tar.gz") - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - vcpkg_download_distfile( - out_win_lib - URLS "https://nodejs.org/dist/v${VERSION}/win-x64/node.lib" - FILENAME "node.lib" - SHA512 95c4b053bf88f758b6124b4a576719901545485613767f1ab996bb019ea7bb0d303c511b357f830e5a14d463dd74c6b412f126103f21d12e31ca00c7de86d853 - ) - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - vcpkg_download_distfile( - out_win_lib - URLS "https://nodejs.org/dist/v${VERSION}/win-x86/node.lib" - FILENAME "node.lib" - SHA512 0baa54a7870088a3290f817f6362446d304e8710ee36f99075925d110bce5c1eac377aa5c4ed6cf30161f98f39032d848eeb8d459add57b1c6458b8c91c72073 - ) - endif() -elseif(VCPKG_TARGET_IS_OSX) - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - set(SHA512 8eb1713afdce23b0e8408d81aa47b3ea0955de328105d666a57efef8955b286c707c107377cff36164d8455558829ab65567b9cbe5997085afc841d95128fcd5) - set(DIST_URL "https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-darwin-arm64.tar.gz") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(SHA512 ffe7e878fd5e424b0ff0d2e7db5e9c02f283792df2f1a748bd6381226701bcd9f93ae48f88d295412afb10d1c924ca068f70aba9857236c8893a2b812eacf248) - set(DIST_URL "https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-darwin-x64.tar.gz") - endif() -elseif(VCPKG_TARGET_IS_LINUX) - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(SHA512 f137a0dba52ded9f2f6b304c5f41fd2c75ba069ee31cfb89811b14254552c0d5ba10890f7001e64e8a6fee277302cb0ba915e0a417c047577384ac495c4ff447) - set(DIST_URL "https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-linux-x64.tar.gz") - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - set(SHA512 a0b2f522b0ecdc4b642f3104fd2eb08b8dfa6dc2b116b5a331722b8c6d96b2b6d5df0e691ef2b56e0463e1f30d37c98c686c5d306e1aa8cd927b306c4eef0770) - set(DIST_URL "https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-linux-arm64.tar.gz") - endif() -endif() - -get_filename_component(DIST_FILENAME "${DIST_URL}" NAME) - -if(out_win_lib) - # nodejs requires the same node.lib to be used for both debug and release builds - file(COPY "${out_win_lib}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib") - file(COPY "${out_win_lib}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib") -endif() - -# download dist -vcpkg_download_distfile( - out_dist - URLS "${DIST_URL}" - FILENAME "${DIST_FILENAME}" - SHA512 "${SHA512}" -) - -# extract dist -vcpkg_extract_source_archive( - OUT_SOURCE_PATH - ARCHIVE "${out_dist}" -) - -# copy headers -set(suffix "include/node") -set(source_path "${OUT_SOURCE_PATH}/${suffix}") -file(COPY "${source_path}" DESTINATION "${CURRENT_PACKAGES_DIR}/include" FILES_MATCHING PATTERN "*.h") - -# we do not take the license from the dist file because for windows it is not included as we download the headers only -set(license_url "https://raw.githubusercontent.com/nodejs/node/v${VERSION}/LICENSE") -vcpkg_download_distfile( - out_license - URLS "${license_url}" - FILENAME "LICENSE" - SHA512 2d79b49a12178a078cf1246ef7589d127189914403cd6f4dfe277ced2b3ef441a6e6ee131f1c75f996d1c1528b7e1ae332e83c1dc44580b2b51a933ed0c50c48 -) -file(INSTALL "${out_license}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) - -configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-node-api-config.cmake.in" "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-node-api-config.cmake" @ONLY) diff --git a/ports/node-api/unofficial-node-api-config.cmake.in b/ports/node-api/unofficial-node-api-config.cmake.in deleted file mode 100644 index 452d765761..0000000000 --- a/ports/node-api/unofficial-node-api-config.cmake.in +++ /dev/null @@ -1,38 +0,0 @@ -if(NOT TARGET unofficial::node-api::node-api) - if(WIN32) - add_library(unofficial::node-api::node-api UNKNOWN IMPORTED) - else() - add_library(unofficial::node-api::node-api INTERFACE IMPORTED) - endif() - - find_path(node-api_INCLUDE_DIR - NAMES node.h - PATHS "${CMAKE_CURRENT_LIST_DIR}/../../include/node" - NO_DEFAULT_PATH - REQUIRED - ) - set_target_properties(unofficial::node-api::node-api PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${node-api_INCLUDE_DIR}" - ) - - if(APPLE) - set_target_properties(unofficial::node-api::node-api PROPERTIES - INTERFACE_LINK_OPTIONS "LINKER:SHELL:-undefined dynamic_lookup" - ) - endif() - - if(WIN32) - find_library(node-api_LIBRARY_RELEASE NAMES node PATHS "${CMAKE_CURRENT_LIST_DIR}/../../lib" NO_DEFAULT_PATH REQUIRED) - set_target_properties(unofficial::node-api::node-api PROPERTIES - IMPORTED_LOCATION_RELEASE "${node-api_LIBRARY_RELEASE}" - IMPORTED_CONFIGURATIONS RELEASE - ) - if("@VCPKG_BUILD_TYPE@" STREQUAL "") - find_library(node-api_LIBRARY_DEBUG NAMES node PATHS "${CMAKE_CURRENT_LIST_DIR}/../../debug/lib" NO_DEFAULT_PATH REQUIRED) - set_target_properties(unofficial::node-api::node-api PROPERTIES - IMPORTED_LOCATION_DEBUG "${node-api_LIBRARY_DEBUG}" - ) - set_property(TARGET unofficial::node-api::node-api APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - endif() - endif() -endif() diff --git a/versions/baseline.json b/versions/baseline.json index 0b046f93f0..dd46fe9d54 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5550,11 +5550,11 @@ }, "node-addon-api": { "baseline": "6.0.0", - "port-version": 0 + "port-version": 1 }, - "node-api": { - "baseline": "18.12.1", - "port-version": 2 + "node-api-headers": { + "baseline": "0.0.5", + "port-version": 0 }, "nonius": { "baseline": "2019-04-20", diff --git a/versions/n-/node-addon-api.json b/versions/n-/node-addon-api.json index bda5bcc637..2756ba6a2a 100644 --- a/versions/n-/node-addon-api.json +++ b/versions/n-/node-addon-api.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "cfdebff816f735bc5922266b54623e0a70b667cf", + "version": "6.0.0", + "port-version": 1 + }, { "git-tree": "45cf82eea2cea9f8fa60b8a476f6484f75f81ca5", "version": "6.0.0", diff --git a/versions/n-/node-api-headers.json b/versions/n-/node-api-headers.json new file mode 100644 index 0000000000..3661dfcd40 --- /dev/null +++ b/versions/n-/node-api-headers.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "d8703d51a9b88c204782885707fc580ab490e9f4", + "version": "0.0.5", + "port-version": 0 + } + ] +}