OLD | NEW |
1 # -*- python -*- | 1 # -*- python -*- |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import atexit | 6 import atexit |
7 import glob | 7 import glob |
8 import os | 8 import os |
9 import platform | 9 import platform |
| 10 import shutil |
10 import stat | 11 import stat |
11 import subprocess | 12 import subprocess |
12 import sys | 13 import sys |
13 import zlib | 14 import zlib |
14 sys.path.append("./common") | 15 sys.path.append("./common") |
| 16 sys.path.append('../third_party') |
| 17 import simplejson |
15 | 18 |
16 from SCons.Errors import UserError | 19 from SCons.Errors import UserError |
17 from SCons.Script import GetBuildFailures | 20 from SCons.Script import GetBuildFailures |
18 | 21 |
19 import SCons.Warnings | 22 import SCons.Warnings |
20 import SCons.Util | 23 import SCons.Util |
21 | 24 |
22 SCons.Warnings.warningAsException() | 25 SCons.Warnings.warningAsException() |
23 | 26 |
24 sys.path.append("tools") | 27 sys.path.append("tools") |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 # been built in a previous invocation. | 1159 # been built in a previous invocation. |
1157 # TODO(ncbray) better 32/64 builds. | 1160 # TODO(ncbray) better 32/64 builds. |
1158 if env.Bit('windows'): | 1161 if env.Bit('windows'): |
1159 fn = env.subst(fn).abspath.replace('-win-x86-64', '-win-x86-32') | 1162 fn = env.subst(fn).abspath.replace('-win-x86-64', '-win-x86-32') |
1160 elif env.Bit('mac'): | 1163 elif env.Bit('mac'): |
1161 fn = env.subst(fn).abspath.replace('-mac-x86-64', '-mac-x86-32') | 1164 fn = env.subst(fn).abspath.replace('-mac-x86-64', '-mac-x86-32') |
1162 return fn | 1165 return fn |
1163 | 1166 |
1164 pre_base_env.AddMethod(GetPPAPIPluginPath) | 1167 pre_base_env.AddMethod(GetPPAPIPluginPath) |
1165 | 1168 |
| 1169 |
| 1170 # runnable-ld.so log has following format: |
| 1171 # lib_name => path_to_lib (0x....address) |
| 1172 def ParseLibInfoInRunnableLdLog(line): |
| 1173 pos = line.find(' => ') |
| 1174 if pos < 0: |
| 1175 return None |
| 1176 lib_name = line[:pos].strip() |
| 1177 lib_path = line[pos+4:] |
| 1178 pos1 = lib_path.rfind(' (') |
| 1179 if pos1 < 0: |
| 1180 return None |
| 1181 lib_path = lib_path[:pos1] |
| 1182 return lib_name, lib_path |
| 1183 |
| 1184 |
| 1185 # Copy libs and manifest to the target directory. |
| 1186 # source[0] is a manifest file |
| 1187 # source[1] is a .libs file with a list of libs generated by runnable-ld.so |
| 1188 def CopyLibsForExtensionCommand(target, source, env): |
| 1189 source_manifest = str(source[0]) |
| 1190 target_manifest = str(target[0]) |
| 1191 shutil.copyfile(source_manifest, target_manifest) |
| 1192 target_dir = os.path.dirname(target_manifest) |
| 1193 libs_file = open(str(source[1]), 'r') |
| 1194 for line in libs_file.readlines(): |
| 1195 lib_info = ParseLibInfoInRunnableLdLog(line) |
| 1196 if lib_info: |
| 1197 lib_name, lib_path = lib_info |
| 1198 shutil.copyfile(lib_path, os.path.join(target_dir, lib_name)) |
| 1199 shutil.copyfile(env.subst('${NACL_SDK_LIB}/runnable-ld.so'), |
| 1200 os.path.join(target_dir, 'runnable-ld.so')) |
| 1201 libs_file.close() |
| 1202 |
| 1203 |
| 1204 # Extensions are loaded from directory on disk and so all dynamic libraries |
| 1205 # they use must be copied to extension directory. The option --extra_serving_dir |
| 1206 # does not help us in this case. |
| 1207 def CopyLibsForExtension(env, target_dir, manifest): |
| 1208 if not env.Bit('nacl_glibc'): |
| 1209 return env.Install(target_dir, manifest) |
| 1210 manifest_base_name = os.path.basename(str(env.subst(manifest))) |
| 1211 lib_list_node = env.File('${STAGING_DIR}/' + manifest_base_name + '.libs') |
| 1212 nmf_node = env.Command( |
| 1213 target_dir + '/' + manifest_base_name, |
| 1214 [manifest, lib_list_node], |
| 1215 CopyLibsForExtensionCommand) |
| 1216 return nmf_node |
| 1217 |
| 1218 pre_base_env.AddMethod(CopyLibsForExtension) |
| 1219 |
| 1220 |
| 1221 # Generate manifest from newlib manifest and the list of libs generated by |
| 1222 # runnable-ld.so. |
| 1223 def GenerateManifestFunc(target, source, env): |
| 1224 source_file = open(str(source[0]), 'r') |
| 1225 obj = simplejson.load(source_file) |
| 1226 source_file.close() |
| 1227 libs_file = open(str(source[1]), 'r') |
| 1228 lib_names = [] |
| 1229 for line in libs_file.readlines(): |
| 1230 lib_info = ParseLibInfoInRunnableLdLog(line) |
| 1231 if lib_info: |
| 1232 lib_name, _ = lib_info |
| 1233 lib_names.append(lib_name) |
| 1234 libs_file.close() |
| 1235 if 'files' not in obj: |
| 1236 obj['files'] = {} |
| 1237 for lib_name in lib_names: |
| 1238 obj['files']['lib/' + lib_name] = {} |
| 1239 obj['files']['lib/' + lib_name]['portable'] = {} |
| 1240 obj['files']['lib/' + lib_name]['portable']['url'] = lib_name |
| 1241 obj['files']['main.nexe'] = {} |
| 1242 for k, v in obj['program'].items(): |
| 1243 obj['files']['main.nexe'][k] = v.copy() |
| 1244 v['url'] = 'runnable-ld.so' |
| 1245 target_file = open(str(target[0]), 'w') |
| 1246 simplejson.dump(obj, target_file) |
| 1247 target_file.close() |
| 1248 return 0 |
| 1249 |
| 1250 |
| 1251 # Returns nexe specified in manifest file. |
| 1252 def GetNexeFromManifest(env, manifest): |
| 1253 manifest_file = open(str(env.File(manifest)), 'r') |
| 1254 obj = simplejson.load(manifest_file) |
| 1255 manifest_file.close() |
| 1256 nexe = obj['program'][env.subst('${TARGET_FULLARCH}')]['url'] |
| 1257 return nexe |
| 1258 |
| 1259 manifest_map = {} |
| 1260 |
| 1261 |
| 1262 # Returns command line arguments for browser tester that add generated manifest |
| 1263 # to a list of files to serve. |
| 1264 def GenerateManifestCommands(env, manifest): |
| 1265 manifest = env.subst(manifest) |
| 1266 manifest_base_name = os.path.basename(manifest) |
| 1267 nexe = GetNexeFromManifest(env, manifest) |
| 1268 result = ['--file', env.File('${STAGING_DIR}/' + manifest_base_name)] |
| 1269 if not env.Bit('nacl_glibc'): |
| 1270 if manifest_base_name not in manifest_map: |
| 1271 env.Install('${STAGING_DIR}', manifest) |
| 1272 manifest_map[manifest_base_name] = nexe |
| 1273 # fall through |
| 1274 if manifest_base_name in manifest_map: |
| 1275 if manifest_map[manifest_base_name] != nexe: |
| 1276 print nexe |
| 1277 print manifest_map[manifest_base_name] |
| 1278 raise Exception("Two manifest files with the same name") |
| 1279 return result |
| 1280 manifest_map[manifest_base_name] = nexe |
| 1281 lib_list_node = env.Command( |
| 1282 '${STAGING_DIR}/' + manifest_base_name + '.libs', |
| 1283 [GetSelLdr(env), |
| 1284 '${NACL_SDK_LIB}/runnable-ld.so', |
| 1285 env.File('${STAGING_DIR}/' + os.path.basename(nexe)), |
| 1286 '${SCONSTRUCT_DIR}/DEPS'], |
| 1287 '${SOURCES[0]} -a -E LD_TRACE_LOADED_OBJECTS=1 ${SOURCES[1]} ' |
| 1288 '--library-path ${NACL_SDK_LIB}:${LIB_DIR} ${SOURCES[2].posix} ' |
| 1289 '> ${TARGET}') |
| 1290 nmf_node = env.Command( |
| 1291 '${STAGING_DIR}/' + manifest_base_name, |
| 1292 [manifest, lib_list_node], |
| 1293 GenerateManifestFunc) |
| 1294 return result |
| 1295 |
| 1296 |
1166 def PPAPIBrowserTester(env, | 1297 def PPAPIBrowserTester(env, |
1167 target, | 1298 target, |
1168 url, | 1299 url, |
1169 files, | 1300 files, |
| 1301 nmfs=None, |
1170 map_files=(), | 1302 map_files=(), |
1171 extensions=(), | 1303 extensions=(), |
1172 timeout=20, | 1304 timeout=20, |
1173 log_verbosity=2, | 1305 log_verbosity=2, |
1174 args=(), | 1306 args=(), |
1175 # list of key/value pairs that are passed to the test | 1307 # list of key/value pairs that are passed to the test |
1176 test_args=(), | 1308 test_args=(), |
1177 # list of "--flag=value" pairs (no spaces!) | 1309 # list of "--flag=value" pairs (no spaces!) |
1178 browser_flags=(), | 1310 browser_flags=(), |
1179 python_tester_script=None, | 1311 python_tester_script=None, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 command.extend(['--sel_ldr', GetSelLdr(env)]) | 1343 command.extend(['--sel_ldr', GetSelLdr(env)]) |
1212 if env.Bit('irt') and (not env.Bit('disable_dynamic_plugin_loading') or | 1344 if env.Bit('irt') and (not env.Bit('disable_dynamic_plugin_loading') or |
1213 env.Bit('override_chrome_irt')): | 1345 env.Bit('override_chrome_irt')): |
1214 command.extend(['--irt_library', env.GetIrtNexe()]) | 1346 command.extend(['--irt_library', env.GetIrtNexe()]) |
1215 for dep_file in files: | 1347 for dep_file in files: |
1216 command.extend(['--file', dep_file]) | 1348 command.extend(['--file', dep_file]) |
1217 for extension in extensions: | 1349 for extension in extensions: |
1218 command.extend(['--extension', extension]) | 1350 command.extend(['--extension', extension]) |
1219 for dest_path, dep_file in map_files: | 1351 for dest_path, dep_file in map_files: |
1220 command.extend(['--map_file', dest_path, dep_file]) | 1352 command.extend(['--map_file', dest_path, dep_file]) |
| 1353 command.extend(['--serving_dir', '${NACL_SDK_LIB}']) |
| 1354 command.extend(['--serving_dir', '${LIB_DIR}']) |
| 1355 if not nmfs is None: |
| 1356 for nmf_file in nmfs: |
| 1357 command.extend(GenerateManifestCommands(env, nmf_file)) |
1221 if 'browser_test_tool' in ARGUMENTS: | 1358 if 'browser_test_tool' in ARGUMENTS: |
1222 command.extend(['--tool', ARGUMENTS['browser_test_tool']]) | 1359 command.extend(['--tool', ARGUMENTS['browser_test_tool']]) |
1223 command.extend(args) | 1360 command.extend(args) |
1224 for flag in browser_flags: | 1361 for flag in browser_flags: |
1225 if flag.find(' ') != -1: | 1362 if flag.find(' ') != -1: |
1226 raise Exception('Spaces not allowed in browser_flags: ' | 1363 raise Exception('Spaces not allowed in browser_flags: ' |
1227 'use --flag=value instead') | 1364 'use --flag=value instead') |
1228 command.extend(['--browser_flag', flag]) | 1365 command.extend(['--browser_flag', flag]) |
1229 for key, value in test_args: | 1366 for key, value in test_args: |
1230 command.extend(['--test_arg', str(key), str(value)]) | 1367 command.extend(['--test_arg', str(key), str(value)]) |
(...skipping 10 matching lines...) Expand all Loading... |
1241 | 1378 |
1242 pre_base_env.AddMethod(PPAPIBrowserTester) | 1379 pre_base_env.AddMethod(PPAPIBrowserTester) |
1243 | 1380 |
1244 | 1381 |
1245 # Disabled for ARM because Chrome binaries for ARM are not available. | 1382 # Disabled for ARM because Chrome binaries for ARM are not available. |
1246 def PPAPIBrowserTesterIsBroken(env): | 1383 def PPAPIBrowserTesterIsBroken(env): |
1247 return env.Bit('target_arm') | 1384 return env.Bit('target_arm') |
1248 | 1385 |
1249 pre_base_env.AddMethod(PPAPIBrowserTesterIsBroken) | 1386 pre_base_env.AddMethod(PPAPIBrowserTesterIsBroken) |
1250 | 1387 |
1251 # 3D disabled for arm, newlib & pnacl | 1388 # 3D is disabled everywhere |
1252 def PPAPIGraphics3DIsBroken(env): | 1389 def PPAPIGraphics3DIsBroken(env): |
1253 return (env.Bit('target_arm') or | 1390 return True |
1254 not env.Bit('nacl_glibc') or | |
1255 env.Bit('bitcode')) | |
1256 | 1391 |
1257 pre_base_env.AddMethod(PPAPIGraphics3DIsBroken) | 1392 pre_base_env.AddMethod(PPAPIGraphics3DIsBroken) |
1258 | 1393 |
1259 | 1394 |
1260 def PyAutoTester(env, target, test, files=[], log_verbosity=2, | 1395 def PyAutoTester(env, target, test, files=[], log_verbosity=2, |
1261 extra_chrome_flags=[], args=[]): | 1396 extra_chrome_flags=[], args=[]): |
1262 if 'TRUSTED_ENV' not in env: | 1397 if 'TRUSTED_ENV' not in env: |
1263 return [] | 1398 return [] |
1264 | 1399 |
1265 env = env.Clone() | 1400 env = env.Clone() |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 # 32-bit test binaries are run on a 64-bit machine (because 32-bit python is not | 1492 # 32-bit test binaries are run on a 64-bit machine (because 32-bit python is not |
1358 # available on 64-bit machines). | 1493 # available on 64-bit machines). |
1359 # However, our Mac bots will have 32-bit versions of Python 2.5, even if they | 1494 # However, our Mac bots will have 32-bit versions of Python 2.5, even if they |
1360 # are 64-bit machines. Mac OS X 10.5 bots have 32-bit Python 2.5 installed as | 1495 # are 64-bit machines. Mac OS X 10.5 bots have 32-bit Python 2.5 installed as |
1361 # part of the OS. Mac OS X 10.6 bots have had 32-bit Python 2.5 manually | 1496 # part of the OS. Mac OS X 10.6 bots have had 32-bit Python 2.5 manually |
1362 # installed. | 1497 # installed. |
1363 # TODO(ncbray): check the architecture of the Python that we plan to run, | 1498 # TODO(ncbray): check the architecture of the Python that we plan to run, |
1364 # rather than the architecture of Python currently running. | 1499 # rather than the architecture of Python currently running. |
1365 def PyAutoTesterIsBroken(env): | 1500 def PyAutoTesterIsBroken(env): |
1366 return (PPAPIBrowserTesterIsBroken(env) | 1501 return (PPAPIBrowserTesterIsBroken(env) |
| 1502 or env.Bit('nacl_glibc') |
1367 or (not env.Bit('host_mac') | 1503 or (not env.Bit('host_mac') |
1368 and env.Bit('build_x86_32') | 1504 and env.Bit('build_x86_32') |
1369 and platform.architecture()[0] == '64bit')) | 1505 and platform.architecture()[0] == '64bit')) |
1370 | 1506 |
1371 pre_base_env.AddMethod(PyAutoTesterIsBroken) | 1507 pre_base_env.AddMethod(PyAutoTesterIsBroken) |
1372 | 1508 |
1373 | 1509 |
1374 # Disable async surfaway pyauto test suite on newlib until issues it raises on | 1510 # Disable async surfaway pyauto test suite on newlib until issues it raises on |
1375 # bots are fixed. TODO(nfullagar): re-enable when this suite for newlib when it | 1511 # bots are fixed. TODO(nfullagar): re-enable when this suite for newlib when it |
1376 # won't break the bots. | 1512 # won't break the bots. |
(...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3277 nacl_env.ValidateSdk() | 3413 nacl_env.ValidateSdk() |
3278 | 3414 |
3279 if BROKEN_TEST_COUNT > 0: | 3415 if BROKEN_TEST_COUNT > 0: |
3280 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3416 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3281 if GetOption('brief_comstr'): | 3417 if GetOption('brief_comstr'): |
3282 msg += " Add --verbose to the command line for more information." | 3418 msg += " Add --verbose to the command line for more information." |
3283 print msg | 3419 print msg |
3284 | 3420 |
3285 # separate warnings from actual build output | 3421 # separate warnings from actual build output |
3286 Banner('B U I L D - O U T P U T:') | 3422 Banner('B U I L D - O U T P U T:') |
OLD | NEW |