7
7
import distutils .core
8
8
import re
9
9
10
+ def update_uvh (tmp_dir , header_files ):
11
+ for file in header_files :
12
+ header_f = os .path .join (tmp_dir , 'node' , 'src' , file )
13
+ rfile = open (header_f , 'r' )
14
+ old = rfile .read ()
15
+ new = re .sub ('third_party/node/deps/uv/include/uv.h' , 'uv.h' , old , 0 )
16
+ wfile = open (header_f , 'w' )
17
+ wfile .write (new )
18
+ wfile .close ()
19
+ return
20
+
10
21
script_dir = os .path .dirname (__file__ )
11
22
nw_root = os .path .normpath (os .path .join (script_dir , os .pardir ))
12
23
project_root = os .path .normpath (os .path .join (nw_root , os .pardir , os .pardir ))
21
32
'''
22
33
if '-t' in sys .argv :
23
34
nw_version = sys .argv [sys .argv .index ('-t' ) + 1 ]
24
- tarname = 'node -v' + nw_version + '.tar.gz'
35
+ tarname = 'nw-headers -v' + nw_version + '.tar.gz'
25
36
tarpath = os .path .join (tmp_dir , tarname )
26
37
27
38
#make tmpdir
71
82
if os .path .exists (os .path .join (tmp_dir , 'node' , 'deps' , 'npm' , 'node_modules' )):
72
83
shutil .rmtree (os .path .join (tmp_dir , 'node' , 'deps' , 'npm' , 'node_modules' ))
73
84
74
- rfile = open (os .path .join (tmp_dir , 'node' , 'src' , 'node.h' ), 'r' )
75
- filer = rfile .read ()
76
- sub = re .sub ('third_party/node/deps/uv/include/uv.h' , 'uv.h' , filer , 0 )
77
- rfile .close ()
78
- wfile = open (os .path .join (tmp_dir , 'node' , 'src' , 'node.h' ), 'w' )
79
- wfile .write (sub )
80
- wfile .close ()
85
+ header_files = ['node.h' , 'env.h' , 'env-inl.h' ]
86
+ update_uvh (tmp_dir , header_files )
81
87
82
88
print 'copy file end'
83
89
print 'Begin compress file'
84
90
85
- tar = tarfile .open (tarpath , 'w:gz' )
86
- for dirpath , dirnames , filenames in os .walk (tmp_dir ):
87
- for name in filenames :
88
- path = os .path .normpath (os .path .join (dirpath , name ))
89
- tar .add (path , path .replace (tmp_dir + os .sep , '' ))
90
- tar .close ()
91
- print 'compress end'
91
+ with tarfile .open (tarpath , 'w:gz' ) as tar :
92
+ tar .add (os .path .join (tmp_dir , 'node' ), arcname = 'node' )
93
+
94
+ print 'compress end'
0 commit comments