1 |
|
2 |
|
3 |
|
4 | {
|
5 | 'variables': {
|
6 | 'vips_version': '<!(node -p "require(\'../lib/libvips\').minimumLibvipsVersion")',
|
7 | 'platform_and_arch': '<!(node -p "require(\'../lib/libvips\').buildPlatformArch()")',
|
8 | 'sharp_libvips_version': '<!(node -p "require(\'../package.json\').optionalDependencies[\'@img/sharp-libvips-<(platform_and_arch)\']")',
|
9 | 'sharp_libvips_yarn_locator': '<!(node -p "require(\'../lib/libvips\').yarnLocator()")',
|
10 | 'sharp_libvips_include_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsIncludeDir()")',
|
11 | 'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsCPlusPlusDir()")',
|
12 | 'sharp_libvips_lib_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsLibDir()")'
|
13 | },
|
14 | 'targets': [{
|
15 | 'target_name': 'libvips-cpp',
|
16 | 'conditions': [
|
17 | ['OS == "win"', {
|
18 |
|
19 | 'type': 'shared_library',
|
20 | 'defines': [
|
21 | 'VIPS_CPLUSPLUS_EXPORTS',
|
22 | '_ALLOW_KEYWORD_MACROS'
|
23 | ],
|
24 | 'sources': [
|
25 | '<(sharp_libvips_cplusplus_dir)/VConnection.cpp',
|
26 | '<(sharp_libvips_cplusplus_dir)/VError.cpp',
|
27 | '<(sharp_libvips_cplusplus_dir)/VImage.cpp',
|
28 | '<(sharp_libvips_cplusplus_dir)/VInterpolate.cpp',
|
29 | '<(sharp_libvips_cplusplus_dir)/VRegion.cpp'
|
30 | ],
|
31 | 'include_dirs': [
|
32 | '<(sharp_libvips_include_dir)',
|
33 | '<(sharp_libvips_include_dir)/glib-2.0',
|
34 | '<(sharp_libvips_lib_dir)/glib-2.0/include'
|
35 | ],
|
36 | 'link_settings': {
|
37 | 'library_dirs': [
|
38 | '<(sharp_libvips_lib_dir)'
|
39 | ],
|
40 | 'libraries': [
|
41 | 'libvips.lib'
|
42 | ],
|
43 | },
|
44 | 'configurations': {
|
45 | 'Release': {
|
46 | 'msvs_settings': {
|
47 | 'VCCLCompilerTool': {
|
48 | 'ExceptionHandling': 1,
|
49 | 'Optimization': 1,
|
50 | 'WholeProgramOptimization': 'true'
|
51 | },
|
52 | 'VCLibrarianTool': {
|
53 | 'AdditionalOptions': [
|
54 | '/LTCG:INCREMENTAL'
|
55 | ]
|
56 | },
|
57 | 'VCLinkerTool': {
|
58 | 'ImageHasSafeExceptionHandlers': 'false',
|
59 | 'OptimizeReferences': 2,
|
60 | 'EnableCOMDATFolding': 2,
|
61 | 'LinkIncremental': 1,
|
62 | 'AdditionalOptions': [
|
63 | '/LTCG:INCREMENTAL'
|
64 | ]
|
65 | }
|
66 | },
|
67 | 'msvs_disabled_warnings': [
|
68 | 4275
|
69 | ]
|
70 | }
|
71 | }
|
72 | }, {
|
73 |
|
74 | 'type': 'none'
|
75 | }]
|
76 | ]
|
77 | }, {
|
78 | 'target_name': 'sharp-<(platform_and_arch)',
|
79 | 'defines': [
|
80 | 'NAPI_VERSION=9',
|
81 | 'NODE_ADDON_API_DISABLE_DEPRECATED',
|
82 | 'NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS'
|
83 | ],
|
84 | 'dependencies': [
|
85 | '<!(node -p "require(\'node-addon-api\').gyp")',
|
86 | 'libvips-cpp'
|
87 | ],
|
88 | 'variables': {
|
89 | 'conditions': [
|
90 | ['OS != "win"', {
|
91 | 'pkg_config_path': '<!(node -p "require(\'../lib/libvips\').pkgConfigPath()")',
|
92 | 'use_global_libvips': '<!(node -p "Boolean(require(\'../lib/libvips\').useGlobalLibvips()).toString()")'
|
93 | }, {
|
94 | 'pkg_config_path': '',
|
95 | 'use_global_libvips': ''
|
96 | }]
|
97 | ]
|
98 | },
|
99 | 'sources': [
|
100 | 'common.cc',
|
101 | 'metadata.cc',
|
102 | 'stats.cc',
|
103 | 'operations.cc',
|
104 | 'pipeline.cc',
|
105 | 'utilities.cc',
|
106 | 'sharp.cc'
|
107 | ],
|
108 | 'include_dirs': [
|
109 | '<!(node -p "require(\'node-addon-api\').include_dir")',
|
110 | ],
|
111 | 'conditions': [
|
112 | ['use_global_libvips == "true"', {
|
113 |
|
114 | 'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
|
115 | 'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)'],
|
116 | 'defines': [
|
117 | 'SHARP_USE_GLOBAL_LIBVIPS'
|
118 | ],
|
119 | 'conditions': [
|
120 | ['OS == "linux"', {
|
121 | 'defines': [
|
122 |
|
123 | '_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)'
|
124 | ]
|
125 | }]
|
126 | ]
|
127 | }, {
|
128 |
|
129 | 'include_dirs': [
|
130 | '<(sharp_libvips_include_dir)',
|
131 | '<(sharp_libvips_include_dir)/glib-2.0',
|
132 | '<(sharp_libvips_lib_dir)/glib-2.0/include'
|
133 | ],
|
134 | 'library_dirs': [
|
135 | '<(sharp_libvips_lib_dir)'
|
136 | ],
|
137 | 'conditions': [
|
138 | ['OS == "win"', {
|
139 | 'defines': [
|
140 | '_ALLOW_KEYWORD_MACROS',
|
141 | '_FILE_OFFSET_BITS=64'
|
142 | ],
|
143 | 'link_settings': {
|
144 | 'libraries': [
|
145 | 'libvips.lib'
|
146 | ]
|
147 | }
|
148 | }],
|
149 | ['OS == "mac"', {
|
150 | 'link_settings': {
|
151 | 'libraries': [
|
152 | 'libvips-cpp.42.dylib'
|
153 | ]
|
154 | },
|
155 | 'xcode_settings': {
|
156 | 'OTHER_LDFLAGS': [
|
157 |
|
158 | '-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
159 | '-Wl,-rpath,\'@loader_path/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
160 | '-Wl,-rpath,\'@loader_path/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
161 | '-Wl,-rpath,\'@loader_path/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
162 | '-Wl,-rpath,\'@loader_path/../../../../../@img-sharp-libvips-<(platform_and_arch)-npm-<(sharp_libvips_version)-<(sharp_libvips_yarn_locator)/node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
163 | ]
|
164 | }
|
165 | }],
|
166 | ['OS == "linux"', {
|
167 | 'defines': [
|
168 | '_GLIBCXX_USE_CXX11_ABI=1'
|
169 | ],
|
170 | 'link_settings': {
|
171 | 'libraries': [
|
172 | '-l:libvips-cpp.so.42'
|
173 | ],
|
174 | 'ldflags': [
|
175 | '-Wl,-s',
|
176 | '-Wl,--disable-new-dtags',
|
177 | '-Wl,-z,nodelete',
|
178 | '-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
179 | '-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
180 | '-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
181 | '-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
182 | '-Wl,-rpath,\'$$ORIGIN/../../../../../@img-sharp-libvips-<(platform_and_arch)-npm-<(sharp_libvips_version)-<(sharp_libvips_yarn_locator)/node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
183 | ]
|
184 | }
|
185 | }],
|
186 | ['OS == "emscripten"', {
|
187 | 'product_extension': 'node.js',
|
188 | 'link_settings': {
|
189 | 'ldflags': [
|
190 | '-fexceptions',
|
191 | '--pre-js=<!(node -p "require.resolve(\'./emscripten/pre.js\')")',
|
192 | '-Oz',
|
193 | '-sALLOW_MEMORY_GROWTH',
|
194 | '-sENVIRONMENT=node',
|
195 | '-sEXPORTED_FUNCTIONS=["emnapiInit", "_vips_shutdown", "_uv_library_shutdown"]',
|
196 | '-sNODERAWFS',
|
197 | '-sTEXTDECODER=0',
|
198 | '-sWASM_ASYNC_COMPILATION=0',
|
199 | '-sWASM_BIGINT'
|
200 | ],
|
201 | 'libraries': [
|
202 | '<!@(PKG_CONFIG_PATH="<!(node -p "require(\'@img/sharp-libvips-dev-wasm32/lib\')")/pkgconfig" pkg-config --static --libs vips-cpp)'
|
203 | ],
|
204 | }
|
205 | }]
|
206 | ]
|
207 | }]
|
208 | ],
|
209 | 'cflags_cc': [
|
210 | '-std=c++0x',
|
211 | '-fexceptions',
|
212 | '-Wall',
|
213 | '-Os'
|
214 | ],
|
215 | 'xcode_settings': {
|
216 | 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
|
217 | 'MACOSX_DEPLOYMENT_TARGET': '10.13',
|
218 | 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
219 | 'GCC_ENABLE_CPP_RTTI': 'YES',
|
220 | 'OTHER_CPLUSPLUSFLAGS': [
|
221 | '-fexceptions',
|
222 | '-Wall',
|
223 | '-Oz'
|
224 | ]
|
225 | },
|
226 | 'configurations': {
|
227 | 'Release': {
|
228 | 'conditions': [
|
229 | ['target_arch == "arm"', {
|
230 | 'cflags_cc': [
|
231 | '-Wno-psabi'
|
232 | ]
|
233 | }],
|
234 | ['OS == "win"', {
|
235 | 'msvs_settings': {
|
236 | 'VCCLCompilerTool': {
|
237 | 'ExceptionHandling': 1,
|
238 | 'Optimization': 1,
|
239 | 'WholeProgramOptimization': 'true'
|
240 | },
|
241 | 'VCLibrarianTool': {
|
242 | 'AdditionalOptions': [
|
243 | '/LTCG:INCREMENTAL'
|
244 | ]
|
245 | },
|
246 | 'VCLinkerTool': {
|
247 | 'ImageHasSafeExceptionHandlers': 'false',
|
248 | 'OptimizeReferences': 2,
|
249 | 'EnableCOMDATFolding': 2,
|
250 | 'LinkIncremental': 1,
|
251 | 'AdditionalOptions': [
|
252 | '/LTCG:INCREMENTAL'
|
253 | ]
|
254 | }
|
255 | },
|
256 | 'msvs_disabled_warnings': [
|
257 | 4275
|
258 | ]
|
259 | }]
|
260 | ]
|
261 | }
|
262 | },
|
263 | }, {
|
264 | 'target_name': 'copy-dll',
|
265 | 'type': 'none',
|
266 | 'dependencies': [
|
267 | 'sharp-<(platform_and_arch)'
|
268 | ],
|
269 | 'conditions': [
|
270 | ['OS == "win"', {
|
271 | 'copies': [{
|
272 | 'destination': 'build/Release',
|
273 | 'files': [
|
274 | '<(sharp_libvips_lib_dir)/libvips-42.dll'
|
275 | ]
|
276 | }]
|
277 | }]
|
278 | ]
|
279 | }]
|
280 | }
|