Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mason_packages
node_modules
build
.toolchain
.mason
.git
local.env
lib/binding
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.DS_Store
mason_packages
build
*.profdata
*.profraw
.toolchain
.mason
local.env
lib/binding
viz/node_modules
node_modules
venv
24 changes: 24 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[submodule "vendor/geometry"]
path = vendor/geometry
url = https://github.com/mapbox/geometry.hpp
[submodule "vendor/variant"]
path = vendor/variant
url = https://github.com/mapbox/variant
[submodule "vendor/vtzero"]
path = vendor/vtzero
url = https://github.com/mapbox/vtzero
[submodule "vendor/spatial-algorithms"]
path = vendor/spatial-algorithms
url = https://github.com/mapbox/spatial-algorithms
[submodule "vendor/boost"]
path = vendor/boost
url = https://github.com/boostorg/boost
[submodule "vendor/gzip-hpp"]
path = vendor/gzip-hpp
url = https://github.com/mapbox/gzip-hpp
[submodule "vendor/protozero"]
path = vendor/protozero
url = https://github.com/mapbox/protozero
[submodule "vendor/cheap-ruler"]
path = vendor/cheap-ruler
url = https://github.com/mapbox/cheap-ruler-cpp
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ install:
- clang++ -v
- which clang++
- make ${BUILDTYPE}
# Build should be standalone now, so remove mason deps
- rm -rf mason_packages

# *Here we run tests*
# We prefer running tests in the 'before_script' section rather than 'script' to ensure fast failure.
Expand Down Expand Up @@ -87,7 +85,6 @@ matrix:
env: BUILDTYPE=debug CXXFLAGS="--coverage" LDFLAGS="--coverage"
# Overrides `script` to publish coverage data to codecov
script:
- export PATH=$(pwd)/mason_packages/.link/bin/:${PATH}
- which llvm-cov
- pip install --user codecov
- codecov --gcov-exec "llvm-cov gcov -l"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && \

RUN curl https://nodejs.org/dist/v4.8.4/node-v4.8.4-linux-x64.tar.gz | tar zxC /usr/local --strip-components=1

ENV PATH=/usr/local/src/mason_packages/.link/bin:${PATH} CXX=clang++
ENV CXX=clang++
WORKDIR /usr/local/src
COPY ./ ./

Expand Down
25 changes: 8 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,27 @@ export WERROR ?= true
# just typing `make` will call `make release`
default: release

node_modules/nan:
node_modules:
npm install --ignore-scripts

mason_packages/headers: node_modules/nan
node_modules/.bin/mason-js install

mason_packages/.link/include: mason_packages/headers
node_modules/.bin/mason-js link

build-deps: mason_packages/.link/include

release: build-deps
release:
V=1 ./node_modules/.bin/node-pre-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error
@echo "run 'make clean' for full rebuild"

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

coverage: build-deps
coverage:
./scripts/coverage.sh

tidy: build-deps
tidy:
./scripts/clang-tidy.sh

format: build-deps
format:
./scripts/clang-format.sh

sanitize: build-deps
sanitize:
./scripts/sanitize.sh

clean:
Expand All @@ -61,11 +53,10 @@ clean:
# remove remains from running 'make coverage'
rm -f *.profraw
rm -f *.profdata
@echo "run 'make distclean' to also clear node_modules, mason_packages, and .mason directories"
@echo "run 'make distclean' to also clear node_modules"

distclean: clean
rm -rf node_modules
rm -rf mason_packages

