@@ -33,6 +33,7 @@ function configure (gyp, argv, callback) {
33
33
, buildDir = path . resolve ( 'build' )
34
34
, configNames = [ 'config.gypi' , 'common.gypi' ]
35
35
, configs = [ ]
36
+ , post_configs = [ ]
36
37
, nodeDir
37
38
, release = processRelease ( argv , gyp , process . version , process . release )
38
39
@@ -110,20 +111,35 @@ function configure (gyp, argv, callback) {
110
111
111
112
var configFilename = 'config.gypi'
112
113
var configPath = path . resolve ( buildDir , configFilename )
114
+ var postConfigFilename = 'post_config.gypi'
115
+ var postConfigPath = path . resolve ( buildDir , postConfigFilename )
113
116
114
117
log . verbose ( 'build/' + configFilename , 'creating config file' )
115
118
116
119
var config = process . config || { }
117
120
, defaults = config . target_defaults
118
121
, variables = config . variables
122
+ , fallback_target_defaults = { }
119
123
120
124
// default "config.variables"
121
125
if ( ! variables ) variables = config . variables = { }
122
126
123
127
// default "config.defaults"
124
128
if ( ! defaults ) defaults = config . target_defaults = { }
125
129
126
- // don't inherit the "defaults" from node's `process.config` object.
130
+ if ( variables . node_shared_cares ||
131
+ variables . node_shared_http_parser ||
132
+ variables . node_shared_libuv ||
133
+ variables . node_shared_openssl ||
134
+ variables . node_shared_zlib ) {
135
+ Object . keys ( defaults ) . forEach ( function ( entry ) {
136
+ if ( entry in { 'cflags' : 1 , 'defines' : 1 , 'include_dirs' : 1 , 'libraries' : 1 } ) {
137
+ fallback_target_defaults [ entry ] = defaults [ entry ]
138
+ }
139
+ } )
140
+ }
141
+ // if node engine does not have to rely on shared libraries in the system
142
+ // do not inherit the "defaults" from node's `process.config` object.
127
143
// doing so could cause problems in cases where the `node` executable was
128
144
// compiled on a different machine (with different lib/include paths) than
129
145
// the machine where the addon is being built to
@@ -186,7 +202,17 @@ function configure (gyp, argv, callback) {
186
202
, json = JSON . stringify ( config , boolsToString , 2 )
187
203
log . verbose ( 'build/' + configFilename , 'writing out config file: %s' , configPath )
188
204
configs . push ( configPath )
189
- fs . writeFile ( configPath , [ prefix , json , '' ] . join ( '\n' ) , findConfigs )
205
+ fs . writeFile ( configPath , [ prefix , json , '' ] . join ( '\n' ) , function ( ) {
206
+
207
+ var config = {
208
+ "target_defaults" : fallback_target_defaults
209
+ }
210
+ , prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step'
211
+ , json = JSON . stringify ( config , boolsToString , 2 )
212
+ log . verbose ( 'build/' + postConfigFilename , 'writing out config file: %s' , postConfigPath )
213
+ post_configs . push ( postConfigPath )
214
+ fs . writeFile ( postConfigPath , [ prefix , json , '' ] . join ( '\n' ) , findConfigs )
215
+ } )
190
216
}
191
217
192
218
function findConfigs ( err ) {
@@ -291,6 +317,9 @@ function configure (gyp, argv, callback) {
291
317
292
318
argv . push ( '-I' , addon_gypi )
293
319
argv . push ( '-I' , common_gypi )
320
+ post_configs . forEach ( function ( config ) {
321
+ argv . push ( '-I' , config )
322
+ } )
294
323
argv . push ( '-Dlibrary=shared_library' )
295
324
argv . push ( '-Dvisibility=default' )
296
325
argv . push ( '-Dnode_root_dir=' + nodeDir )
0 commit comments