| OLD | NEW |
| 1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 Google Inc. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import copy | 5 import copy |
| 6 import hashlib | 6 import hashlib |
| 7 import multiprocessing | 7 import multiprocessing |
| 8 import os.path | 8 import os.path |
| 9 import re | 9 import re |
| 10 import signal | 10 import signal |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 | 1312 |
| 1313 def OpenOutput(path, mode='w'): | 1313 def OpenOutput(path, mode='w'): |
| 1314 """Open |path| for writing, creating directories if necessary.""" | 1314 """Open |path| for writing, creating directories if necessary.""" |
| 1315 try: | 1315 try: |
| 1316 os.makedirs(os.path.dirname(path)) | 1316 os.makedirs(os.path.dirname(path)) |
| 1317 except OSError: | 1317 except OSError: |
| 1318 pass | 1318 pass |
| 1319 return open(path, mode) | 1319 return open(path, mode) |
| 1320 | 1320 |
| 1321 | 1321 |
| 1322 def CommandWithWrapper(cmd, wrappers, prog): |
| 1323 wrapper = wrappers.get(cmd, '') |
| 1324 if wrapper: |
| 1325 return wrapper + ' ' + prog |
| 1326 return prog |
| 1327 |
| 1328 |
| 1322 def GenerateOutputForConfig(target_list, target_dicts, data, params, | 1329 def GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1323 config_name): | 1330 config_name): |
| 1324 options = params['options'] | 1331 options = params['options'] |
| 1325 flavor = gyp.common.GetFlavor(params) | 1332 flavor = gyp.common.GetFlavor(params) |
| 1326 generator_flags = params.get('generator_flags', {}) | 1333 generator_flags = params.get('generator_flags', {}) |
| 1327 | 1334 |
| 1328 # generator_dir: relative path from pwd to where make puts build files. | 1335 # generator_dir: relative path from pwd to where make puts build files. |
| 1329 # Makes migrating from make to ninja easier, ninja doesn't put anything here. | 1336 # Makes migrating from make to ninja easier, ninja doesn't put anything here. |
| 1330 generator_dir = os.path.relpath(params['options'].generator_output or '.') | 1337 generator_dir = os.path.relpath(params['options'].generator_output or '.') |
| 1331 | 1338 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 | 1378 |
| 1372 cc_host = None | 1379 cc_host = None |
| 1373 cxx_host = None | 1380 cxx_host = None |
| 1374 cc_host_global_setting = None | 1381 cc_host_global_setting = None |
| 1375 cxx_host_global_setting = None | 1382 cxx_host_global_setting = None |
| 1376 | 1383 |
| 1377 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) | 1384 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) |
| 1378 make_global_settings = data[build_file].get('make_global_settings', []) | 1385 make_global_settings = data[build_file].get('make_global_settings', []) |
| 1379 build_to_root = gyp.common.InvertRelativePath(build_dir, | 1386 build_to_root = gyp.common.InvertRelativePath(build_dir, |
| 1380 options.toplevel_dir) | 1387 options.toplevel_dir) |
| 1388 flock = 'flock' |
| 1389 if flavor == 'mac': |
| 1390 flock = './gyp-mac-tool flock' |
| 1391 wrappers = {} |
| 1392 if flavor != 'win': |
| 1393 wrappers['LINK'] = flock + ' linker.lock' |
| 1381 for key, value in make_global_settings: | 1394 for key, value in make_global_settings: |
| 1382 if key == 'CC': | 1395 if key == 'CC': |
| 1383 cc = os.path.join(build_to_root, value) | 1396 cc = os.path.join(build_to_root, value) |
| 1384 if key == 'CXX': | 1397 if key == 'CXX': |
| 1385 cxx = os.path.join(build_to_root, value) | 1398 cxx = os.path.join(build_to_root, value) |
| 1386 if key == 'LD': | 1399 if key == 'LD': |
| 1387 ld = os.path.join(build_to_root, value) | 1400 ld = os.path.join(build_to_root, value) |
| 1388 if key == 'CC.host': | 1401 if key == 'CC.host': |
| 1389 cc_host = os.path.join(build_to_root, value) | 1402 cc_host = os.path.join(build_to_root, value) |
| 1390 cc_host_global_setting = value | 1403 cc_host_global_setting = value |
| 1391 if key == 'CXX.host': | 1404 if key == 'CXX.host': |
| 1392 cxx_host = os.path.join(build_to_root, value) | 1405 cxx_host = os.path.join(build_to_root, value) |
| 1393 cxx_host_global_setting = value | 1406 cxx_host_global_setting = value |
| 1394 if key == 'LD.host': | 1407 if key == 'LD.host': |
| 1395 ld_host = os.path.join(build_to_root, value) | 1408 ld_host = os.path.join(build_to_root, value) |
| 1409 if key.endswith('_wrapper'): |
| 1410 wrappers[key[:-len('_wrapper')]] = os.path.join(build_to_root, value) |
| 1396 | 1411 |
| 1397 flock = 'flock' | |
| 1398 if flavor == 'mac': | |
| 1399 flock = './gyp-mac-tool flock' | |
| 1400 cc = GetEnvironFallback(['CC_target', 'CC'], cc) | 1412 cc = GetEnvironFallback(['CC_target', 'CC'], cc) |
| 1401 master_ninja.variable('cc', cc) | 1413 master_ninja.variable('cc', CommandWithWrapper('CC', wrappers, cc)) |
| 1402 cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx) | 1414 cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx) |
| 1403 master_ninja.variable('cxx', cxx) | 1415 master_ninja.variable('cxx', CommandWithWrapper('CXX', wrappers, cxx)) |
| 1404 ld = GetEnvironFallback(['LD_target', 'LD'], ld) | 1416 ld = GetEnvironFallback(['LD_target', 'LD'], ld) |
| 1405 | 1417 |
| 1406 if not cc_host: | 1418 if not cc_host: |
| 1407 cc_host = cc | 1419 cc_host = cc |
| 1408 if not cxx_host: | 1420 if not cxx_host: |
| 1409 cxx_host = cxx | 1421 cxx_host = cxx |
| 1410 | 1422 |
| 1411 if flavor == 'win': | 1423 if flavor == 'win': |
| 1412 master_ninja.variable('ld', ld) | 1424 master_ninja.variable('ld', ld) |
| 1413 master_ninja.variable('idl', 'midl.exe') | 1425 master_ninja.variable('idl', 'midl.exe') |
| 1414 master_ninja.variable('ar', 'lib.exe') | 1426 master_ninja.variable('ar', 'lib.exe') |
| 1415 master_ninja.variable('rc', 'rc.exe') | 1427 master_ninja.variable('rc', 'rc.exe') |
| 1416 master_ninja.variable('asm', 'ml.exe') | 1428 master_ninja.variable('asm', 'ml.exe') |
| 1417 master_ninja.variable('mt', 'mt.exe') | 1429 master_ninja.variable('mt', 'mt.exe') |
| 1418 master_ninja.variable('use_dep_database', '1') | 1430 master_ninja.variable('use_dep_database', '1') |
| 1419 else: | 1431 else: |
| 1420 master_ninja.variable('ld', flock + ' linker.lock ' + ld) | 1432 master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld)) |
| 1421 master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar')) | 1433 master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar')) |
| 1422 | 1434 |
| 1423 master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar')) | 1435 master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar')) |
| 1424 cc_host = GetEnvironFallback(['CC_host'], cc_host) | 1436 cc_host = GetEnvironFallback(['CC_host'], cc_host) |
| 1425 cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) | 1437 cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) |
| 1426 ld_host = GetEnvironFallback(['LD_host'], ld_host) | 1438 ld_host = GetEnvironFallback(['LD_host'], ld_host) |
| 1427 | 1439 |
| 1428 # The environment variable could be used in 'make_global_settings', like | 1440 # The environment variable could be used in 'make_global_settings', like |
| 1429 # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. | 1441 # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. |
| 1430 if '$(CC)' in cc_host and cc_host_global_setting: | 1442 if '$(CC)' in cc_host and cc_host_global_setting: |
| 1431 cc_host = cc_host_global_setting.replace('$(CC)', cc) | 1443 cc_host = cc_host_global_setting.replace('$(CC)', cc) |
| 1432 if '$(CXX)' in cxx_host and cxx_host_global_setting: | 1444 if '$(CXX)' in cxx_host and cxx_host_global_setting: |
| 1433 cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) | 1445 cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) |
| 1434 master_ninja.variable('cc_host', cc_host) | 1446 master_ninja.variable('cc_host', cc_host) |
| 1435 master_ninja.variable('cxx_host', cxx_host) | 1447 master_ninja.variable('cxx_host', cxx_host) |
| 1436 if flavor == 'win': | 1448 if flavor == 'win': |
| 1437 master_ninja.variable('ld_host', ld_host) | 1449 master_ninja.variable('ld_host', ld_host) |
| 1438 else: | 1450 else: |
| 1439 master_ninja.variable('ld_host', flock + ' linker.lock ' + ld_host) | 1451 master_ninja.variable('ld_host', CommandWithWrapper( |
| 1452 'LINK', wrappers, ld_host)) |
| 1440 | 1453 |
| 1441 master_ninja.newline() | 1454 master_ninja.newline() |
| 1442 | 1455 |
| 1443 if flavor != 'win': | 1456 if flavor != 'win': |
| 1444 master_ninja.rule( | 1457 master_ninja.rule( |
| 1445 'cc', | 1458 'cc', |
| 1446 description='CC $out', | 1459 description='CC $out', |
| 1447 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' | 1460 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' |
| 1448 '$cflags_pch_c -c $in -o $out'), | 1461 '$cflags_pch_c -c $in -o $out'), |
| 1449 depfile='$out.d') | 1462 depfile='$out.d') |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 arglists.append( | 1795 arglists.append( |
| 1783 (target_list, target_dicts, data, params, config_name)) | 1796 (target_list, target_dicts, data, params, config_name)) |
| 1784 pool.map(CallGenerateOutputForConfig, arglists) | 1797 pool.map(CallGenerateOutputForConfig, arglists) |
| 1785 except KeyboardInterrupt, e: | 1798 except KeyboardInterrupt, e: |
| 1786 pool.terminate() | 1799 pool.terminate() |
| 1787 raise e | 1800 raise e |
| 1788 else: | 1801 else: |
| 1789 for config_name in config_names: | 1802 for config_name in config_names: |
| 1790 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1803 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1791 config_name) | 1804 config_name) |
| OLD | NEW |