OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium 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 """MB - the Meta-Build wrapper around GYP and GN | 6 """MB - the Meta-Build wrapper around GYP and GN |
7 | 7 |
8 MB is a wrapper script for GYP and GN that can be used to generate build files | 8 MB is a wrapper script for GYP and GN that can be used to generate build files |
9 for sets of canned configurations and analyze them. | 9 for sets of canned configurations and analyze them. |
10 """ | 10 """ |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 # This is a terrible hack to work around the fact that | 1120 # This is a terrible hack to work around the fact that |
1121 # //tools/clang/scripts/update.py is invoked by GYP and GN but | 1121 # //tools/clang/scripts/update.py is invoked by GYP and GN but |
1122 # currently relies on an environment variable to figure out | 1122 # currently relies on an environment variable to figure out |
1123 # what revision to embed in the command line #defines. | 1123 # what revision to embed in the command line #defines. |
1124 # For GN, we've made this work via a gn arg that will cause update.py | 1124 # For GN, we've made this work via a gn arg that will cause update.py |
1125 # to get an additional command line arg, but getting that to work | 1125 # to get an additional command line arg, but getting that to work |
1126 # via GYP_DEFINES has proven difficult, so we rewrite the GYP_DEFINES | 1126 # via GYP_DEFINES has proven difficult, so we rewrite the GYP_DEFINES |
1127 # to get rid of the arg and add the old var in, instead. | 1127 # to get rid of the arg and add the old var in, instead. |
1128 # See crbug.com/582737 for more on this. This can hopefully all | 1128 # See crbug.com/582737 for more on this. This can hopefully all |
1129 # go away with GYP. | 1129 # go away with GYP. |
1130 if 'llvm_force_head_revision=1' in gyp_defines: | 1130 m = re.search('llvm_force_head_revision=1\s*', gyp_defines) |
| 1131 if m: |
1131 env['LLVM_FORCE_HEAD_REVISION'] = '1' | 1132 env['LLVM_FORCE_HEAD_REVISION'] = '1' |
1132 gyp_defines = gyp_defines.replace('llvm_force_head_revision=1', '') | 1133 gyp_defines = gyp_defines.replace(m.group(0), '') |
| 1134 |
| 1135 # This is another terrible hack to work around the fact that |
| 1136 # GYP sets the link concurrency to use via the GYP_LINK_CONCURRENCY |
| 1137 # environment variable, and not via a proper GYP_DEFINE. See |
| 1138 # crbug.com/611491 for more on this. |
| 1139 m = re.search('gyp_link_concurrency=(\d+)(\s*)', gyp_defines) |
| 1140 if m: |
| 1141 env['GYP_LINK_CONCURRENCY'] = m.group(1) |
| 1142 gyp_defines = gyp_defines.replace(m.group(0), '') |
1133 | 1143 |
1134 env['GYP_GENERATORS'] = 'ninja' | 1144 env['GYP_GENERATORS'] = 'ninja' |
1135 if 'GYP_CHROMIUM_NO_ACTION' in env: | 1145 if 'GYP_CHROMIUM_NO_ACTION' in env: |
1136 del env['GYP_CHROMIUM_NO_ACTION'] | 1146 del env['GYP_CHROMIUM_NO_ACTION'] |
1137 if 'GYP_CROSSCOMPILE' in env: | 1147 if 'GYP_CROSSCOMPILE' in env: |
1138 del env['GYP_CROSSCOMPILE'] | 1148 del env['GYP_CROSSCOMPILE'] |
1139 env['GYP_DEFINES'] = gyp_defines | 1149 env['GYP_DEFINES'] = gyp_defines |
1140 if vals['gyp_crosscompile']: | 1150 if vals['gyp_crosscompile']: |
1141 env['GYP_CROSSCOMPILE'] = '1' | 1151 env['GYP_CROSSCOMPILE'] = '1' |
1142 return cmd, env | 1152 return cmd, env |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 env_prefix = '' | 1326 env_prefix = '' |
1317 env_quoter = pipes.quote | 1327 env_quoter = pipes.quote |
1318 shell_quoter = pipes.quote | 1328 shell_quoter = pipes.quote |
1319 | 1329 |
1320 def print_env(var): | 1330 def print_env(var): |
1321 if env and var in env: | 1331 if env and var in env: |
1322 self.Print('%s%s=%s' % (env_prefix, var, env_quoter(env[var]))) | 1332 self.Print('%s%s=%s' % (env_prefix, var, env_quoter(env[var]))) |
1323 | 1333 |
1324 print_env('GYP_CROSSCOMPILE') | 1334 print_env('GYP_CROSSCOMPILE') |
1325 print_env('GYP_DEFINES') | 1335 print_env('GYP_DEFINES') |
| 1336 print_env('GYP_LINK_CONCURRENCY') |
| 1337 print_env('LLVM_FORCE_HEAD_REVISION') |
1326 | 1338 |
1327 if cmd[0] == self.executable: | 1339 if cmd[0] == self.executable: |
1328 cmd = ['python'] + cmd[1:] | 1340 cmd = ['python'] + cmd[1:] |
1329 self.Print(*[shell_quoter(arg) for arg in cmd]) | 1341 self.Print(*[shell_quoter(arg) for arg in cmd]) |
1330 | 1342 |
1331 def PrintJSON(self, obj): | 1343 def PrintJSON(self, obj): |
1332 self.Print(json.dumps(obj, indent=2, sort_keys=True)) | 1344 self.Print(json.dumps(obj, indent=2, sort_keys=True)) |
1333 | 1345 |
1334 def GNTargetName(self, target): | 1346 def GNTargetName(self, target): |
1335 return target | 1347 return target |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 # Then check to see if the arg contains any metacharacters other than | 1481 # Then check to see if the arg contains any metacharacters other than |
1470 # double quotes; if it does, quote everything (including the double | 1482 # double quotes; if it does, quote everything (including the double |
1471 # quotes) for safety. | 1483 # quotes) for safety. |
1472 if any(a in UNSAFE_FOR_CMD for a in arg): | 1484 if any(a in UNSAFE_FOR_CMD for a in arg): |
1473 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) | 1485 arg = ''.join('^' + a if a in ALL_META_CHARS else a for a in arg) |
1474 return arg | 1486 return arg |
1475 | 1487 |
1476 | 1488 |
1477 if __name__ == '__main__': | 1489 if __name__ == '__main__': |
1478 sys.exit(main(sys.argv[1:])) | 1490 sys.exit(main(sys.argv[1:])) |
OLD | NEW |