|
10 | 10 | project_root = os.path.normpath(os.path.join(nw_root, os.pardir, os.pardir));
|
11 | 11 | #default project path
|
12 | 12 | 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 = [] |
14 | 20 |
|
15 | 21 | #parse command line arguments
|
16 | 22 | """
|
|
56 | 62 | print 'nw file does not exist.\n'
|
57 | 63 | exit()
|
58 | 64 |
|
| 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 | + |
59 | 76 | required_file_linux = (
|
60 | 77 | 'nw',
|
61 | 78 | 'nw.pak',
|
|
78 | 95 | 'nwsnapshot',
|
79 | 96 | )
|
80 | 97 |
|
| 98 | +required_chromedriver2_file_win = ( |
| 99 | + 'chromedriver2_server.exe', |
| 100 | +) |
| 101 | + |
| 102 | +required_chromedriver2_file_others = ( |
| 103 | + 'chromedriver2_server', |
| 104 | +) |
81 | 105 |
|
82 | 106 | 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) |
84 | 109 |
|
85 | 110 | 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); |
87 | 113 |
|
88 | 114 | 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 | + |
90 | 118 |
|
91 | 119 | #generate binary tar name
|
92 | 120 | import getnwisrelease
|
|
108 | 136 | if (platform_name == 'win' or platform_name == 'osx'):
|
109 | 137 | arch = 'ia32'
|
110 | 138 |
|
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') |
115 | 144 |
|
116 | 145 | #use zip in mac and windows
|
117 | 146 | 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' |
119 | 149 |
|
120 | 150 |
|
121 | 151 | #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')) |
128 | 156 |
|
| 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]) |
129 | 160 |
|
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])) |
132 | 164 |
|
| 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]) |
133 | 168 |
|
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]) |
138 | 171 |
|
139 | 172 |
|
140 | 173 | #copy file to binary
|
141 | 174 | 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)) |
149 | 183 |
|
150 | 184 | print 'copy file end.\n'
|
151 | 185 |
|
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]) |
155 | 189 |
|
156 | 190 | print 'Begin compress file'
|
157 | 191 |
|
158 |
| - |
159 | 192 | if platform_name in ('win', 'osx'):
|
160 | 193 | """
|
161 | 194 | If there are sub directors, this should be modified
|
162 | 195 | """
|
163 | 196 | 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) |
166 | 200 |
|
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, '')) |
171 | 205 |
|
172 |
| - zip.close() |
| 206 | + zip.close() |
173 | 207 |
|
174 | 208 | 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() |
178 | 213 |
|
179 | 214 |
|
180 | 215 | print 'compress file end.\n'
|
181 | 216 |
|
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])) |
185 | 220 |
|
186 | 221 |
|
0 commit comments