Skip to content

Commit cc48f72

Browse files
committed
Merge pull request nwjs#991 from kingFighter/tools
Make the 'dist' build target depends on 'chromedriver2_server' target.
2 parents 22cf51d + ee6e6b5 commit cc48f72

File tree

2 files changed

+84
-45
lines changed

2 files changed

+84
-45
lines changed

nw.gypi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@
404404
'action': ['python', '<(package_script)'],
405405
},
406406
],
407+
'dependencies': [
408+
'<(DEPTH)/chrome/chrome.gyp:chromedriver2_server',
409+
],
410+
407411
},
408412
{
409413
'target_name': 'nw',

tools/package_binaries.py

Lines changed: 80 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
project_root = os.path.normpath(os.path.join(nw_root, os.pardir, os.pardir));
1111
#default project path
1212
project_root = os.path.join(project_root, 'out', 'Release')
13-
13+
required_file = []
14+
tarname = []
15+
binary_name = []
16+
binary_tar = []
17+
binary_store_path = []
18+
binary_full_path = []
19+
binary_tar_full_path = []
1420

1521
#parse command line arguments
1622
"""
@@ -56,6 +62,17 @@
5662
print 'nw file does not exist.\n'
5763
exit()
5864

65+
if platform_name != 'win' and not os.path.exists(
66+
os.path.join(project_root, 'chromedriver2_server')):
67+
print 'chromedriver2_server file does not exist.\n'
68+
exit()
69+
70+
if platform_name == 'win' and not os.path.exists(
71+
os.path.join(project_root, 'chromedriver2_server.exe')):
72+
print 'chromedriver2_server file does not exist.\n'
73+
exit()
74+
75+
5976
required_file_linux = (
6077
'nw',
6178
'nw.pak',
@@ -78,15 +95,26 @@
7895
'nwsnapshot',
7996
)
8097

98+
required_chromedriver2_file_win = (
99+
'chromedriver2_server.exe',
100+
)
101+
102+
required_chromedriver2_file_others = (
103+
'chromedriver2_server',
104+
)
81105

82106
if (platform_name == 'linux'):
83-
required_file = required_file_linux
107+
required_file.append(required_file_linux)
108+
required_file.append(required_chromedriver2_file_others)
84109

85110
if (platform_name == 'win'):
86-
required_file = required_file_win
111+
required_file.append(required_file_win)
112+
required_file.append(required_chromedriver2_file_win);
87113

88114
if (platform_name == 'osx'):
89-
required_file = required_file_mac
115+
required_file.append(required_file_mac)
116+
required_file.append(required_chromedriver2_file_others)
117+
90118

91119
#generate binary tar name
92120
import getnwisrelease
@@ -108,79 +136,86 @@
108136
if (platform_name == 'win' or platform_name == 'osx'):
109137
arch = 'ia32'
110138

111-
tarname = 'node-webkit-' + nw_version
112-
113-
binary_name = tarname + '-' + platform_name + '-' + arch
114-
binary_tar = binary_name + '.tar.gz'
139+
tarname.append('node-webkit-' + nw_version)
140+
tarname.append('chromedriver2-nw-' + nw_version)
141+
for index in range(len(tarname)):
142+
binary_name.append(tarname[index] + '-' + platform_name + '-' + arch);
143+
binary_tar.append(binary_name[index] + '.tar.gz')
115144

116145
#use zip in mac and windows
117146
if platform_name in ('win', 'osx'):
118-
binary_tar = binary_name + '.zip'
147+
for index in range(len(binary_name)):
148+
binary_tar[index] = binary_name[index] + '.zip'
119149

120150

121151
#make directory for binary_tar
122-
binary_store_path = os.path.join(project_root,
123-
'node-webkit-binaries')
124-
125-
126-
if not os.path.exists(binary_store_path):
127-
os.mkdir(binary_store_path)
152+
binary_store_path.append(os.path.join(project_root,
153+
'node-webkit-binaries'))
154+
binary_store_path.append(os.path.join(project_root,
155+
'chromedriver2-binaries'))
128156

157+
for index in range(len(binary_store_path)):
158+
if not os.path.exists(binary_store_path[index]):
159+
os.mkdir(binary_store_path[index])
129160

130-
binary_full_path = os.path.join(binary_store_path, binary_name)
131-
binary_tar_full_path = os.path.join(binary_store_path, binary_tar)
161+
for index in range(len(binary_store_path)):
162+
binary_full_path.append(os.path.join(binary_store_path[index], binary_name[index]))
163+
binary_tar_full_path.append(os.path.join(binary_store_path[index], binary_tar[index]))
132164

165+
for index in range(len(binary_full_path)):
166+
if os.path.exists(binary_full_path[index]):
167+
shutil.rmtree(binary_full_path[index])
133168

134-
if os.path.exists(binary_full_path):
135-
shutil.rmtree(binary_full_path)
136-
137-
os.mkdir(binary_full_path)
169+
for index in range(len(binary_full_path)):
170+
os.mkdir(binary_full_path[index])
138171

139172

140173
#copy file to binary
141174
print 'Begin copy file.'
142-
for file in required_file:
143-
try:
144-
shutil.copy(os.path.join(project_root, file),
145-
os.path.join(binary_full_path, file))
146-
except:
147-
shutil.copytree(os.path.join(project_root, file),
148-
os.path.join(binary_full_path, file))
175+
for index in range(len(required_file)):
176+
for file in required_file[index]:
177+
try:
178+
shutil.copy(os.path.join(project_root, file),
179+
os.path.join(binary_full_path[index], file))
180+
except:
181+
shutil.copytree(os.path.join(project_root, file),
182+
os.path.join(binary_full_path[index], file))
149183

150184
print 'copy file end.\n'
151185

152-
if (os.path.isfile(binary_tar_full_path)):
153-
os.remove(binary_tar_full_path)
154-
186+
for index in range(len(binary_tar_full_path)):
187+
if (os.path.isfile(binary_tar_full_path[index])):
188+
os.remove(binary_tar_full_path[index])
155189

156190
print 'Begin compress file'
157191

158-
159192
if platform_name in ('win', 'osx'):
160193
"""
161194
If there are sub directors, this should be modified
162195
"""
163196
import zipfile
164-
zip = zipfile.ZipFile(binary_tar_full_path, 'w',
165-
compression=zipfile.ZIP_DEFLATED)
197+
for index in range(len(binary_tar_full_path)):
198+
zip = zipfile.ZipFile(binary_tar_full_path[index], 'w',
199+
compression=zipfile.ZIP_DEFLATED)
166200

167-
for dirpath, dirnames, filenames in os.walk(binary_full_path):
168-
for name in filenames:
169-
path = os.path.normpath(os.path.join(dirpath, name))
170-
zip.write(path, path.replace(binary_full_path+os.sep, ''))
201+
for dirpath, dirnames, filenames in os.walk(binary_full_path[index]):
202+
for name in filenames:
203+
path = os.path.normpath(os.path.join(dirpath, name))
204+
zip.write(path, path.replace(binary_full_path[index] + os.sep, ''))
171205

172-
zip.close()
206+
zip.close()
173207

174208
else:
175-
tar = tarfile.open(binary_tar_full_path, 'w:gz')
176-
tar.add(binary_full_path, os.path.basename(binary_full_path))
177-
tar.close()
209+
for index in range(len(binary_tar_full_path)):
210+
tar = tarfile.open(binary_tar_full_path[index], 'w:gz')
211+
tar.add(binary_full_path[index], os.path.basename(binary_full_path[index]))
212+
tar.close()
178213

179214

180215
print 'compress file end.\n'
181216

182-
183-
print 'the binaries files store in path:', os.path.normpath(
184-
os.path.join(os.getcwd(), binary_store_path))
217+
for index in range(len(binary_store_path)):
218+
print 'the binaries files store in path:', os.path.normpath(
219+
os.path.join(os.getcwd(), binary_store_path[index]))
185220

186221

0 commit comments

Comments
 (0)