-
Notifications
You must be signed in to change notification settings - Fork 10
/
binding.gyp
115 lines (115 loc) · 4.63 KB
/
binding.gyp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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 NAN
# It's a variable to make easy to pass to
# cflags (linux) and xcode (mac)
'system_includes': [
"-isystem <(module_root_dir)/<!(node -e \"require('nan')\")",
"-isystem <(module_root_dir)/mason_packages/.link/include/"
],
# Flags we pass to the compiler to ensure the compiler
# warns us about potentially buggy or dangerous code
'compiler_checks': [
'-Wall',
'-Wextra',
'-Weffc++',
'-Wconversion',
'-pedantic-errors',
'-Wconversion',
'-Wshadow',
'-Wfloat-equal',
'-Wuninitialized',
'-Wunreachable-code',
'-Wold-style-cast',
'-Wno-error=unused-variable'
]
},
# `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/standalone/hello.cpp',
'./src/standalone_async/hello_async.cpp',
'./src/object_sync/hello.cpp',
'./src/object_async/hello_async.cpp'
],
'ldflags': [
'-Wl,-z,now',
],
'conditions': [
['error_on_warnings == "true"', {
'cflags_cc' : [ '-Werror' ],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '-Werror' ]
}
}]
],
'cflags_cc': [
'<@(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.8',
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD':'c++11',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0'
}
}
]
}