Skip to content

Commit

Permalink
switch build to use cmake-js
Browse files Browse the repository at this point in the history
  • Loading branch information
LandryNorris committed Aug 18, 2023
1 parent 1ca1790 commit 16d4679
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 8 deletions.
98 changes: 96 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/librhsp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)
set (CMAKE_CXX_STANDARD 17)

project(rhsp)
add_subdirectory(librhsp)

project(noderhsp)

if(SYSTEM STREQUAL "Windows")
link_libraries(${CMAKE_SOURCE_DIR}/build-def/node.lib)
Expand Down Expand Up @@ -49,6 +51,7 @@ include_directories(${NODE_ADDON_API_DIR} ${CMAKE_JS_INC} ${CMAKE_CURRENT_SOURCE

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${SOURCES} ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries(${PROJECT_NAME} rhsp)

if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
Expand Down
4 changes: 4 additions & 0 deletions packages/librhsp/binding-options.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
name: 'noderhsp',
napi_versions: [8],
}
11 changes: 9 additions & 2 deletions packages/librhsp/lib/binding.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as path from "path";
import { createRequire } from "module";
import { fileURLToPath } from "url";
import { dirname } from "path";
Expand All @@ -23,11 +22,19 @@ import {
Version,
} from "@rev-robotics/rev-hub-core";
import { SerialParity } from "@rev-robotics/rev-hub-core";
import * as path from "path";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const require = createRequire(import.meta.url);
const addon = require("node-gyp-build")(path.join(__dirname, ".."));
console.log(__dirname);
const addon = require("pkg-prebuilds")(
path.join(__dirname, ".."),
{
name: 'noderhsp',
napi_versions: [8],
}
);

export * from "./error-codes.js";
export * from "./serial-errors.js";
Expand Down
6 changes: 3 additions & 3 deletions packages/librhsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@rev-robotics/rev-hub-core": "^1.0.0",
"cmake-js": "^7.2.1",
"node-addon-api": "^6.0.0",
"node-gyp-build": "^4.6.0"
"node-gyp-build": "^4.6.0",
"pkg-prebuilds": "^0.2.0"
},
"devDependencies": {
"@types/node": "^16.18.18",
Expand All @@ -25,13 +26,12 @@
},
"scripts": {
"build": "tsc",
"install": "node-gyp-build \"node scripts/build-RHSPlib.mjs\"",
"install": "pkg-prebuilds-verify binding-options.cjs || cmake-js compile",
"makePrebuildsOnLinux": "node scripts/linux-cross-build.mjs",
"makePrebuildsOnDarwin": "node scripts/macos-cross-build.mjs",
"prepublishOnly": "prebuildify --napi && tsc",
"cross-build": "node-gyp-build \"node scripts/cross-build-RHSPlib.mjs\""
},
"gypfile": true,
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
Expand Down

0 comments on commit 16d4679

Please sign in to comment.