Build Node bindings on Windows (#6334)

Extends CI to build NodeJS bindings for Windows.
This commit is contained in:
Siarhei Fedartsou 2022-09-20 21:43:13 +02:00 committed by GitHub
parent 1c65ea2194
commit 9b834810d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1775 additions and 1180 deletions

3
.gitattributes vendored
View File

@ -13,3 +13,6 @@
# Declare files that will always have LF line endings on checkout.
*.sh text eol=lf
# https://eslint.org/docs/latest/rules/linebreak-style#using-this-rule-with-version-control-systems
*.js text eol=lf

View File

@ -24,6 +24,9 @@ jobs:
needs: format-taginfo-docs
runs-on: windows-2022
continue-on-error: false
env:
BUILD_TYPE: Release
ENABLE_APPLE_SILICON: "OFF"
steps:
- uses: actions/checkout@v3
- run: pip install conan==1.51.3
@ -34,12 +37,38 @@ jobs:
node-version: 16
- run: node --version
- run: npm --version
- name: Prepare environment
shell: bash
run: |
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
- run: npm install --ignore-scripts
- run: npm link --ignore-scripts
- uses: microsoft/setup-msbuild@v1.1
- name: Build
run: |
.\scripts\ci\windows-build.bat
- name: Run node tests
shell: bash
run: |
./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm
node test/nodejs/index.js
- name: Build Node package
shell: bash
run: ./scripts/ci/node_package.sh
- name: Publish Node package
if: ${{ env.PUBLISH == 'On' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: build/stage/**/*.tar.gz
omitBody: true
omitBodyDuringUpdate: true
omitName: true
omitNameDuringUpdate: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
format-taginfo-docs:
runs-on: ubuntu-20.04
@ -531,10 +560,8 @@ jobs:
run: |
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
echo "OSRM_INSTALL_DIR=${GITHUB_WORKSPACE}/install-osrm" >> $GITHUB_ENV
echo "OSRM_BUILD_DIR=${GITHUB_WORKSPACE}/build-osrm" >> $GITHUB_ENV
if [[ "$ENABLE_SANITIZER" == 'ON' ]]; then
# We can only set this after checkout once we know the workspace directory
echo "LSAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/leaksanitizer.conf" >> $GITHUB_ENV
@ -549,12 +576,10 @@ jobs:
sudo mdutil -i off /
export MASON_OS=osx
fi
echo "MASON=${GITHUB_WORKSPACE}/scripts/mason.sh" >> $GITHUB_ENV
echo "CMAKE_URL=https://mason-binaries.s3.amazonaws.com/${MASON_OS}-x86_64/cmake/${CMAKE_VERSION}.tar.gz" >> $GITHUB_ENV
echo "CMAKE_DIR=mason_packages/${MASON_OS}-x86_64/cmake/${CMAKE_VERSION}" >> $GITHUB_ENV
- name: Install dev dependencies
run: |
python3 -m pip install conan==1.51.3
@ -634,6 +659,7 @@ jobs:
else
APPLE_SILICON_FLAGS=()
fi
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DENABLE_CONAN=${ENABLE_CONAN:-OFF} \
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \

View File

@ -22,6 +22,7 @@
- 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)
- FIXED: Internal refactoring of identifier types used in data facade [#6044](https://github.com/Project-OSRM/osrm-backend/pull/6044)
- Build:
- ADDED: Build Node bindings on Windows. [#6334](https://github.com/Project-OSRM/osrm-backend/pull/6334)
- ADDED: Configure cross-compilation for Apple Silicon. [#6360](https://github.com/Project-OSRM/osrm-backend/pull/6360)
- CHANGED: Use apt-get to install Clang on CI. [#6345](https://github.com/Project-OSRM/osrm-backend/pull/6345)
- CHANGED: Fix TBB in case of Conan + NodeJS build. [#6333](https://github.com/Project-OSRM/osrm-backend/pull/6333)

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.2)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed.
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)
add_subdirectory(fuzz)
endif ()
# add headers sanity check target that includes all headers independently
# make sure we have all deps for the nodejs sub project's includes (nan, node)
if (ENABLE_NODE_BINDINGS)
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
file(GLOB_RECURSE headers_to_check
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
file(GLOB_RECURSE headers_to_check
${PROJECT_BINARY_DIR}/*.hpp
${PROJECT_SOURCE_DIR}/include/*.hpp)
foreach(header ${headers_to_check})
foreach(header ${headers_to_check})
if ("${header}" MATCHES ".*/include/nodejs/.*")
# we do not check NodeJS bindings headers
continue()
endif()
get_filename_component(filename ${header} NAME_WE)
set(filename "${check_headers_dir}/${filename}.cpp")
if (NOT EXISTS ${filename})
file(WRITE ${filename} "#include \"${header}\"\n")
endif()
list(APPEND sources ${filename})
endforeach()
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
endif()
endforeach()
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})

View File

@ -28,6 +28,7 @@
#include "util/json_util.hpp"
#include <iterator>
#include <map>
#include <vector>
namespace osrm

View File

@ -6,6 +6,7 @@
#include "engine/guidance/route_leg.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/internal_route_result.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/typedefs.hpp"
#include <boost/algorithm/string/join.hpp>

View File

@ -1,107 +0,0 @@
#ifndef OSRM_EXTRACTOR_GEOJSON_DEBUG_POLICIES
#define OSRM_EXTRACTOR_GEOJSON_DEBUG_POLICIES
#include <algorithm>
#include <vector>
#include "extractor/query_node.hpp"
#include "util/coordinate.hpp"
#include "util/json_container.hpp"
#include "util/node_based_graph.hpp"
#include "util/typedefs.hpp"
#include "guidance/coordinate_extractor.hpp"
#include "guidance/intersection.hpp"
#include "util/coordinate.hpp"
#include "util/geojson_debug_policy_toolkit.hpp"
#include <boost/optional.hpp>
namespace osrm
{
namespace extractor
{
// generate a visualisation of an intersection, printing the coordinates used for angle calculation
template <typename IntersectionType> struct IntersectionPrinter
{
IntersectionPrinter(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<extractor::QueryNode> &node_coordinates,
const extractor::guidance::CoordinateExtractor &coordinate_extractor);
// renders the used coordinate locations for all entries/as well as the resulting
// intersection-classification
util::json::Array operator()(const NodeID intersection_node,
const IntersectionType &intersection,
const boost::optional<util::json::Object> &node_style = {},
const boost::optional<util::json::Object> &way_style = {}) const;
const util::NodeBasedDynamicGraph &node_based_graph;
const std::vector<extractor::QueryNode> &node_coordinates;
const extractor::guidance::CoordinateExtractor &coordinate_extractor;
};
// IMPLEMENTATION
template <typename IntersectionType>
IntersectionPrinter<IntersectionType>::IntersectionPrinter(
const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<extractor::QueryNode> &node_coordinates,
const extractor::guidance::CoordinateExtractor &coordinate_extractor)
: node_based_graph(node_based_graph), node_coordinates(node_coordinates),
coordinate_extractor(coordinate_extractor)
{
}
template <typename IntersectionType>
util::json::Array IntersectionPrinter<IntersectionType>::operator()(
const NodeID intersection_node,
const IntersectionType &intersection,
const boost::optional<util::json::Object> &node_style,
const boost::optional<util::json::Object> &way_style) const
{
// request the number of lanes. This process needs to be in sync with what happens over at
// intersection analysis
const auto intersection_lanes =
intersection.FindMaximum(guidance::makeExtractLanesForRoad(node_based_graph));
std::vector<util::Coordinate> coordinates;
coordinates.reserve(intersection.size());
coordinates.push_back(node_coordinates[intersection_node]);
const auto road_to_coordinate = [&](const auto &road) {
const constexpr auto FORWARD = false;
const auto to_node = node_based_graph.GetTarget(road.eid);
return coordinate_extractor.GetCoordinateAlongRoad(
intersection_node, road.eid, FORWARD, to_node, intersection_lanes);
};
std::transform(intersection.begin(),
intersection.end(),
std::back_inserter(coordinates),
road_to_coordinate);
util::json::Array features;
features.values.push_back(
util::makeFeature("MultiPoint", makeJsonArray(coordinates), node_style));
if (coordinates.size() > 1)
{
std::vector<util::Coordinate> line_coordinates(2);
line_coordinates[0] = coordinates.front();
const auto coordinate_to_line = [&](const util::Coordinate coordinate) {
line_coordinates[1] = coordinate;
return util::makeFeature("LineString", makeJsonArray(line_coordinates), way_style);
};
std::transform(std::next(coordinates.begin()),
coordinates.end(),
std::back_inserter(features.values),
coordinate_to_line);
}
return features;
}
} /* namespace extractor */
} /* namespace osrm */
#endif /* OSRM_EXTRACTOR_GEOJSON_DEBUG_POLICIES */

View File

@ -1,14 +1,14 @@
#ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
#define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
#include "extractor/intersection/constants.hpp"
#include <algorithm>
#include <boost/assert.hpp>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <string>
#include "extractor/intersection/constants.hpp"
namespace osrm
{
namespace extractor

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include <assert.h>
#include <math.h>
#include <memory.h>
#if defined(_MSC_VER)
#include "rapidjson/msinttypes/stdint.h"

2733
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,10 @@
"private": false,
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.1",
"@mapbox/node-pre-gyp": "^1.0.9",
"cheap-ruler": "^3.0.2",
"mkdirp": "^0.5.5",
"nan": "^2.14.2",
"mkdirp": "^0.5.6",
"nan": "^2.16.0",
"node-cmake": "^2.5.1",
"rimraf": "^2.7.1"
},
@ -39,18 +39,18 @@
"node": ">=4.0.0"
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"acorn": "^8.4.0",
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"acorn": "^8.8.0",
"ansi-escape-sequences": "^5.1.2",
"aws-sdk": "~2.0.31",
"babel-plugin-transform-class-properties": "^6.24.1",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"chalk": "^1.1.3",
"command-line-args": "^5.1.1",
"command-line-args": "^5.2.1",
"command-line-usage": "^5.0.4",
"csv-stringify": "^3.0.0",
"cucumber": "^1.2.1",
@ -59,13 +59,13 @@
"documentation": "^4.0.0",
"eslint": "^5.16.0",
"faucet": "^0.0.1",
"jsonpath": "^1.1.0",
"jsonpath": "^1.1.1",
"node-timeout": "0.0.4",
"polyline": "^0.2.0",
"request": "^2.88.2",
"tape": "^4.13.3",
"tape": "^4.16.0",
"turf": "^3.0.14",
"uglify-js": "^3.13.9",
"uglify-js": "^3.17.0",
"xmlbuilder": "^4.2.1"
},
"bundleDependencies": [

View File

@ -11,7 +11,7 @@ mkdir build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DBUILD_TOOLS=ON -G "Visual Studio 17 2022" ..
cmake -DENABLE_CONAN=ON -DENABLE_NODE_BINDINGS=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "Visual Studio 17 2022" ..
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
msbuild OSRM.sln ^
@ -25,10 +25,6 @@ msbuild OSRM.sln ^
/nologo
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
dir C:\Users\runneradmin\.conan\
dir C:\Users\runneradmin\.conan\data\tbb\2020.3\_\_\package\e9a552ebe8f994398de9ceee972f0ad207df0658\lib\
SET PATH=C:\Users\runneradmin\.conan\data\tbb\2020.3\_\_\package\e9a552ebe8f994398de9ceee972f0ad207df0658\lib\;%PATH%
CD %PROJECT_DIR%\build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

View File

@ -14,7 +14,7 @@ nodejs_init()
message(STATUS "Configuring node_osrm bindings for NodeJs ${NODEJS_VERSION}")
add_nodejs_module(node_osrm node_osrm.cpp)
set_target_properties(node_osrm PROPERTIES CXX_STANDARD 14)
set_target_properties(node_osrm PROPERTIES CXX_STANDARD 17)
# TODO: we disable clang-tidy for this target, because it causes errors in third-party NodeJs related headers
set_target_properties(node_osrm PROPERTIES CXX_CLANG_TIDY "")