Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 import argparse | |
| 6 import os | |
| 7 import subprocess | |
| 8 import sys | |
| 9 | |
| 10 | |
| 11 def main(args): | |
| 12 parser = argparse.ArgumentParser() | |
| 13 parser.add_argument( | |
| 14 '--gyp-condition', '-c', type=str, required=True, | |
| 15 help=('Name of environment variable that acts as the switch. If the ' | |
|
Kai Ninomiya
2017/06/05 21:58:51
nit: it's not really an environment variable that
nednguyen
2017/06/05 22:24:24
Done.
| |
| 16 'variable is set in the environment, this will execute the target ' | |
| 17 'script')) | |
| 18 options, script_args = parser.parse_known_args() | |
| 19 | |
| 20 # Make sure that we always execute target script with python. | |
| 21 if 'python' not in script_args[0]: | |
| 22 script_args.insert(0, sys.executable) | |
| 23 | |
| 24 gyp_defines = os.environ.get('GYP_DEFINES', '') | |
| 25 if options.gyp_condition in gyp_defines: | |
|
Kai Ninomiya
2017/06/05 21:58:51
This may not matter since this should get replaced
nednguyen
2017/06/05 22:24:24
Done.
| |
| 26 print 'Found matching condition in GYP_DEFINES. Execute: %s' % ( | |
| 27 ' '.join(script_args)) | |
| 28 subprocess.check_call(script_args) | |
| 29 else: | |
| 30 print ('Not found "%s" condition in GYP_DEFINES="%s". ' | |
| 31 'Skip script execution.' % | |
| 32 (options.gyp_condition, gyp_defines)) | |
| 33 return 0 | |
| 34 | |
| 35 | |
| 36 if __name__ == '__main__': | |
| 37 main(sys.argv[1:]) | |
| OLD | NEW |