Skip to content

Commit 68867f4

Browse files
springmeyermapsam
authored andcommitted
Update to latest node-cpp-skel (#114)
* node v12 + upgrades all around via node-cpp-skel * wow, vtquery was really out of date * add sanitize script * add mason-versions.ini for mason-js * port over common.gypi fixes too * clang-tidy fixes * fix sanitize script * more clang tidy fixes * clang format
1 parent 1805a37 commit 68867f4

16 files changed

+463
-440
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Checks: '*,-cert-err58-cpp'
2+
Checks: '*,-cert-err58-cpp,-fuchsia*,-google-runtime-references'
33
WarningsAsErrors: '*'
44
HeaderFilterRegex: '\/include\/'
55
AnalyzeTemporaryDtors: false

.travis.yml

Lines changed: 47 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ addons:
99
packages: [ 'libstdc++-4.9-dev' ]
1010

1111
install:
12-
# set up the environment by installing mason and clang++
13-
- ./scripts/setup.sh --config local.env
14-
# put mason and clang++ on PATH
15-
- source local.env
1612
- node -v
1713
- which node
1814
- clang++ -v
@@ -27,70 +23,70 @@ install:
2723
# For this reason, we disable the 'script' section below, since we prefer using 'before_script'.
2824
before_script:
2925
- npm test
30-
# after successful tests, publish binaries if specified in commit message
31-
- ./scripts/publish.sh --toolset=${TOOLSET:-} --debug=$([ "${BUILDTYPE}" == 'debug' ] && echo "true" || echo "false")
3226

33-
# We set 'script' here to an empty array to prevent this section from automatically running 'npm test'
34-
# The reason we do this is mentioned above in the comment about the 'before_script' stage.
35-
# For reference, the default travis behavior which we override comes from https://github.com/travis-ci/travis-build/blob/e5a45cbf49e0d9e27398e76e5f25dd7706feb6aa/lib/travis/build/script/node_js.rb#L62-L69.
3627
script:
28+
# after successful tests, publish binaries if specified in commit message
29+
- ./scripts/publish.sh --toolset=${TOOLSET:-} --debug=$([ "${BUILDTYPE}" == 'debug' ] && echo "true" || echo "false")
3730

3831
# the matrix allows you to specify different operating systems and environments to
3932
# run your tests and build binaries
4033
matrix:
4134
include:
42-
# linux publishable node v8
35+
36+
## ** Builds that are published **
37+
38+
# linux cfi build node v6/release
4339
- os: linux
44-
env: BUILDTYPE=release
45-
node_js: 8
46-
# linux publishable node v8/debug
40+
env: BUILDTYPE=release TOOLSET=cfi CXXFLAGS="-fsanitize=cfi -fvisibility=hidden" LDFLAGS="-fsanitize=cfi"
41+
node_js: 10
42+
# linux publishable node v12/release
4743
- os: linux
48-
env: BUILDTYPE=debug
49-
node_js: 8
50-
# linux publishable node v10
44+
env: BUILDTYPE=release
45+
node_js: 12
46+
# linux publishable node v10/release
5147
- os: linux
5248
env: BUILDTYPE=release
5349
node_js: 10
5450
# linux publishable node v10/debug
5551
- os: linux
5652
env: BUILDTYPE=debug
5753
node_js: 10
58-
# osx publishable node v8
54+
# osx publishable node v10/release
5955
- os: osx
60-
osx_image: xcode8.3
56+
osx_image: xcode9.3
6157
env: BUILDTYPE=release
62-
node_js: 8
63-
# osx publishable node v10
58+
node_js: 10
59+
# osx publishable node v12/release
6460
- os: osx
65-
osx_image: xcode8.3
61+
osx_image: xcode9.3
6662
env: BUILDTYPE=release
67-
node_js: 10
68-
# Sanitizer build node v10/Debug
63+
node_js: 12
64+
# linux sanitizer build node v6/debug
6965
- os: linux
7066
env: BUILDTYPE=debug TOOLSET=asan
71-
sudo: required # workaround https://github.com/mapbox/node-cpp-skel/issues/93
7267
node_js: 10
68+
sudo: required
7369
# Overrides `install` to set up custom asan flags
7470
install:
75-
- ./scripts/setup.sh --config local.env
76-
# put mason and clang++ on PATH
77-
- source local.env
78-
# Note: to build without stopping on errors remove the -fno-sanitize-recover=all flag
79-
# You might want to do this if there are multiple errors and you want to see them all before fixing
80-
- export CXXFLAGS="${MASON_SANITIZE_CXXFLAGS} -fno-sanitize-recover=all"
81-
- export LDFLAGS="${MASON_SANITIZE_LDFLAGS}"
82-
- make ${BUILDTYPE}
83-
# Overrides `script` to disable asan LD_PRELOAD before publishing
71+
- make sanitize
72+
# Overrides `before_script` (tests are already run in `make sanitize`)
73+
before_script:
74+
# osx sanitizer build node v6/debug
75+
- os: osx
76+
env: BUILDTYPE=debug TOOLSET=asan
77+
node_js: 10
78+
sudo: required
79+
# Overrides `install` to set up custom asan flags
80+
install:
81+
- make sanitize
82+
# Overrides `before_script` (tests are already run in `make sanitize`)
8483
before_script:
85-
- export LD_PRELOAD=${MASON_LLVM_RT_PRELOAD}
86-
- export ASAN_OPTIONS=fast_unwind_on_malloc=0:${ASAN_OPTIONS}
87-
- npm test
88-
- unset LD_PRELOAD
89-
# after successful tests, publish binaries if specified in commit message
90-
- ./scripts/publish.sh --toolset=${TOOLSET:-} --debug=$([ "${BUILDTYPE}" == 'debug' ] && echo "true" || echo "false")
84+
85+
## ** Builds that do not get published **
86+
9187
# g++ build (default builds all use clang++)
9288
- os: linux
93-
env: BUILDTYPE=debug CXX="g++-6" CC="gcc-6" CXXFLAGS="-Weffc++"
89+
env: BUILDTYPE=debug CXX="g++-6" CC="gcc-6" LINK="g++-6" AR="ar" NM="nm"
9490
node_js: 10
9591
addons:
9692
apt:
@@ -103,23 +99,17 @@ matrix:
10399
install:
104100
- make ${BUILDTYPE}
105101
# Overrides `script` to disable publishing
106-
before_script:
107-
- npm test
102+
script:
108103
# Coverage build
109104
- os: linux
110105
env: BUILDTYPE=debug CXXFLAGS="--coverage" LDFLAGS="--coverage"
111106
node_js: 10
112107
# Overrides `script` to publish coverage data to codecov
113-
before_script:
114-
- pip install --user codecov
115-
- mason install llvm-cov ${MASON_LLVM_RELEASE}
116-
- mason link llvm-cov ${MASON_LLVM_RELEASE}
117-
- which llvm-cov
118-
- curl -S -f https://codecov.io/bash -o codecov
119-
- chmod +x codecov
120108
script:
121-
- make coverage
122-
- ./codecov -x "llvm-cov gcov" -Z
109+
- export PATH=$(pwd)/mason_packages/.link/bin/:${PATH}
110+
- which llvm-cov
111+
- pip install --user codecov
112+
- codecov --gcov-exec "llvm-cov gcov -l"
123113
# Clang format build
124114
- os: linux
125115
# can be generic since we don't need nodejs to run formatting
@@ -131,8 +121,10 @@ matrix:
131121
# will trigger the build to fail (idea here is to get us to pay attention
132122
# and get in the habit of running these locally before committing)
133123
- make format
134-
# Overrides `script`, no need to run tests
124+
# Overrides `before_script`, no need to run tests
135125
before_script:
126+
# Overrides `script` to disable publishing
127+
script:
136128
# Clang tidy build
137129
- os: linux
138130
env: CLANG_TIDY
@@ -144,5 +136,7 @@ matrix:
144136
# will trigger the build to fail (idea here is to get us to pay attention
145137
# and get in the habit of running these locally before committing)
146138
- make tidy
147-
# Overrides `script`, no need to run tests
139+
# Overrides `before_script`, no need to run tests
148140
before_script:
141+
# Overrides `script` to disable publishing
142+
script:

Makefile

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,60 @@
1-
MODULE_NAME := $(shell node -e "console.log(require('./package.json').binary.module_name)")
1+
# This Makefile serves a few purposes:
2+
#
3+
# 1. It provides an interface to iterate quickly while developing the C++ code in src/
4+
# by typing `make` or `make debug`. To make iteration as fast as possible it calls out
5+
# directly to underlying build tools and skips running steps that appear to have already
6+
# been run (determined by the presence of a known file or directory). What `make` does is
7+
# the same as running `npm install --build-from-source` except that it is faster when
8+
# run a second time because it will skip re-running expensive steps.
9+
# Note: in rare cases (like if you hit `crtl-c` during an install) you might end up with
10+
# build deps only partially installed. In this case you should run `make distclean` to fully
11+
# restore your repo to is starting state and then running `make` again should start from
12+
# scratch, fixing any inconsistencies.
13+
#
14+
# 2. It provides a few commands that call out to external scripts like `make coverage` or
15+
# `make tidy`. These scripts can be called directly but this Makefile provides a more uniform
16+
# interface to call them.
17+
#
18+
# To learn more about the build system see https://github.com/mapbox/node-cpp-skel/blob/master/docs/extended-tour.md#builds
219

320
# Whether to turn compiler warnings into errors
421
export WERROR ?= true
522

23+
# the default target. This line means that
24+
# just typing `make` will call `make release`
625
default: release
726

8-
node_modules:
9-
# install deps but for now ignore our own install script
10-
# so that we can run it directly in either debug or release
27+
node_modules/nan:
1128
npm install --ignore-scripts
1229

13-
release: node_modules
30+
mason_packages/headers: node_modules/nan
31+
node_modules/.bin/mason-js install
32+
33+
mason_packages/.link/include: mason_packages/headers
34+
node_modules/.bin/mason-js link
35+
36+
build-deps: mason_packages/.link/include
37+
38+
release: build-deps
1439
V=1 ./node_modules/.bin/node-pre-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error
1540
@echo "run 'make clean' for full rebuild"
1641

17-
debug: node_modules
42+
debug: mason_packages/.link/include
1843
V=1 ./node_modules/.bin/node-pre-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error --debug
1944
@echo "run 'make clean' for full rebuild"
2045

21-
coverage:
46+
coverage: build-deps
2247
./scripts/coverage.sh
2348

24-
tidy:
49+
tidy: build-deps
2550
./scripts/clang-tidy.sh
2651

27-
format:
52+
format: build-deps
2853
./scripts/clang-format.sh
2954

55+
sanitize: build-deps
56+
./scripts/sanitize.sh
57+
3058
clean:
3159
rm -rf lib/binding
3260
rm -rf build
@@ -38,20 +66,23 @@ clean:
3866
distclean: clean
3967
rm -rf node_modules
4068
rm -rf mason_packages
41-
# remove remains from running './scripts/setup.sh'
42-
rm -rf .mason
43-
rm -rf .toolchain
44-
rm -f local.env
69+
70+
# variable used in the `xcode` target below
71+
MODULE_NAME := $(shell node -e "console.log(require('./package.json').binary.module_name)")
4572

4673
xcode: node_modules
4774
./node_modules/.bin/node-pre-gyp configure -- -f xcode
48-
4975
@# If you need more targets, e.g. to run other npm scripts, duplicate the last line and change NPM_ARGUMENT
5076
SCHEME_NAME="$(MODULE_NAME)" SCHEME_TYPE=library BLUEPRINT_NAME=$(MODULE_NAME) BUILDABLE_NAME=$(MODULE_NAME).node scripts/create_scheme.sh
5177
SCHEME_NAME="npm test" SCHEME_TYPE=node BLUEPRINT_NAME=$(MODULE_NAME) BUILDABLE_NAME=$(MODULE_NAME).node NODE_ARGUMENT="`npm bin tape`/tape test/*.test.js" scripts/create_scheme.sh
5278

5379
open build/binding.xcodeproj
5480

81+
testpack:
82+
rm -f ./*tgz
83+
npm pack
84+
tar -ztvf *tgz
85+
5586
docs:
5687
npm run docs
5788

binding.gyp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# This file inherits default targets for Node addons, see https://github.com/nodejs/node-gyp/blob/master/addon.gypi
22
{
3+
# https://github.com/springmeyer/gyp/blob/master/test/make_global_settings/wrapper/wrapper.gyp
4+
'make_global_settings': [
5+
['CXX', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
6+
['CC', '<(module_root_dir)/mason_packages/.link/bin/clang'],
7+
['LINK', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
8+
['AR', '<(module_root_dir)/mason_packages/.link/bin/llvm-ar'],
9+
['NM', '<(module_root_dir)/mason_packages/.link/bin/llvm-nm']
10+
],
311
'includes': [ 'common.gypi' ], # brings in a default set of options that are inherited from gyp
412
'variables': { # custom variables we use specific to this file
513
'error_on_warnings%':'true', # can be overriden by a command line variable because of the % sign using "WERROR" (defined in Makefile)
@@ -34,18 +42,21 @@
3442
# - none: a trick to tell gyp not to run the compiler for a given target.
3543
'targets': [
3644
{
37-
# This target:
38-
# - doesnt build any code (why it's type "none", to tell gyp not to run the compiler)
39-
# - runs a script to install mason packages
4045
'target_name': 'action_before_build',
4146
'type': 'none',
4247
'hard_dependency': 1,
4348
'actions': [
4449
{
4550
'action_name': 'install_deps',
46-
'inputs': ['./scripts/install_deps.sh'],
51+
'inputs': ['./node_modules/.bin/mason-js'],
4752
'outputs': ['./mason_packages'],
48-
'action': ['./scripts/install_deps.sh']
53+
'action': ['./node_modules/.bin/mason-js', 'install']
54+
},
55+
{
56+
'action_name': 'link_deps',
57+
'inputs': ['./node_modules/.bin/mason-js'],
58+
'outputs': ['./mason_packages/.link'],
59+
'action': ['./node_modules/.bin/mason-js', 'link']
4960
}
5061
]
5162
},

common.gypi

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# More details at https://github.com/mapbox/mason/issues/319
1313
'-D_GLIBCXX_USE_CXX11_ABI=0'
1414
],
15-
'cflags_cc!': ['-std=gnu++0x', '-std=gnu++1y', '-fno-rtti', '-fno-exceptions'],
15+
'cflags_cc!': ['-std=gnu++0x','-std=gnu++1y', '-fno-rtti', '-fno-exceptions'],
1616
'configurations': {
1717
'Debug': {
1818
'defines!': [
@@ -37,11 +37,20 @@
3737
'defines': [
3838
'NDEBUG'
3939
],
40+
'cflags': [
41+
'-flto'
42+
],
43+
'ldflags': [
44+
'-flto',
45+
'-fuse-ld=<(module_root_dir)/mason_packages/.link/bin/ld'
46+
],
4047
'xcode_settings': {
4148
'OTHER_CPLUSPLUSFLAGS!': [
4249
'-Os',
4350
'-O2'
4451
],
52+
'OTHER_LDFLAGS':[ '-flto' ],
53+
'OTHER_CPLUSPLUSFLAGS': [ '-flto' ],
4554
'GCC_OPTIMIZATION_LEVEL': '3',
4655
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
4756
'DEAD_CODE_STRIPPING': 'YES',

mason-versions.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[headers]
2+
geometry=96d3505
3+
variant=1.1.4
4+
vtzero=1.0.1
5+
protozero=1.6.2
6+
spatial-algorithms=0.1.0
7+
boost=1.65.1
8+
cheap-ruler=2.5.3
9+
vector-tile=f4728da
10+
gzip-hpp=0.1.0
11+
protozero=1.6.3
12+
[compiled]
13+
clang++=7.0.0
14+
clang-tidy=7.0.0
15+
clang-format=7.0.0
16+
llvm-cov=7.0.0
17+
binutils=2.31

0 commit comments

Comments
 (0)