UNPKG

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