Skip to content

Commit 9b83481

Browse files
Build Node bindings on Windows (#6334)
Extends CI to build NodeJS bindings for Windows.
1 parent 1c65ea2 commit 9b83481

File tree

13 files changed

+1801
-1206
lines changed

13 files changed

+1801
-1206
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313

1414
# Declare files that will always have LF line endings on checkout.
1515
*.sh text eol=lf
16+
17+
# https://eslint.org/docs/latest/rules/linebreak-style#using-this-rule-with-version-control-systems
18+
*.js text eol=lf

.github/workflows/osrm-backend.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
needs: format-taginfo-docs
2525
runs-on: windows-2022
2626
continue-on-error: false
27+
env:
28+
BUILD_TYPE: Release
29+
ENABLE_APPLE_SILICON: "OFF"
2730
steps:
2831
- uses: actions/checkout@v3
2932
- run: pip install conan==1.51.3
@@ -34,12 +37,38 @@ jobs:
3437
node-version: 16
3538
- run: node --version
3639
- run: npm --version
40+
- name: Prepare environment
41+
shell: bash
42+
run: |
43+
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
44+
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
3745
- run: npm install --ignore-scripts
3846
- run: npm link --ignore-scripts
3947
- uses: microsoft/[email protected]
4048
- name: Build
4149
run: |
4250
.\scripts\ci\windows-build.bat
51+
- name: Run node tests
52+
shell: bash
53+
run: |
54+
./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm
55+
node test/nodejs/index.js
56+
- name: Build Node package
57+
shell: bash
58+
run: ./scripts/ci/node_package.sh
59+
- name: Publish Node package
60+
if: ${{ env.PUBLISH == 'On' }}
61+
uses: ncipollo/release-action@v1
62+
with:
63+
allowUpdates: true
64+
artifactErrorsFailBuild: true
65+
artifacts: build/stage/**/*.tar.gz
66+
omitBody: true
67+
omitBodyDuringUpdate: true
68+
omitName: true
69+
omitNameDuringUpdate: true
70+
replacesArtifacts: true
71+
token: ${{ secrets.GITHUB_TOKEN }}
4372

4473
format-taginfo-docs:
4574
runs-on: ubuntu-20.04
@@ -526,15 +555,13 @@ jobs:
526555
key: v3-test-${{ matrix.name }}-${{ github.sha }}
527556
restore-keys: |
528557
v3-test-${{ matrix.name }}-
529-
558+
530559
- name: Prepare environment
531560
run: |
532561
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
533562
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
534-
535563
echo "OSRM_INSTALL_DIR=${GITHUB_WORKSPACE}/install-osrm" >> $GITHUB_ENV
536564
echo "OSRM_BUILD_DIR=${GITHUB_WORKSPACE}/build-osrm" >> $GITHUB_ENV
537-
538565
if [[ "$ENABLE_SANITIZER" == 'ON' ]]; then
539566
# We can only set this after checkout once we know the workspace directory
540567
echo "LSAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/leaksanitizer.conf" >> $GITHUB_ENV
@@ -549,12 +576,10 @@ jobs:
549576
sudo mdutil -i off /
550577
export MASON_OS=osx
551578
fi
552-
553579
echo "MASON=${GITHUB_WORKSPACE}/scripts/mason.sh" >> $GITHUB_ENV
580+
554581
echo "CMAKE_URL=https://mason-binaries.s3.amazonaws.com/${MASON_OS}-x86_64/cmake/${CMAKE_VERSION}.tar.gz" >> $GITHUB_ENV
555582
echo "CMAKE_DIR=mason_packages/${MASON_OS}-x86_64/cmake/${CMAKE_VERSION}" >> $GITHUB_ENV
556-
557-
558583
- name: Install dev dependencies
559584
run: |
560585
python3 -m pip install conan==1.51.3
@@ -634,6 +659,7 @@ jobs:
634659
else
635660
APPLE_SILICON_FLAGS=()
636661
fi
662+
637663
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
638664
-DENABLE_CONAN=${ENABLE_CONAN:-OFF} \
639665
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- FIXED: Bug in bicycle profile that caused exceptions if there is a highway=bicycle in the data. [#6296](https://github.com/Project-OSRM/osrm-backend/pull/6296)
2323
- FIXED: Internal refactoring of identifier types used in data facade [#6044](https://github.com/Project-OSRM/osrm-backend/pull/6044)
2424
- Build:
25+
- ADDED: Build Node bindings on Windows. [#6334](https://github.com/Project-OSRM/osrm-backend/pull/6334)
2526
- ADDED: Configure cross-compilation for Apple Silicon. [#6360](https://github.com/Project-OSRM/osrm-backend/pull/6360)
2627
- CHANGED: Use apt-get to install Clang on CI. [#6345](https://github.com/Project-OSRM/osrm-backend/pull/6345)
2728
- CHANGED: Fix TBB in case of Conan + NodeJS build. [#6333](https://github.com/Project-OSRM/osrm-backend/pull/6333)

CMakeLists.txt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.2)
33
set(CMAKE_CXX_STANDARD 17)
44
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
55

6+
67
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
78
message(FATAL_ERROR "In-source builds are not allowed.
89
Please create a directory and run cmake from there, passing the path to this source directory as the last argument.
@@ -883,22 +884,23 @@ if (ENABLE_FUZZING)
883884
add_subdirectory(fuzz)
884885
endif ()
885886

887+
# add headers sanity check target that includes all headers independently
888+
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
889+
file(GLOB_RECURSE headers_to_check
890+
${PROJECT_BINARY_DIR}/*.hpp
891+
${PROJECT_SOURCE_DIR}/include/*.hpp)
892+
foreach(header ${headers_to_check})
893+
if ("${header}" MATCHES ".*/include/nodejs/.*")
894+
# we do not check NodeJS bindings headers
895+
continue()
896+
endif()
897+
get_filename_component(filename ${header} NAME_WE)
898+
set(filename "${check_headers_dir}/${filename}.cpp")
899+
if (NOT EXISTS ${filename})
900+
file(WRITE ${filename} "#include \"${header}\"\n")
901+
endif()
902+
list(APPEND sources ${filename})
903+
endforeach()
904+
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
905+
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
886906

887-
# add headers sanity check target that includes all headers independently
888-
# make sure we have all deps for the nodejs sub project's includes (nan, node)
889-
if (ENABLE_NODE_BINDINGS)
890-
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
891-
file(GLOB_RECURSE headers_to_check
892-
${PROJECT_BINARY_DIR}/*.hpp
893-
${PROJECT_SOURCE_DIR}/include/*.hpp)
894-
foreach(header ${headers_to_check})
895-
get_filename_component(filename ${header} NAME_WE)
896-
set(filename "${check_headers_dir}/${filename}.cpp")
897-
if (NOT EXISTS ${filename})
898-
file(WRITE ${filename} "#include \"${header}\"\n")
899-
endif()
900-
list(APPEND sources ${filename})
901-
endforeach()
902-
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
903-
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
904-
endif()

include/engine/api/route_api.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "util/json_util.hpp"
2929

3030
#include <iterator>
31+
#include <map>
3132
#include <vector>
3233

3334
namespace osrm

include/engine/guidance/assemble_leg.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "engine/guidance/route_leg.hpp"
77
#include "engine/guidance/route_step.hpp"
88
#include "engine/internal_route_result.hpp"
9+
#include "util/coordinate_calculation.hpp"
910
#include "util/typedefs.hpp"
1011

1112
#include <boost/algorithm/string/join.hpp>

include/extractor/geojson_debug_policies.hpp

Lines changed: 0 additions & 107 deletions
This file was deleted.

include/extractor/road_classification.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
22
#define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
33

4+
#include "extractor/intersection/constants.hpp"
45
#include <algorithm>
6+
#include <boost/assert.hpp>
57
#include <cmath>
68
#include <cstdint>
79
#include <cstdlib>
810
#include <string>
911

10-
#include "extractor/intersection/constants.hpp"
11-
1212
namespace osrm
1313
{
1414
namespace extractor

include/util/ieee754.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ THE SOFTWARE.
2727

2828
#include <assert.h>
2929
#include <math.h>
30+
#include <memory.h>
3031

3132
#if defined(_MSC_VER)
3233
#include "rapidjson/msinttypes/stdint.h"

0 commit comments

Comments
 (0)