From baa9d834e7deca8dbf6fbc58fc8ff2509e3bc873 Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Wed, 15 Feb 2023 00:27:11 +0600 Subject: [PATCH] [node-api|node-addon-api] fix and update (#29599) * node-api-config-fix * port-ver * upd * hash * newver * add-ver * . * . * respect vcpkg_build_type in config * addver * Update node-addon-api.json --- ports/node-addon-api/portfile.cmake | 4 +- .../unofficial-node-addon-api-config.cmake | 16 ++++---- ports/node-addon-api/vcpkg.json | 2 +- ports/node-api/portfile.cmake | 7 +--- .../node-api/unofficial-node-api-config.cmake | 29 -------------- .../unofficial-node-api-config.cmake.in | 38 +++++++++++++++++++ ports/node-api/vcpkg.json | 2 +- versions/baseline.json | 4 +- versions/n-/node-addon-api.json | 5 +++ versions/n-/node-api.json | 5 +++ 10 files changed, 65 insertions(+), 47 deletions(-) delete mode 100644 ports/node-api/unofficial-node-api-config.cmake create mode 100644 ports/node-api/unofficial-node-api-config.cmake.in diff --git a/ports/node-addon-api/portfile.cmake b/ports/node-addon-api/portfile.cmake index 0898771176..2d6b96ab12 100644 --- a/ports/node-addon-api/portfile.cmake +++ b/ports/node-addon-api/portfile.cmake @@ -1,8 +1,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO nodejs/node-addon-api - REF v5.0.0 - SHA512 5ee14bc325ce66c6f645c3b638efaf69a7dfc90f0d6514f8568dedf34d5b5460b80c4438c4c12264d80c827edf46a82f0ecceb53b2a370ed5ec2ee640fa1ef7f + REF "v${VERSION}" + SHA512 f7889d676665f053577c4964b56a51d628f2da1bd9ee77b478b088cc11750952037687242e0a24036daae759d27c9b619b9f9db9c2c2839204d91af1603a1d90 HEAD_REF main ) 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 61ef8c8db7..ace4d47b75 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,11 @@ -include(CMakeFindDependencyMacro) -find_dependency(unofficial-node-api CONFIG) +if(NOT TARGET unofficial::node-addon-api::node-addon-api) + include(CMakeFindDependencyMacro) + find_dependency(unofficial-node-api 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) + 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) -set_target_properties(unofficial::node-addon-api::node-addon-api PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../include/" -) + set_target_properties(unofficial::node-addon-api::node-addon-api PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../include/" + ) +endif() diff --git a/ports/node-addon-api/vcpkg.json b/ports/node-addon-api/vcpkg.json index 69b556a777..b1a236d1d3 100644 --- a/ports/node-addon-api/vcpkg.json +++ b/ports/node-addon-api/vcpkg.json @@ -1,6 +1,6 @@ { "name": "node-addon-api", - "version": "5.0.0", + "version": "6.0.0", "description": "Module for using Node-API from C++", "homepage": "https://github.com/nodejs/node-addon-api", "license": "MIT", diff --git a/ports/node-api/portfile.cmake b/ports/node-api/portfile.cmake index ee04a9ed9c..53a4f17e82 100644 --- a/ports/node-api/portfile.cmake +++ b/ports/node-api/portfile.cmake @@ -1,5 +1,3 @@ -vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION} - set(SHA512 0) if(VCPKG_TARGET_IS_WINDOWS) @@ -66,7 +64,7 @@ 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/v18.12.1/LICENSE") +set(license_url "https://raw.githubusercontent.com/nodejs/node/v${VERSION}/LICENSE") vcpkg_download_distfile( out_license URLS "${license_url}" @@ -75,5 +73,4 @@ vcpkg_download_distfile( ) file(INSTALL "${out_license}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) -# copy ./unofficial-node-api-config.cmake to ${CURRENT_PACKAGES_DIR}/share/node-api -file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-node-api-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}") +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 b/ports/node-api/unofficial-node-api-config.cmake deleted file mode 100644 index f38708ae6e..0000000000 --- a/ports/node-api/unofficial-node-api-config.cmake +++ /dev/null @@ -1,29 +0,0 @@ -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) - 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}" - IMPORTED_LOCATION_RELEASE "${node-api_LIBRARY_RELEASE}" - ) -endif() diff --git a/ports/node-api/unofficial-node-api-config.cmake.in b/ports/node-api/unofficial-node-api-config.cmake.in new file mode 100644 index 0000000000..452d765761 --- /dev/null +++ b/ports/node-api/unofficial-node-api-config.cmake.in @@ -0,0 +1,38 @@ +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/ports/node-api/vcpkg.json b/ports/node-api/vcpkg.json index 66ebfd474e..1aa1c247fb 100644 --- a/ports/node-api/vcpkg.json +++ b/ports/node-api/vcpkg.json @@ -1,7 +1,7 @@ { "name": "node-api", "version-semver": "18.12.1", - "port-version": 1, + "port-version": 2, "description": "NodeJS API for writing modules in C++", "homepage": "https://nodejs.org/api/addons.html", "license": null, diff --git a/versions/baseline.json b/versions/baseline.json index 33bee5e17c..2dff5a0225 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5421,12 +5421,12 @@ "port-version": 3 }, "node-addon-api": { - "baseline": "5.0.0", + "baseline": "6.0.0", "port-version": 0 }, "node-api": { "baseline": "18.12.1", - "port-version": 1 + "port-version": 2 }, "nonius": { "baseline": "2019-04-20", diff --git a/versions/n-/node-addon-api.json b/versions/n-/node-addon-api.json index 96ae9e2836..bda5bcc637 100644 --- a/versions/n-/node-addon-api.json +++ b/versions/n-/node-addon-api.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "45cf82eea2cea9f8fa60b8a476f6484f75f81ca5", + "version": "6.0.0", + "port-version": 0 + }, { "git-tree": "b1c42d68e9b5e63b2d63cac93212af32d9e553dc", "version": "5.0.0", diff --git a/versions/n-/node-api.json b/versions/n-/node-api.json index 0df4207ac9..0dd5dae001 100644 --- a/versions/n-/node-api.json +++ b/versions/n-/node-api.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "d127d3b83f2702e56542e7c90807893464f3de79", + "version-semver": "18.12.1", + "port-version": 2 + }, { "git-tree": "1b12126f91686d77b2ea46cd9c7e311f000f7bb9", "version-semver": "18.12.1",