diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 34c50016eda..a2409db828b 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -68,13 +68,13 @@ jobs: # - name: Run node tests # shell: bash # run: | - # ./lib/binding/osrm-extract.exe -p profiles/car.lua test/data/monaco.osm.pbf + # ./lib/binding_napi_v8/osrm-extract.exe -p profiles/car.lua test/data/monaco.osm.pbf # mkdir -p test/data/ch # cp test/data/monaco.osrm* test/data/ch/ - # ./lib/binding/osrm-contract.exe test/data/ch/monaco.osrm + # ./lib/binding_napi_v8/osrm-contract.exe test/data/ch/monaco.osrm - # ./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm + # ./lib/binding_napi_v8/osrm-datastore.exe test/data/ch/monaco.osrm # node test/nodejs/index.js - name: Build Node package shell: bash diff --git a/.gitignore b/.gitignore index c8d84b8c554..9510b88f6ce 100644 --- a/.gitignore +++ b/.gitignore @@ -103,5 +103,5 @@ node_modules debug.lua # node-osrm artifacts -lib/binding +lib/binding_napi_v8 diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a710101da..07c6e97745d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased - Changes from 6.0.0 - Build: + - FIXED: Update Node.js binding path from `lib/binding` to `lib/binding_napi_v8` to match node-pre-gyp versioning conventions [#7272](https://github.com/Project-OSRM/osrm-backend/pull/7272) - FIXED: Reduce MSVC compiler warnings by suppressing informational warnings while preserving bug-indicating warnings [#7253](https://github.com/Project-OSRM/osrm-backend/issues/7253) - Misc: - CHANGED: Add std::format compatibility layer with fallback to fmt::format [#7261](https://github.com/Project-OSRM/osrm-backend/pull/7261) diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index d8c67eff7f5..0da19d063c2 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -4,11 +4,11 @@ The `OSRM` method is the main constructor for creating an OSRM instance. An OSRM instance requires a `.osrm.*` dataset(`.osrm.*` because it contains several files), which is prepared by the OSRM toolchain. -You can create such a `.osrm.*` dataset by running the OSRM binaries we ship in `node_modules/osrm/lib/binding/` and default +You can create such a `.osrm.*` dataset by running the OSRM binaries we ship in `node_modules/osrm/lib/binding_napi_v8/` and default profiles (e.g. for setting speeds and determining road types to route on) in `node_modules/osrm/profiles/`: - node_modules/osrm/lib/binding/osrm-extract data.osm.pbf -p node_modules/osrm/profiles/car.lua - node_modules/osrm/lib/binding/osrm-contract data.osrm + node_modules/osrm/lib/binding_napi_v8/osrm-extract data.osm.pbf -p node_modules/osrm/profiles/car.lua + node_modules/osrm/lib/binding_napi_v8/osrm-contract data.osrm Consult the [osrm-backend](https://github.com/Project-OSRM/osrm-backend) documentation for further details. diff --git a/lib/binding/.gitkeep b/lib/binding/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/binding_napi_v8 b/lib/binding_napi_v8 deleted file mode 120000 index 32bc84fb763..00000000000 --- a/lib/binding_napi_v8 +++ /dev/null @@ -1 +0,0 @@ -binding \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 62f106fd890..f4d0e8e5635 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,7 +10,7 @@ const __dirname = path.dirname(__filename); const require = createRequire(import.meta.url); // Load native OSRM binding and add version info from package.json -const OSRM = require('./binding/node_osrm.node').OSRM; +const OSRM = require('./binding_napi_v8/node_osrm.node').OSRM; const packageJson = JSON.parse(readFileSync(path.join(__dirname, '../package.json'), 'utf8')); OSRM.version = packageJson.version; diff --git a/package.json b/package.json index 51893bc223e..8ae55a2b7bd 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "clean": "rm -rf test/cache", "docs": "./scripts/build_api_docs.sh", "install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh", - "nodejs-tests": "make -C test/data && ./lib/binding/osrm-datastore test/data/ch/monaco.osrm && node test/nodejs/index.js | faucet", + "nodejs-tests": "make -C test/data && ./lib/binding_napi_v8/osrm-datastore test/data/ch/monaco.osrm && node test/nodejs/index.js | faucet", "prepare": "husky" }, "repository": { diff --git a/scripts/ci/node_package.sh b/scripts/ci/node_package.sh index 19f6bbf4a30..7b998816b46 100755 --- a/scripts/ci/node_package.sh +++ b/scripts/ci/node_package.sh @@ -18,7 +18,7 @@ echo "dumping binary meta..." # enforce that binary has proper ORIGIN flags so that # it can portably find libtbb.so in the same directory if [[ $(uname -s) == 'Linux' ]]; then - readelf -d ./lib/binding/node_osrm.node > readelf-output.txt + readelf -d ./lib/binding_napi_v8/node_osrm.node > readelf-output.txt if grep -q 'Flags: ORIGIN' readelf-output.txt; then echo "Found ORIGIN flag in readelf output" cat readelf-output.txt diff --git a/scripts/ci/run_benchmarks.sh b/scripts/ci/run_benchmarks.sh index b763b83d61e..00e28b649af 100755 --- a/scripts/ci/run_benchmarks.sh +++ b/scripts/ci/run_benchmarks.sh @@ -87,7 +87,7 @@ function run_benchmarks_for_folder { for BENCH in nearest table trip route match; do echo "Running node $BENCH $ALGORITHM" START=$(date +%s.%N) - node $SCRIPTS_FOLDER/scripts/ci/bench.js $FOLDER/lib/binding/node_osrm.node $FOLDER/data.osrm $ALGORITHM $BENCH $GPS_TRACES > "$RESULTS_FOLDER/node_${BENCH}_${ALGORITHM}.bench" 5 + node $SCRIPTS_FOLDER/scripts/ci/bench.js $FOLDER/lib/binding_napi_v8/node_osrm.node $FOLDER/data.osrm $ALGORITHM $BENCH $GPS_TRACES > "$RESULTS_FOLDER/node_${BENCH}_${ALGORITHM}.bench" 5 END=$(date +%s.%N) DIFF=$(echo "$END - $START" | bc) echo "Took: ${DIFF}s" diff --git a/src/nodejs/CMakeLists.txt b/src/nodejs/CMakeLists.txt index f153a0a8603..76f0a1b2aed 100644 --- a/src/nodejs/CMakeLists.txt +++ b/src/nodejs/CMakeLists.txt @@ -5,7 +5,7 @@ message(STATUS "Building node_osrm") set(NAPI_VERSION 8) add_definitions(-DNAPI_VERSION=${NAPI_VERSION}) -set(BINDING_DIR "${PROJECT_SOURCE_DIR}/lib/binding") +set(BINDING_DIR "${PROJECT_SOURCE_DIR}/lib/binding_napi_v8") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/node_modules/node-cmake") @@ -36,6 +36,9 @@ target_link_libraries(node_osrm osrm) # node_osrm artifacts in ${BINDING_DIR} to depend targets on set(ARTIFACTS "") +# Create the binding directory if it doesn't exist +file(MAKE_DIRECTORY ${BINDING_DIR}) + set(OSRM_BINARIES osrm-extract osrm-contract osrm-routed osrm-datastore osrm-components osrm-partition osrm-customize) foreach(binary ${OSRM_BINARIES}) add_custom_command(OUTPUT ${BINDING_DIR}/${binary} diff --git a/src/nodejs/node_osrm.cpp b/src/nodejs/node_osrm.cpp index f8cd7e4756f..cb5ef2a6f19 100644 --- a/src/nodejs/node_osrm.cpp +++ b/src/nodejs/node_osrm.cpp @@ -44,11 +44,11 @@ Napi::Object Engine::Init(Napi::Env env, Napi::Object exports) /** * The `OSRM` method is the main constructor for creating an OSRM instance. * An OSRM instance requires a `.osrm.*` dataset(`.osrm.*` because it contains several files), which is prepared by the OSRM toolchain. - * You can create such a `.osrm.*` dataset by running the OSRM binaries we ship in `node_modules/osrm/lib/binding/` and default + * You can create such a `.osrm.*` dataset by running the OSRM binaries we ship in `node_modules/osrm/lib/binding_napi_v8/` and default * profiles (e.g. for setting speeds and determining road types to route on) in `node_modules/osrm/profiles/`: * - * node_modules/osrm/lib/binding/osrm-extract data.osm.pbf -p node_modules/osrm/profiles/car.lua - * node_modules/osrm/lib/binding/osrm-contract data.osrm + * node_modules/osrm/lib/binding_napi_v8/osrm-extract data.osm.pbf -p node_modules/osrm/profiles/car.lua + * node_modules/osrm/lib/binding_napi_v8/osrm-contract data.osrm * * Consult the [osrm-backend](https://github.com/Project-OSRM/osrm-backend) documentation for further details. *