Skip to content

Commit b940e0f

Browse files
committedFeb 20, 2014
gyp: specialize node.d for freebsd
`node.d` should use `psinfo.d` instead of `procfs.d` and have statically defined architecture on FreeBSD.
1 parent 085db9d commit b940e0f

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed
 

‎node.gyp

+32-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,12 @@
159159
}],
160160
[ 'node_use_dtrace=="true"', {
161161
'defines': [ 'HAVE_DTRACE=1' ],
162-
'dependencies': [ 'node_dtrace_header' ],
162+
'dependencies': [
163+
'node_dtrace_header',
164+
'specialize_node_d',
165+
],
163166
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
167+
164168
#
165169
# DTrace is supported on solaris, mac, and bsd. There are three
166170
# object files associated with DTrace support, but they're not all
@@ -482,10 +486,36 @@
482486
]
483487
} ],
484488
]
485-
}
489+
},
486490
]
487491
} ],
488492
]
493+
},
494+
{
495+
'target_name': 'specialize_node_d',
496+
'type': 'none',
497+
'conditions': [
498+
[ 'node_use_dtrace=="true"', {
499+
'actions': [
500+
{
501+
'action_name': 'specialize_node_d',
502+
'inputs': [
503+
'src/node.d'
504+
],
505+
'outputs': [
506+
'<(PRODUCT_DIR)/node.d',
507+
],
508+
'action': [
509+
'tools/specialize_node_d.py',
510+
'<@(_outputs)',
511+
'<@(_inputs)',
512+
'<@(OS)',
513+
'<@(target_arch)',
514+
],
515+
},
516+
],
517+
} ],
518+
]
489519
}
490520
] # end targets
491521
}

‎tools/install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def files(action):
132132
# install unconditionally, checking if the platform supports dtrace doesn't
133133
# work when cross-compiling and besides, there's at least one linux flavor
134134
# with dtrace support now (oracle's "unbreakable" linux)
135-
action(['src/node.d'], 'lib/dtrace/')
135+
action(['out/Release/node.d'], 'lib/dtrace/node.d')
136136

137137
if 'freebsd' in sys.platform or 'openbsd' in sys.platform:
138138
action(['doc/node.1'], 'man/man1/')

‎tools/specialize_node_d.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
#
4+
# specialize_node_d.py output_file src/node.d flavor arch
5+
#
6+
# Specialize node.d for given flavor (`freebsd`) and arch (`x64` or `ia32`)
7+
#
8+
9+
import re
10+
import subprocess
11+
import sys
12+
import errno
13+
14+
if len(sys.argv) != 5:
15+
print "usage: specialize_node_d.py outfile src/node.d flavor arch"
16+
sys.exit(2);
17+
18+
outfile = file(sys.argv[1], 'w');
19+
infile = file(sys.argv[2], 'r');
20+
flavor = sys.argv[3];
21+
arch = sys.argv[4];
22+
23+
model = r'curpsinfo->pr_dmodel == PR_MODEL_ILP32'
24+
25+
for line in infile:
26+
if flavor == 'freebsd':
27+
line = re.sub('procfs.d', 'psinfo.d', line);
28+
if arch == 'x64':
29+
line = re.sub(model, '0', line);
30+
else:
31+
line = re.sub(model, '1', line);
32+
outfile.write(line);

0 commit comments

Comments
 (0)
Please sign in to comment.