UNPKG

8.09 kBPlain TextView Raw
1{
2 'targets': [{
3 'target_name': 'libvips-cpp',
4 'conditions': [
5 ['OS == "win"', {
6 # Build libvips C++ binding for Windows due to MSVC std library ABI changes
7 'type': 'shared_library',
8 'defines': [
9 'VIPS_CPLUSPLUS_EXPORTS',
10 '_ALLOW_KEYWORD_MACROS'
11 ],
12 'sources': [
13 'src/libvips/cplusplus/VError.cpp',
14 'src/libvips/cplusplus/VConnection.cpp',
15 'src/libvips/cplusplus/VInterpolate.cpp',
16 'src/libvips/cplusplus/VImage.cpp'
17 ],
18 'include_dirs': [
19 'vendor/include',
20 'vendor/include/glib-2.0',
21 'vendor/lib/glib-2.0/include'
22 ],
23 'libraries': [
24 '../vendor/lib/libvips.lib',
25 '../vendor/lib/libglib-2.0.lib',
26 '../vendor/lib/libgobject-2.0.lib'
27 ],
28 'configurations': {
29 'Release': {
30 'msvs_settings': {
31 'VCCLCompilerTool': {
32 'ExceptionHandling': 1,
33 'WholeProgramOptimization': 'true'
34 },
35 'VCLibrarianTool': {
36 'AdditionalOptions': [
37 '/LTCG:INCREMENTAL'
38 ]
39 },
40 'VCLinkerTool': {
41 'ImageHasSafeExceptionHandlers': 'false',
42 'OptimizeReferences': 2,
43 'EnableCOMDATFolding': 2,
44 'LinkIncremental': 1,
45 'AdditionalOptions': [
46 '/LTCG:INCREMENTAL'
47 ]
48 }
49 },
50 'msvs_disabled_warnings': [
51 4275
52 ]
53 }
54 }
55 }, {
56 # Ignore this target for non-Windows
57 'type': 'none'
58 }]
59 ]
60 }, {
61 'target_name': 'sharp',
62 'defines': [
63 'NAPI_VERSION=3'
64 ],
65 'dependencies': [
66 '<!(node -p "require(\'node-addon-api\').gyp")',
67 'libvips-cpp'
68 ],
69 'variables': {
70 'runtime_link%': 'shared',
71 'conditions': [
72 ['OS != "win"', {
73 'pkg_config_path': '<!(node -e "console.log(require(\'./lib/libvips\').pkgConfigPath())")',
74 'use_global_libvips': '<!(node -e "console.log(Boolean(require(\'./lib/libvips\').useGlobalLibvips()).toString())")'
75 }, {
76 'pkg_config_path': '',
77 'use_global_libvips': ''
78 }]
79 ]
80 },
81 'sources': [
82 'src/common.cc',
83 'src/metadata.cc',
84 'src/stats.cc',
85 'src/operations.cc',
86 'src/pipeline.cc',
87 'src/utilities.cc',
88 'src/sharp.cc'
89 ],
90 'include_dirs': [
91 '<!@(node -p "require(\'node-addon-api\').include")',
92 ],
93 'conditions': [
94 ['use_global_libvips == "true"', {
95 # Use pkg-config for include and lib
96 'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
97 'conditions': [
98 ['runtime_link == "static"', {
99 'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs --static vips-cpp)']
100 }, {
101 'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)']
102 }],
103 ['OS == "linux"', {
104 'defines': [
105 # Inspect libvips-cpp.so to determine which C++11 ABI version was used and set _GLIBCXX_USE_CXX11_ABI accordingly. This is quite horrible.
106 '_GLIBCXX_USE_CXX11_ABI=<!(if readelf -Ws "$(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --variable libdir vips-cpp)/libvips-cpp.so" | c++filt | grep -qF __cxx11;then echo "1";else echo "0";fi)'
107 ]
108 }]
109 ]
110 }, {
111 # Use pre-built libvips stored locally within node_modules
112 'include_dirs': [
113 'vendor/include',
114 'vendor/include/glib-2.0',
115 'vendor/lib/glib-2.0/include'
116 ],
117 'conditions': [
118 ['OS == "win"', {
119 'defines': [
120 '_ALLOW_KEYWORD_MACROS',
121 '_FILE_OFFSET_BITS=64'
122 ],
123 'libraries': [
124 '../vendor/lib/libvips.lib',
125 '../vendor/lib/libglib-2.0.lib',
126 '../vendor/lib/libgobject-2.0.lib'
127 ]
128 }],
129 ['OS == "mac"', {
130 'libraries': [
131 '../vendor/lib/libvips-cpp.42.dylib',
132 '../vendor/lib/libvips.42.dylib',
133 '../vendor/lib/libglib-2.0.0.dylib',
134 '../vendor/lib/libgobject-2.0.0.dylib',
135 # Ensure runtime linking is relative to sharp.node
136 '-Wl,-s -rpath \'@loader_path/../../vendor/lib\''
137 ]
138 }],
139 ['OS == "linux"', {
140 'defines': [
141 '_GLIBCXX_USE_CXX11_ABI=0'
142 ],
143 'libraries': [
144 '../vendor/lib/libvips-cpp.so',
145 '../vendor/lib/libvips.so',
146 '../vendor/lib/libglib-2.0.so',
147 '../vendor/lib/libgobject-2.0.so',
148 # Dependencies of dependencies, included for openSUSE support
149 '../vendor/lib/libcairo.so',
150 '../vendor/lib/libexif.so',
151 '../vendor/lib/libexpat.so',
152 '../vendor/lib/libffi.so',
153 '../vendor/lib/libfontconfig.so',
154 '../vendor/lib/libfreetype.so',
155 '../vendor/lib/libfribidi.so',
156 '../vendor/lib/libgdk_pixbuf-2.0.so',
157 '../vendor/lib/libgif.so',
158 '../vendor/lib/libgio-2.0.so',
159 '../vendor/lib/libgmodule-2.0.so',
160 '../vendor/lib/libgsf-1.so',
161 '../vendor/lib/libgthread-2.0.so',
162 '../vendor/lib/libharfbuzz.so',
163 '../vendor/lib/libjpeg.so',
164 '../vendor/lib/liblcms2.so',
165 '../vendor/lib/liborc-0.4.so',
166 '../vendor/lib/libpango-1.0.so',
167 '../vendor/lib/libpangocairo-1.0.so',
168 '../vendor/lib/libpangoft2-1.0.so',
169 '../vendor/lib/libpixman-1.so',
170 '../vendor/lib/libpng.so',
171 '../vendor/lib/librsvg-2.so',
172 '../vendor/lib/libtiff.so',
173 '../vendor/lib/libwebp.so',
174 '../vendor/lib/libwebpdemux.so',
175 '../vendor/lib/libwebpmux.so',
176 '../vendor/lib/libxml2.so',
177 '../vendor/lib/libz.so',
178 # Ensure runtime linking is relative to sharp.node
179 '-Wl,-s -Wl,--disable-new-dtags -Wl,-rpath=\'$${ORIGIN}/../../vendor/lib\''
180 ]
181 }]
182 ]
183 }]
184 ],
185 'cflags_cc': [
186 '-std=c++0x',
187 '-fexceptions',
188 '-Wall',
189 '-O3'
190 ],
191 'xcode_settings': {
192 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
193 'CLANG_CXX_LIBRARY': 'libc++',
194 'MACOSX_DEPLOYMENT_TARGET': '10.7',
195 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
196 'GCC_ENABLE_CPP_RTTI': 'YES',
197 'OTHER_CPLUSPLUSFLAGS': [
198 '-fexceptions',
199 '-Wall',
200 '-O3'
201 ]
202 },
203 'configurations': {
204 'Release': {
205 'conditions': [
206 ['OS == "linux"', {
207 'cflags_cc': [
208 '-Wno-cast-function-type'
209 ]
210 }],
211 ['target_arch == "arm"', {
212 'cflags_cc': [
213 '-Wno-psabi'
214 ]
215 }],
216 ['OS == "win"', {
217 'msvs_settings': {
218 'VCCLCompilerTool': {
219 'ExceptionHandling': 1,
220 'WholeProgramOptimization': 'true'
221 },
222 'VCLibrarianTool': {
223 'AdditionalOptions': [
224 '/LTCG:INCREMENTAL'
225 ]
226 },
227 'VCLinkerTool': {
228 'ImageHasSafeExceptionHandlers': 'false',
229 'OptimizeReferences': 2,
230 'EnableCOMDATFolding': 2,
231 'LinkIncremental': 1,
232 'AdditionalOptions': [
233 '/LTCG:INCREMENTAL'
234 ]
235 }
236 },
237 'msvs_disabled_warnings': [
238 4275
239 ]
240 }]
241 ]
242 }
243 },
244 }]
245}