Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node-api] Add new port #26768

Merged
merged 112 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
811f0ae
port is building for x64-windows
Pospelove Sep 12, 2022
c28dd71
Add file endings
Pospelove Sep 12, 2022
76030c3
Reformat manifest file
Pospelove Sep 12, 2022
f947f41
Add versions
Pospelove Sep 12, 2022
f0e6be5
Remove comment
Pospelove Sep 13, 2022
447651b
Check host system instead of target
Pospelove Sep 13, 2022
5481746
fix user fs pollution & allow nodejs tool to have the same triplet as…
Pospelove Sep 13, 2022
c44572b
Merge branch 'node' of https://github.com/Pospelove/vcpkg into node
Pospelove Sep 13, 2022
93d9378
x86-windows now builds
Pospelove Sep 13, 2022
09af147
Support find_package (TARGET_SOURCES still todo)
Pospelove Sep 13, 2022
ad87fc8
add win_delay_hook.cc
Pospelove Sep 13, 2022
6375822
license for nodejs
Pospelove Sep 13, 2022
4490840
reformat
Pospelove Sep 13, 2022
6e99968
reformat
Pospelove Sep 13, 2022
a1aa22f
Update node-api.json
Pospelove Sep 13, 2022
d7a1102
nodejs port ver increment
Pospelove Sep 13, 2022
9a04e57
fix versions
Pospelove Sep 13, 2022
9c1bcf1
fix versions
Pospelove Sep 13, 2022
ea15357
Fix find_library/find_path review comments
Pospelove Sep 14, 2022
ff55505
node-api-config.cmake => unofficial-node-api-config.cmake
Pospelove Sep 14, 2022
4c62837
remove vcpkg_execute_npm_command.cmake
Pospelove Sep 14, 2022
9f8fc09
update git-tree in node-api.json
Pospelove Sep 14, 2022
21faba4
fix node triplet
Pospelove Sep 14, 2022
1f30741
remove obvious comment
Pospelove Sep 14, 2022
bcf4f63
Update node-api.json
Pospelove Sep 14, 2022
0bd2bc9
Revert everything related to vcpkg-tool-nodejs
Pospelove Sep 14, 2022
14fdc0e
fix port-version of vcpkg-tool-nodejs in baseline.json
Pospelove Sep 14, 2022
8406094
Update node-api.json
Pospelove Sep 14, 2022
438e2f1
ban arm
Pospelove Sep 14, 2022
d52bf52
fix EOF
Pospelove Sep 14, 2022
098ee3e
Update node-api.json
Pospelove Sep 14, 2022
68e52f6
Tweaks for Linux failure debugging
Pospelove Sep 14, 2022
4ebd3cc
Update node-api.json
Pospelove Sep 14, 2022
f4c4e35
Reformat with vscode cmake formatter
Pospelove Sep 14, 2022
fea7979
Even more debug logging
Pospelove Sep 14, 2022
ae47477
add <node_root>/bin to search
Pospelove Sep 14, 2022
d4ad5c2
Update node-api.json
Pospelove Sep 14, 2022
4621ee5
Add debugging for 2-nd error encountered
Pospelove Sep 14, 2022
35411d4
update ver
Pospelove Sep 14, 2022
7a5b2a9
update
Pospelove Sep 14, 2022
aa8ebdb
update ver
Pospelove Sep 14, 2022
e8cd2f7
add nodejs tool to path
Pospelove Sep 14, 2022
ab449e4
update ver
Pospelove Sep 14, 2022
3f82d3b
use prefix npm option
Pospelove Sep 14, 2022
d1bce81
add version
Pospelove Sep 14, 2022
ea96629
move things to node tool dir (temporary)
Pospelove Sep 16, 2022
5d6d56e
add ver
Pospelove Sep 16, 2022
07426e2
Add CMAKE_JS_LIB emptyness check
Pospelove Sep 16, 2022
9129531
add version
Pospelove Sep 16, 2022
7aab218
separate node root ad node bin directories
Pospelove Sep 16, 2022
57667a2
update node-api-config.cmake
Pospelove Sep 16, 2022
587c776
add ver
Pospelove Sep 16, 2022
80dda78
typo-fi
Pospelove Sep 16, 2022
09bc053
update version
Pospelove Sep 16, 2022
50d43a1
remove debug logging
Pospelove Sep 16, 2022
a5dd5db
update ver
Pospelove Sep 16, 2022
07bf79d
do not use system cmake
Pospelove Sep 16, 2022
6729371
add ver
Pospelove Sep 16, 2022
7efeacf
rename vars
Pospelove Sep 29, 2022
c6e036b
Update ver
Pospelove Sep 29, 2022
b1ad786
Add comment
Pospelove Oct 22, 2022
32b040f
add-version
Pospelove Oct 22, 2022
b06a12b
Now downloads cmake-js from github, but deps aren't downloaded (wip)
Pospelove Oct 29, 2022
925c585
add version
Pospelove Oct 29, 2022
f4bbb5a
Seems to work except lodash (wip)
Pospelove Oct 29, 2022
a939ff8
add version
Pospelove Oct 29, 2022
93087e7
license null (wip)
Pospelove Oct 29, 2022
fd17b5e
license null -reformat- (wip)
Pospelove Oct 29, 2022
27c520f
add ver
Pospelove Oct 29, 2022
1ad60ee
Add todo (wip)
Pospelove Oct 29, 2022
f4ab0e7
add ver
Pospelove Oct 29, 2022
9d13430
install lodash, new error now related to yargs isn't being built (wip)
Pospelove Nov 3, 2022
4b4e1cc
add version (wip)
Pospelove Nov 3, 2022
0b524d0
fix (wip)
Pospelove Nov 3, 2022
f3cef15
add version (wip)
Pospelove Nov 3, 2022
2890c74
Cleanup, will try one thing (wip)
Pospelove Nov 5, 2022
1199c9a
no cmake-js ver, now install includes (wip)
Pospelove Nov 5, 2022
91ad975
⌛ closing temporary, I'll get back to this later ⌛. at least I know w…
Pospelove Nov 9, 2022
28982bb
test
Pospelove Dec 14, 2022
bc23ae0
baseline
Pospelove Dec 14, 2022
1d7493a
format
Pospelove Dec 14, 2022
381f4ec
fill with zeros
Pospelove Dec 14, 2022
d03d964
update supports
Pospelove Dec 14, 2022
b46eb83
correct url for win
Pospelove Dec 14, 2022
02f9a28
addver
Pospelove Dec 14, 2022
2485495
better handle arch and os
Pospelove Dec 14, 2022
f59acfc
ver
Pospelove Dec 14, 2022
cdeffd7
update
Pospelove Dec 14, 2022
36ee833
update
Pospelove Dec 14, 2022
264de93
add-todo
Pospelove Dec 14, 2022
45b3463
add win support
Pospelove Dec 14, 2022
6404ed9
ver
Pospelove Dec 14, 2022
f9a9eb8
qol
Pospelove Dec 14, 2022
80f6c8a
ver
Pospelove Dec 14, 2022
612a6f7
add-sha
Pospelove Dec 14, 2022
e132556
ver
Pospelove Dec 14, 2022
b196eaf
update
Pospelove Dec 14, 2022
ae111af
update
Pospelove Dec 14, 2022
95d92a8
fix-license
Pospelove Dec 14, 2022
8c636e8
fix-license
Pospelove Dec 14, 2022
4254414
add sha
Pospelove Dec 15, 2022
6356182
add sha
Pospelove Dec 15, 2022
e20339b
linux-arm64
Pospelove Dec 15, 2022
5dddee8
linux-arm64
Pospelove Dec 15, 2022
2ec1526
sha512 for arm
Pospelove Dec 15, 2022
bb86325
sha512 for arm
Pospelove Dec 15, 2022
8c1342d
remove imported sources
Pospelove Dec 15, 2022
c237547
remove imported sources
Pospelove Dec 15, 2022
9a1f774
apply suggestion
Pospelove Dec 15, 2022
285ce82
add ver
Pospelove Dec 15, 2022
744cce5
fix eof
Pospelove Dec 15, 2022
3bd1ce7
add ver
Pospelove Dec 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ports/node-api/cmake-js-fetch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.10)
project(cmake-js-fetch)

