Skip to content

Commit

Permalink
internal: make a prebuilt nodejs port (#2230)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored Nov 25, 2024
1 parent f21af05 commit 256847a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ endif()

# Bool options (Part 1)
option(SKYRIM_SE "Legacy Skyrim SE (1.5) build" OFF)
option(BUILD_NODEJS_PLUGIN "Build a NodeJS plugin for Skyrim if ON, use a pre-built from ./client-deps otherwise" OFF)
option(BUILD_NODEJS "Build NodeJS port if ON, use a pre-built otherwise" OFF)

if(SKYRIM_SE)
list(APPEND VCPKG_MANIFEST_FEATURES "skyrim-se")
else()
list(APPEND VCPKG_MANIFEST_FEATURES "skyrim-ae")
endif()

if(BUILD_NODEJS_PLUGIN)
if(BUILD_NODEJS)
list(APPEND VCPKG_MANIFEST_FEATURES "build-nodejs")
else()
list(APPEND VCPKG_MANIFEST_FEATURES "prebuilt-nodejs")
endif()

cmake_minimum_required(VERSION 3.19)
Expand Down Expand Up @@ -95,7 +97,7 @@ message(STATUS BUILD_UNIT_TESTS=${BUILD_UNIT_TESTS})
message(STATUS INSTALL_CLIENT_DIST=${INSTALL_CLIENT_DIST})
message(STATUS BUILD_GAMEMODE=${BUILD_GAMEMODE})
message(STATUS OFFLINE_MODE=${OFFLINE_MODE})
message(STATUS BUILD_NODEJS_PLUGIN=${BUILD_NODEJS_PLUGIN})
message(STATUS BUILD_NODEJS=${BUILD_NODEJS})

if(PREPARE_NEXUS_ARCHIVES AND EMSCRIPTEN)
message(FATAL_ERROR "PREPARE_NEXUS_ARCHIVES is not supported on Emscripten")
Expand Down
31 changes: 31 additions & 0 deletions overlay_ports/node-embedder-api-prebuilt/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set(NODE_EMBEDDER_API_URL "https://node-embedder-api-prebuilt-vcpkg-port.b-cdn.net/node-embedder-api-prebuilt.zip")
set(NODE_EMBEDDER_API_FILENAME "node-embedder-api-prebuilt.zip")
set(NODE_EMBEDDER_API_SHA512 0082a1537052d2343a867cac2eb9acb9ba2da1607c3766ef5ada6fd2498e0fc3df754cabf3a47825358e441a7f594addcf8fdf3be84b05f27fa6eb8aefa1e2ed)

vcpkg_download_distfile(ARCHIVE
URLS ${NODE_EMBEDDER_API_URL}
FILENAME ${NODE_EMBEDDER_API_FILENAME}
SHA512 ${NODE_EMBEDDER_API_SHA512}
)

vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
NO_REMOVE_ONE_LEVEL
)

file(GLOB_RECURSE files ${SOURCE_PATH}/*)

foreach(file ${files})
file(RELATIVE_PATH relative_path ${SOURCE_PATH} ${file})

set(destination_path ${CURRENT_PACKAGES_DIR}/${relative_path})

get_filename_component(destination_dir ${destination_path} DIRECTORY)
file(MAKE_DIRECTORY ${destination_dir})

message(STATUS "Copying ${file} to ${destination_path}")
file(COPY ${file} DESTINATION ${destination_dir})
endforeach()

file(DOWNLOAD https://raw.githubusercontent.com/frida/frida-gum/698b356fef0ecfc3ac2818f0b387be90e93deeda/COPYING ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright)
20 changes: 20 additions & 0 deletions overlay_ports/node-embedder-api-prebuilt/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "node-embedder-api-prebuilt",
"version": "1",
"description": "NodeJS API for embedding NodeJS in your C++ applications",
"homepage": "https://nodejs.org/api/embedding.html",
"license": "MIT",
"supports": "(windows & x64 & !uwp) | linux | osx",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true,
"platform": "windows"
},
{
"name": "vcpkg-cmake-config",
"host": true,
"platform": "windows"
}
]
}
9 changes: 9 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@
"platform": "windows"
}
]
},
"prebuilt-nodejs": {
"description": "",
"dependencies": [
{
"name": "node-embedder-api-prebuilt",
"platform": "windows"
}
]
}
}
}

0 comments on commit 256847a

Please sign in to comment.