# variable used in the `xcode` target below
MODULE_NAME := $(shell node -e "console.log(require('./package.json').binary.module_name)")
Expand Down
175 changes: 70 additions & 105 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,110 +1,75 @@
# This file inherits default targets for Node addons, see https://github.com/nodejs/node-gyp/blob/master/addon.gypi
{
# https://github.com/springmeyer/gyp/blob/master/test/make_global_settings/wrapper/wrapper.gyp
'make_global_settings': [
['CXX', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
['CC', '<(module_root_dir)/mason_packages/.link/bin/clang'],
['LINK', '<(module_root_dir)/mason_packages/.link/bin/clang++'],
['AR', '<(module_root_dir)/mason_packages/.link/bin/llvm-ar'],
['NM', '<(module_root_dir)/mason_packages/.link/bin/llvm-nm']
],
'includes': [ 'common.gypi' ], # brings in a default set of options that are inherited from gyp
'variables': { # custom variables we use specific to this file
'error_on_warnings%':'true', # can be overriden by a command line variable because of the % sign using "WERROR" (defined in Makefile)
# Use this variable to silence warnings from mason dependencies and from node-addon-api
# It's a variable to make easy to pass to
# cflags (linux) and xcode (mac)
'system_includes': [
"-isystem <!@(node -p \"require('node-addon-api').include.slice(1,-1)\")",
"-isystem <(module_root_dir)/mason_packages/.link/include/"
],
'compiler_checks': [
'-Wall',
'-Wextra',
'-Wconversion',
'-pedantic-errors',
'-Wconversion',
'-Wshadow',
'-Wfloat-equal',
'-Wuninitialized',
'-Wunreachable-code',
'-Wold-style-cast',
'-Wno-error=unused-variable',
'-Wno-error=deprecated-declarations'
]
},
# `targets` is a list of targets for gyp to run.
# Different types of targets:
# - [executable](https://github.com/mapbox/cpp/blob/master/glossary.md#executable)
# - [loadable_module](https://github.com/mapbox/cpp/blob/master/glossary.md#loadable-module)
# - [static library](https://github.com/mapbox/cpp/blob/master/glossary.md#static-library)
# - [shared library](https://github.com/mapbox/cpp/blob/master/glossary.md#shared-library)
# - none: a trick to tell gyp not to run the compiler for a given target.
'targets': [
{
'target_name': 'action_before_build',
'type': 'none',
'hard_dependency': 1,
'actions': [
{
'action_name': 'install_deps',
'inputs': ['./node_modules/.bin/mason-js'],
'outputs': ['./mason_packages'],
'action': ['./node_modules/.bin/mason-js', 'install']
},
{
'action_name': 'link_deps',
'inputs': ['./node_modules/.bin/mason-js'],
'outputs': ['./mason_packages/.link'],
'action': ['./node_modules/.bin/mason-js', 'link']
}
]
},
{
# module_name and module_path are both variables passed by node-pre-gyp from package.json
'target_name': '<(module_name)', # sets the name of the binary file
'product_dir': '<(module_path)', # controls where the node binary file gets copied to (./lib/binding/module.node)
'type': 'loadable_module',
'dependencies': [ 'action_before_build' ],
# "make" only watches files specified here, and will sometimes cache these files after the first compile.
# This cache can sometimes cause confusing errors when removing/renaming/adding new files.
# Running "make clean" helps to prevent this "mysterious error by cache" scenario
# This also is where the benefits of using a "glob" come into play...
# See: https://github.com/mapbox/node-cpp-skel/pull/44#discussion_r122050205
'sources': [
'./src/module.cpp',
'./src/vtquery.cpp'
],
'ldflags': [
'-Wl,-z,now',
],
'conditions': [
['error_on_warnings == "true"', {
'cflags_cc' : [ '-Werror' ],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '-Werror' ]
}
}]
],
'cflags': [
'<@(system_includes)',
'<@(compiler_checks)'
],
'xcode_settings': {
'OTHER_LDFLAGS':[
'-Wl,-bind_at_load'
"includes": [
"common.gypi"
], # brings in a default set of options that are inherited from gyp
"variables": { # custom variables we use specific to this file
"error_on_warnings%": "true", # can be overriden by a command line variable because of the % sign using "WERROR" (defined in Makefile)
# Use this variable to silence warnings from dependencies and from node-addon-api
# It's a variable to make easy to pass to
# cflags (linux) and xcode (mac)
"system_includes": [
"-isystem <!@(node -p \"require('node-addon-api').include.slice(1,-1)\")",
"<!@(node -p \"require('fs').readdirSync('./vendor', {withFileTypes: true}).filter(e => e.isDirectory()).map(f=>'-isystem <(module_root_dir)/vendor/'+f.name+'/include').join(' ')\")",
"<!@(node -p \"require('fs').readdirSync('./vendor/boost/libs/', {withFileTypes: true}).filter(e => e.isDirectory()).map(f=>'-isystem <(module_root_dir)/vendor/boost/libs/'+f.name+'/include').join(' ')\")",
],
'OTHER_CPLUSPLUSFLAGS': [
'<@(system_includes)',
'<@(compiler_checks)'
"compiler_checks": [
"-Wall",
"-Wextra",
"-Wconversion",
"-pedantic-errors",
"-Wconversion",
"-Wshadow",
"-Wfloat-equal",
"-Wuninitialized",
"-Wunreachable-code",
"-Wold-style-cast",
"-Wno-error=unused-variable",
"-Wno-error=deprecated-declarations",
],
'GCC_ENABLE_CPP_RTTI': 'YES',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'MACOSX_DEPLOYMENT_TARGET':'10.8',
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD':'c++14',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0'
}
}
]
},
# `targets` is a list of targets for gyp to run.
# Different types of targets:
# - [executable](https://github.com/mapbox/cpp/blob/master/glossary.md#executable)
# - [loadable_module](https://github.com/mapbox/cpp/blob/master/glossary.md#loadable-module)
# - [static library](https://github.com/mapbox/cpp/blob/master/glossary.md#static-library)
# - [shared library](https://github.com/mapbox/cpp/blob/master/glossary.md#shared-library)
# - none: a trick to tell gyp not to run the compiler for a given target.
"targets": [
{
# module_name and module_path are both variables passed by node-pre-gyp from package.json
"target_name": "<(module_name)", # sets the name of the binary file
"product_dir": "<(module_path)", # controls where the node binary file gets copied to (./lib/binding/module.node)
"type": "loadable_module",
# "make" only watches files specified here, and will sometimes cache these files after the first compile.
# This cache can sometimes cause confusing errors when removing/renaming/adding new files.
# Running "make clean" helps to prevent this "mysterious error by cache" scenario
# This also is where the benefits of using a "glob" come into play...
# See: https://github.com/mapbox/node-cpp-skel/pull/44#discussion_r122050205
"sources": ["./src/module.cpp", "./src/vtquery.cpp"],
"ldflags": [
"-Wl,-z,now",
],
"conditions": [
[
'error_on_warnings == "true"',
{
"cflags_cc": ["-Werror"],
"xcode_settings": {"OTHER_CPLUSPLUSFLAGS": ["-Werror"]},
},
]
],
"cflags": ["<@(system_includes)", "<@(compiler_checks)"],
"xcode_settings": {
"OTHER_LDFLAGS": ["-Wl,-bind_at_load"],
"OTHER_CPLUSPLUSFLAGS": ["<@(system_includes)", "<@(compiler_checks)"],
"GCC_ENABLE_CPP_RTTI": "YES",
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"MACOSX_DEPLOYMENT_TARGET": "10.15",
"CLANG_CXX_LIBRARY": "libc++",
"CLANG_CXX_LANGUAGE_STANDARD": "c++14",
"GCC_VERSION": "com.apple.compilers.llvm.clang.1_0",
},
},
],
}
78 changes: 29 additions & 49 deletions common.gypi
Original file line number Diff line number Diff line change
@@ -1,52 +1,32 @@
{
'target_defaults': {
'default_configuration': 'Release',
'cflags_cc' : [ '-std=c++14' ],
'cflags_cc!': ['-std=gnu++0x','-std=gnu++1y', '-fno-rtti', '-fno-exceptions'],
'configurations': {
'Debug': {
'defines!': [
'NDEBUG'
],
'cflags_cc!': [
'-O3',
'-Os',
'-DNDEBUG'
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS!': [
'-O3',
'-Os',
'-DDEBUG'
],
'GCC_OPTIMIZATION_LEVEL': '0',
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES'
}
},
'Release': {
'defines': [
'NDEBUG'
],
'cflags': [
'-flto'
],
'ldflags': [
'-flto',
'-fuse-ld=<(module_root_dir)/mason_packages/.link/bin/ld'
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS!': [
'-Os',
'-O2'
],
'OTHER_LDFLAGS':[ '-flto' ],
'OTHER_CPLUSPLUSFLAGS': [ '-flto' ],
'GCC_OPTIMIZATION_LEVEL': '3',
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
'DEAD_CODE_STRIPPING': 'YES',
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES'
}
}
"target_defaults": {
"default_configuration": "Release",
"cflags_cc": ["-std=c++14"],
"cflags_cc!": ["-std=gnu++0x", "-std=gnu++1y", "-fno-rtti", "-fno-exceptions"],
"configurations": {
"Debug": {
"defines!": ["NDEBUG"],
"cflags_cc!": ["-O3", "-Os", "-DNDEBUG"],
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS!": ["-O3", "-Os", "-DDEBUG"],
"GCC_OPTIMIZATION_LEVEL": "0",
"GCC_GENERATE_DEBUGGING_SYMBOLS": "YES",
},
},
"Release": {
"defines": ["NDEBUG"],
"cflags": ["-flto"],
"ldflags": ["-flto"],
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS!": ["-Os", "-O2"],
"OTHER_LDFLAGS": ["-flto"],
"OTHER_CPLUSPLUSFLAGS": ["-flto"],
"GCC_OPTIMIZATION_LEVEL": "3",
"GCC_GENERATE_DEBUGGING_SYMBOLS": "NO",
"DEAD_CODE_STRIPPING": "YES",
"GCC_INLINES_ARE_PRIVATE_EXTERN": "YES",
},
},
},
}
}
}
Loading