set(f ${CMAKE_CURRENT_BINARY_DIR}/node.cmake)

foreach(p ${CMAKE_JS_INC})
Pospelove marked this conversation as resolved.
Show resolved Hide resolved
string(REPLACE "\\" "\\\\" p ${p})
file(APPEND ${f} "set(CMAKE_JS_INC \"${p}\")\n")
endforeach()

foreach(p ${CMAKE_JS_SRC})
string(REPLACE "\\" "\\\\" p ${p})
file(APPEND ${f} "set(CMAKE_JS_SRC \"${p}\")\n")
endforeach()

foreach(p ${CMAKE_JS_LIB})
string(REPLACE "\\" "\\\\" p ${p})
file(APPEND ${f} "set(CMAKE_JS_LIB \"${p}\")\n")
endforeach()
5 changes: 5 additions & 0 deletions ports/node-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"cmake-js-fetch": "cmake-js configure --directory cmake-js-fetch"
}
}
56 changes: 56 additions & 0 deletions ports/node-api/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Based on qtwebengine
find_program(NODEJS NAMES node PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/node" "bin" NO_DEFAULT_PATHS)
find_program(NODEJS NAMES node)
if(NOT NODEJS)
message(FATAL_ERROR "node not found! Please install it via your system package manager!")
endif()

get_filename_component(NODEJS_DIR "${NODEJS}" DIRECTORY)

# check if vcpkg host is windows
if(VCPKG_HOST_IS_WINDOWS)
set(npm_command "${NODEJS_DIR}/npm.cmd")
else()
set(npm_command "${NODEJS_DIR}/npm")
endif()

file(REMOVE_RECURSE "${DOWNLOADS}/tmp-cmakejs-output")
file(REMOVE_RECURSE "${DOWNLOADS}/tmp-cmakejs-home")
file(MAKE_DIRECTORY "${DOWNLOADS}/tmp-cmakejs-output")
file(MAKE_DIRECTORY "${DOWNLOADS}/tmp-cmakejs-home")

vcpkg_execute_npm_command(
NPM_COMMAND ${npm_command}
COMMAND install [email protected]
WORKING_DIRECTORY "${NODEJS_DIR}"
)

# Precent pollution of user home directory
file(READ "${NODEJS_DIR}/node_modules/cmake-js/lib/environment.js" environment_js)
string(REPLACE "process.env[(os.platform() === \"win32\") ? \"USERPROFILE\" : \"HOME\"]" "\"${DOWNLOADS}/tmp-cmakejs-home\"" environment_js "${environment_js}")
file(WRITE "${NODEJS_DIR}/node_modules/cmake-js/lib/environment.js" "${environment_js}")

vcpkg_execute_npm_command(
NPM_COMMAND ${npm_command}
COMMAND run cmake-js-fetch --scripts-prepend-node-path -- --out "${DOWNLOADS}/tmp-cmakejs-output"
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
)

include("${DOWNLOADS}/tmp-cmakejs-output/node.cmake")

file(COPY "${CMAKE_JS_INC}" DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(COPY "${CMAKE_JS_LIB}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${CMAKE_JS_LIB}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")

# Non-empty only for Windows at the current version of NodeJS
if(CMAKE_JS_SRC)
file(COPY "${CMAKE_JS_SRC}" DESTINATION "${CURRENT_PACKAGES_DIR}/include/node")
endif()

# Handle copyright
file(INSTALL "${NODEJS_DIR}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

# vcpkg remove doesn't remove cmake-js, so we need to remove it manually right now
file(GLOB cmakejs_files "${NODEJS_DIR}/cmake-js*")
file(REMOVE ${cmakejs_files})
file(REMOVE_RECURSE "${NODEJS_DIR}/node_modules/cmake-js")
19 changes: 19 additions & 0 deletions ports/node-api/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "node-api",
"version-semver": "14.17.4",
"description": "NodeJS API for writing modules in C++",
"homepage": "https://nodejs.org/api/addons.html",
"license": "MIT",
"supports": "windows | linux | osx",
"dependencies": [
"vcpkg-tool-nodejs",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
8 changes: 7 additions & 1 deletion ports/vcpkg-tool-nodejs/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ set(PROG_VERSION 14.17.4)
set(BREW_PACKAGE_NAME "${PROGNAME}")
set(APT_PACKAGE_NAME "${PROGNAME}")

if(VCPKG_CROSSCOMPILING)
set(RELAX_CROSSCOMPILING_CHECK OFF)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_HOST_IS_WINDOWS)
# it's ok to "cross-compile" from windows to windows in case of this port
set(RELAX_CROSSCOMPILING_CHECK ON)
endif()

if(VCPKG_CROSSCOMPILING AND NOT RELAX_CROSSCOMPILING_CHECK)
message(FATAL_ERROR "This is a host only port!")
endif()

Expand Down
2 changes: 1 addition & 1 deletion ports/vcpkg-tool-nodejs/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vcpkg-tool-nodejs",
"version-semver": "14.17.4",
"supports": "native"
"supports": "windows | linux | osx"
}
28 changes: 28 additions & 0 deletions scripts/cmake/vcpkg_execute_npm_command.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function(vcpkg_execute_npm_command)
cmake_parse_arguments(A "" "WORKING_DIRECTORY;OUTPUT_VARIABLE;RESULT_VARIABLE;NPM_COMMAND" "COMMAND" ${ARGN})
foreach(arg WORKING_DIRECTORY COMMAND NPM_COMMAND)
if("${A_${arg}}" STREQUAL "")
message(FATAL_ERROR "Missing ${arg} argument")
endif()
endforeach()

if(NOT IS_ABSOLUTE "${A_WORKING_DIRECTORY}")
message(FATAL_ERROR "Expected WORKING_DIRECTORY to be an absolute path, but got: ${A_WORKING_DIRECTORY}")
endif()

execute_process(COMMAND "${A_NPM_COMMAND}" ${A_COMMAND}
WORKING_DIRECTORY ${A_WORKING_DIRECTORY}
RESULT_VARIABLE npm_result
OUTPUT_VARIABLE npm_output
)

if("${A_RESULT_VARIABLE}" STREQUAL "")
if(NOT "${npm_result}" STREQUAL "0")
message(FATAL_ERROR "${A_NPM_COMMAND} ${A_COMMAND} exited with ${npm_result}:\n${npm_output}")
endif()
else()
set("${A_RESULT_VARIABLE}" "${npm_result}" PARENT_SCOPE)
endif()

set("${A_OUTPUT_VARIABLE}" "${npm_output}" PARENT_SCOPE)
endfunction()
Pospelove marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions scripts/ports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ include("${SCRIPTS}/cmake/vcpkg_list.cmake")
include("${SCRIPTS}/cmake/vcpkg_minimum_required.cmake")
include("${SCRIPTS}/cmake/vcpkg_replace_string.cmake")
include("${SCRIPTS}/cmake/vcpkg_test_cmake.cmake")
include("${SCRIPTS}/cmake/vcpkg_execute_npm_command.cmake")
Pospelove marked this conversation as resolved.
Show resolved Hide resolved

include("${SCRIPTS}/cmake/z_vcpkg_apply_patches.cmake")
include("${SCRIPTS}/cmake/z_vcpkg_forward_output_variable.cmake")
Expand Down
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4976,6 +4976,10 @@
"baseline": "2021-02-21",
"port-version": 3
},
"node-api": {
"baseline": "14.17.4",
"port-version": 0
},
"nonius": {
"baseline": "2019-04-20",
"port-version": 2
Expand Down
9 changes: 9 additions & 0 deletions versions/n-/node-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "c7f7248a9cbc46b1328a30a3b06a3ed19ea4ad04",
"version-semver": "14.17.4",
"port-version": 0
}
]
}