10
10
import os
11
11
import re
12
12
import shutil
13
+ import stat
13
14
import sys
14
15
15
16
# set at init time
@@ -126,6 +127,48 @@ def subdir_files(path, dest, action):
126
127
for subdir , files in ret .items ():
127
128
action (files , subdir + '/' )
128
129
130
+ def build_tick_processor (action ):
131
+ tmp_script = 'out/Release/tick-processor'
132
+ if action == install :
133
+ # construct script
134
+ scripts = [
135
+ 'tools/v8-prof/polyfill.js' ,
136
+ 'deps/v8/tools/splaytree.js' ,
137
+ 'deps/v8/tools/codemap.js' ,
138
+ 'deps/v8/tools/csvparser.js' ,
139
+ 'deps/v8/tools/consarray.js' ,
140
+ 'deps/v8/tools/csvparser.js' ,
141
+ 'deps/v8/tools/consarray.js' ,
142
+ 'deps/v8/tools/profile.js' ,
143
+ 'deps/v8/tools/profile_view.js' ,
144
+ 'deps/v8/tools/logreader.js' ,
145
+ 'deps/v8/tools/tickprocessor.js' ,
146
+ 'deps/v8/tools/SourceMap.js' ,
147
+ 'deps/v8/tools/tickprocessor-driver.js' ]
148
+ args = []
149
+ if sys .platform == 'win32' :
150
+ args .append ('--windows' )
151
+ elif sys .platform == 'darwin' :
152
+ args .append ('--nm=' + abspath (install_path , 'share/doc/node' ) + '/mac-nm' )
153
+ args .append ('--mac' )
154
+ with open (tmp_script , 'w' ) as out_file :
155
+ # Add #! line to run with node
156
+ out_file .write ('#! ' + abspath (install_path , 'bin/node' ) + '\n ' )
157
+ # inject arguments
158
+ for arg in args :
159
+ out_file .write ('process.argv.splice(2, 0, \' ' + arg + '\' );\n ' )
160
+ # cat in source files
161
+ for script in scripts :
162
+ with open (script ) as in_file :
163
+ shutil .copyfileobj (in_file , out_file )
164
+ # make executable
165
+ st = os .stat (tmp_script )
166
+ os .chmod (tmp_script , st .st_mode | stat .S_IEXEC )
167
+ # perform installations
168
+ action ([tmp_script ], 'share/doc/node/' )
169
+ if sys .platform == 'darwin' :
170
+ action (['deps/v8/tools/mac-nm' ], 'share/doc/node/' )
171
+
129
172
def files (action ):
130
173
is_windows = sys .platform == 'win32'
131
174
@@ -140,6 +183,8 @@ def files(action):
140
183
141
184
action (['deps/v8/tools/gdbinit' ], 'share/doc/node/' )
142
185
186
+ build_tick_processor (action )
187
+
143
188
if 'freebsd' in sys .platform or 'openbsd' in sys .platform :
144
189
action (['doc/node.1' ], 'man/man1/' )
145
190
else :
0 commit comments