Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 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 gyp | 6 import gyp |
| 7 import gyp.common | 7 import gyp.common |
| 8 import gyp.msvs_emulation | 8 import gyp.msvs_emulation |
| 9 import gyp.MSVSVersion | 9 import gyp.MSVSVersion |
| 10 import gyp.system_test | 10 import gyp.system_test |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 | 1135 |
| 1136 return rule_name | 1136 return rule_name |
| 1137 | 1137 |
| 1138 | 1138 |
| 1139 def CalculateVariables(default_variables, params): | 1139 def CalculateVariables(default_variables, params): |
| 1140 """Calculate additional variables for use in the build (called by gyp).""" | 1140 """Calculate additional variables for use in the build (called by gyp).""" |
| 1141 global generator_additional_non_configuration_keys | 1141 global generator_additional_non_configuration_keys |
| 1142 global generator_additional_path_sections | 1142 global generator_additional_path_sections |
| 1143 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) | 1143 cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) |
| 1144 flavor = gyp.common.GetFlavor(params) | 1144 flavor = gyp.common.GetFlavor(params) |
| 1145 default_variables.setdefault('HOST_OS', gyp.common.GetHostOSFlavor()) | |
| 1145 if flavor == 'mac': | 1146 if flavor == 'mac': |
| 1146 default_variables.setdefault('OS', 'mac') | 1147 default_variables.setdefault('OS', 'mac') |
| 1147 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') | 1148 default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') |
| 1148 default_variables.setdefault('SHARED_LIB_DIR', | 1149 default_variables.setdefault('SHARED_LIB_DIR', |
| 1149 generator_default_variables['PRODUCT_DIR']) | 1150 generator_default_variables['PRODUCT_DIR']) |
| 1150 default_variables.setdefault('LIB_DIR', | 1151 default_variables.setdefault('LIB_DIR', |
| 1151 generator_default_variables['PRODUCT_DIR']) | 1152 generator_default_variables['PRODUCT_DIR']) |
| 1152 | 1153 |
| 1153 # Copy additional generator configuration data from Xcode, which is shared | 1154 # Copy additional generator configuration data from Xcode, which is shared |
| 1154 # by the Mac Ninja generator. | 1155 # by the Mac Ninja generator. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 out = OpenOutput(os.path.join(toplevel_build, 'set_environment.bat')) | 1220 out = OpenOutput(os.path.join(toplevel_build, 'set_environment.bat')) |
| 1220 vsvars_path = gyp.msvs_emulation.GetVsvarsPath(generator_flags) | 1221 vsvars_path = gyp.msvs_emulation.GetVsvarsPath(generator_flags) |
| 1221 out.write('@call "%s"\n' % vsvars_path) | 1222 out.write('@call "%s"\n' % vsvars_path) |
| 1222 out.close() | 1223 out.close() |
| 1223 | 1224 |
| 1224 | 1225 |
| 1225 def GenerateOutputForConfig(target_list, target_dicts, data, params, | 1226 def GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1226 config_name): | 1227 config_name): |
| 1227 options = params['options'] | 1228 options = params['options'] |
| 1228 flavor = gyp.common.GetFlavor(params) | 1229 flavor = gyp.common.GetFlavor(params) |
| 1230 host_os = gyp.common.GetHostOSFlavor() | |
| 1229 generator_flags = params.get('generator_flags', {}) | 1231 generator_flags = params.get('generator_flags', {}) |
| 1230 | 1232 |
| 1231 # build_dir: relative path from source root to our output files. | 1233 # build_dir: relative path from source root to our output files. |
| 1232 # e.g. "out/Debug" | 1234 # e.g. "out/Debug" |
| 1233 build_dir = os.path.join(generator_flags.get('output_dir', 'out'), | 1235 build_dir = os.path.join(generator_flags.get('output_dir', 'out'), |
| 1234 config_name) | 1236 config_name) |
| 1235 | 1237 |
| 1236 toplevel_build = os.path.join(options.toplevel_dir, build_dir) | 1238 toplevel_build = os.path.join(options.toplevel_dir, build_dir) |
| 1237 | 1239 |
| 1238 master_ninja = ninja_syntax.Writer( | 1240 master_ninja = ninja_syntax.Writer( |
| 1239 OpenOutput(os.path.join(toplevel_build, 'build.ninja')), | 1241 OpenOutput(os.path.join(toplevel_build, 'build.ninja')), |
| 1240 width=120) | 1242 width=120) |
| 1241 | 1243 |
| 1242 # Put build-time support tools in out/{config_name}. | 1244 # Put build-time support tools in out/{config_name}. |
| 1243 gyp.common.CopyTool(flavor, toplevel_build) | 1245 gyp.common.CopyTool(flavor, toplevel_build) |
| 1246 if host_os == 'mac' and flavor != 'mac': | |
| 1247 gyp.common.CopyTool(flavor, toplevel_build) | |
|
Torne
2012/08/01 11:20:32
See comment in make.py but also you've copypasted
| |
| 1244 | 1248 |
| 1245 # Grab make settings for CC/CXX. | 1249 # Grab make settings for CC/CXX. |
| 1246 if flavor == 'win': | 1250 if flavor == 'win': |
| 1247 cc = cxx = gyp.msvs_emulation.GetCLPath(generator_flags) | 1251 cc = cxx = gyp.msvs_emulation.GetCLPath(generator_flags) |
| 1248 _WriteWinEnvironmentHelper(toplevel_build, generator_flags) | 1252 _WriteWinEnvironmentHelper(toplevel_build, generator_flags) |
| 1249 else: | 1253 else: |
| 1250 cc, cxx = 'gcc', 'g++' | 1254 cc, cxx = 'gcc', 'g++' |
| 1251 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) | 1255 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) |
| 1252 make_global_settings = data[build_file].get('make_global_settings', []) | 1256 make_global_settings = data[build_file].get('make_global_settings', []) |
| 1253 build_to_root = InvertRelativePath(build_dir) | 1257 build_to_root = InvertRelativePath(build_dir) |
| 1254 for key, value in make_global_settings: | 1258 for key, value in make_global_settings: |
| 1255 if key == 'CC': cc = os.path.join(build_to_root, value) | 1259 if key == 'CC': cc = os.path.join(build_to_root, value) |
| 1256 if key == 'CXX': cxx = os.path.join(build_to_root, value) | 1260 if key == 'CXX': cxx = os.path.join(build_to_root, value) |
| 1257 | 1261 |
| 1258 flock = 'flock' | 1262 flock = 'flock' |
| 1259 if flavor == 'mac': | 1263 if host_os == 'mac': |
| 1260 flock = './gyp-mac-tool flock' | 1264 flock = './gyp-mac-tool flock' |
| 1261 master_ninja.variable('cc', os.environ.get('CC', cc)) | 1265 master_ninja.variable('cc', os.environ.get('CC', cc)) |
| 1262 master_ninja.variable('cxx', os.environ.get('CXX', cxx)) | 1266 master_ninja.variable('cxx', os.environ.get('CXX', cxx)) |
| 1263 if flavor == 'win': | 1267 if flavor == 'win': |
| 1264 master_ninja.variable('ld', gyp.msvs_emulation.GetLinkPath(generator_flags)) | 1268 master_ninja.variable('ld', gyp.msvs_emulation.GetLinkPath(generator_flags)) |
| 1265 master_ninja.variable('idl', | 1269 master_ninja.variable('idl', |
| 1266 gyp.msvs_emulation.GetMidlPath(generator_flags)) | 1270 gyp.msvs_emulation.GetMidlPath(generator_flags)) |
| 1267 master_ninja.variable('ar', gyp.msvs_emulation.GetLibPath(generator_flags)) | 1271 master_ninja.variable('ar', gyp.msvs_emulation.GetLibPath(generator_flags)) |
| 1268 # TODO(scottmg): Note that rc.exe isn't part of VS, it's part of the | 1272 # TODO(scottmg): Note that rc.exe isn't part of VS, it's part of the |
| 1269 # Windows SDK. We currently assume it's in the PATH, we may need to figure | 1273 # Windows SDK. We currently assume it's in the PATH, we may need to figure |
| 1270 # out a way to locate it explicitly. | 1274 # out a way to locate it explicitly. |
| 1271 master_ninja.variable('rc', 'rc.exe') | 1275 master_ninja.variable('rc', 'rc.exe') |
| 1272 else: | 1276 else: |
| 1273 master_ninja.variable('ld', flock + ' linker.lock $cxx') | 1277 master_ninja.variable('ld', flock + ' linker.lock $cxx') |
| 1274 master_ninja.variable('ar', os.environ.get('AR', 'ar')) | 1278 master_ninja.variable('ar', os.environ.get('AR', 'ar')) |
| 1275 | 1279 |
| 1276 master_ninja.variable('ar_target', os.environ.get('AR_target', '$ar')) | 1280 master_ninja.variable('ar_target', os.environ.get('AR_target', '$ar')) |
| 1277 master_ninja.variable('cc_target', os.environ.get('CC_target', '$cc')) | 1281 master_ninja.variable('cc_target', os.environ.get('CC_target', '$cc')) |
| 1278 master_ninja.variable('cxx_target', os.environ.get('CXX_target', '$cxx')) | 1282 master_ninja.variable('cxx_target', os.environ.get('CXX_target', '$cxx')) |
| 1279 if flavor == 'win': | 1283 if flavor == 'win': |
| 1280 master_ninja.variable('ld_target', os.environ.get('LD_target', '$ld')) | 1284 master_ninja.variable('ld_target', os.environ.get('LD_target', '$ld')) |
| 1281 else: | 1285 else: |
| 1282 master_ninja.variable('ld_target', flock + ' linker.lock $cxx_target') | 1286 master_ninja.variable('ld_target', flock + ' linker.lock $cxx_target') |
| 1283 | 1287 |
| 1284 if flavor == 'mac': | 1288 if host_os == 'mac': |
| 1285 master_ninja.variable('mac_tool', os.path.join('.', 'gyp-mac-tool')) | 1289 master_ninja.variable('mac_tool', os.path.join('.', 'gyp-mac-tool')) |
| 1286 master_ninja.newline() | 1290 master_ninja.newline() |
| 1287 | 1291 |
| 1288 if flavor != 'win': | 1292 if flavor != 'win': |
| 1289 master_ninja.rule( | 1293 master_ninja.rule( |
| 1290 'cc', | 1294 'cc', |
| 1291 description='CC $out', | 1295 description='CC $out', |
| 1292 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' | 1296 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' |
| 1293 '$cflags_pch_c -c $in -o $out'), | 1297 '$cflags_pch_c -c $in -o $out'), |
| 1294 depfile='$out.d') | 1298 depfile='$out.d') |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1437 'link', | 1441 'link', |
| 1438 description='LINK $out, POSTBUILDS', | 1442 description='LINK $out, POSTBUILDS', |
| 1439 command=('$ld $ldflags -o $out ' | 1443 command=('$ld $ldflags -o $out ' |
| 1440 '$in $libs$postbuilds')) | 1444 '$in $libs$postbuilds')) |
| 1441 master_ninja.rule( | 1445 master_ninja.rule( |
| 1442 'infoplist', | 1446 'infoplist', |
| 1443 description='INFOPLIST $out', | 1447 description='INFOPLIST $out', |
| 1444 command=('$cc -E -P -Wno-trigraphs -x c $defines $in -o $out && ' | 1448 command=('$cc -E -P -Wno-trigraphs -x c $defines $in -o $out && ' |
| 1445 'plutil -convert xml1 $out $out')) | 1449 'plutil -convert xml1 $out $out')) |
| 1446 master_ninja.rule( | 1450 master_ninja.rule( |
| 1447 'mac_tool', | |
| 1448 description='MACTOOL $mactool_cmd $in', | |
| 1449 command='$env $mac_tool $mactool_cmd $in $out') | |
| 1450 master_ninja.rule( | |
| 1451 'package_framework', | 1451 'package_framework', |
| 1452 description='PACKAGE FRAMEWORK $out, POSTBUILDS', | 1452 description='PACKAGE FRAMEWORK $out, POSTBUILDS', |
| 1453 command='$mac_tool package-framework $out $version$postbuilds ' | 1453 command='$mac_tool package-framework $out $version$postbuilds ' |
| 1454 '&& touch $out') | 1454 '&& touch $out') |
| 1455 | |
| 1456 if host_os == 'mac': | |
| 1457 master_ninja.rule( | |
| 1458 'mac_tool', | |
| 1459 description='MACTOOL $mactool_cmd $in', | |
| 1460 command='$env $mac_tool $mactool_cmd $in $out') | |
| 1461 | |
| 1455 if flavor == 'win': | 1462 if flavor == 'win': |
| 1456 master_ninja.rule( | 1463 master_ninja.rule( |
| 1457 'stamp', | 1464 'stamp', |
| 1458 description='STAMP $out', | 1465 description='STAMP $out', |
| 1459 command='python gyp-win-tool stamp $out') | 1466 command='python gyp-win-tool stamp $out') |
| 1460 master_ninja.rule( | 1467 master_ninja.rule( |
| 1461 'copy', | 1468 'copy', |
| 1462 description='COPY $in $out', | 1469 description='COPY $in $out', |
| 1463 command='python gyp-win-tool recursive-mirror $in $out') | 1470 command='python gyp-win-tool recursive-mirror $in $out') |
| 1464 else: | 1471 else: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1542 | 1549 |
| 1543 user_config = params.get('generator_flags', {}).get('config', None) | 1550 user_config = params.get('generator_flags', {}).get('config', None) |
| 1544 if user_config: | 1551 if user_config: |
| 1545 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1552 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1546 user_config) | 1553 user_config) |
| 1547 else: | 1554 else: |
| 1548 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1555 config_names = target_dicts[target_list[0]]['configurations'].keys() |
| 1549 for config_name in config_names: | 1556 for config_name in config_names: |
| 1550 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1557 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 1551 config_name) | 1558 config_name) |
| OLD | NEW |