sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
scottmg@chromium.org | 1e50b9e | 2013-05-29 01:02:13 +0900 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
dpranke | 17ef776 | 2016-09-22 07:27:23 +0900 | [diff] [blame] | 5 | """This script is now only used by the closure_compilation builders.""" |
scottmg@chromium.org | 1e50b9e | 2013-05-29 01:02:13 +0900 | [diff] [blame] | 6 | |
dpranke | 1654c15 | 2016-09-08 01:40:06 +0900 | [diff] [blame] | 7 | import argparse |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 8 | import glob |
dpranke | 1654c15 | 2016-09-08 01:40:06 +0900 | [diff] [blame] | 9 | import gyp_environment |
scottmg@chromium.org | 1e50b9e | 2013-05-29 01:02:13 +0900 | [diff] [blame] | 10 | import os |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 11 | import shlex |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 12 | import sys |
scottmg@chromium.org | 1e50b9e | 2013-05-29 01:02:13 +0900 | [diff] [blame] | 13 | |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 14 | script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 15 | chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| 16 | |
dpranke | 1654c15 | 2016-09-08 01:40:06 +0900 | [diff] [blame] | 17 | sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) |
| 18 | import gyp |
| 19 | |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 20 | |
| 21 | def ProcessGypDefinesItems(items): |
| 22 | """Converts a list of strings to a list of key-value pairs.""" |
| 23 | result = [] |
| 24 | for item in items: |
| 25 | tokens = item.split('=', 1) |
| 26 | # Some GYP variables have hyphens, which we don't support. |
| 27 | if len(tokens) == 2: |
| 28 | result += [(tokens[0], tokens[1])] |
| 29 | else: |
| 30 | # No value supplied, treat it as a boolean and set it. Note that we |
| 31 | # use the string '1' here so we have a consistent definition whether |
| 32 | # you do 'foo=1' or 'foo'. |
| 33 | result += [(tokens[0], '1')] |
| 34 | return result |
| 35 | |
| 36 | |
dpranke | 17ef776 | 2016-09-22 07:27:23 +0900 | [diff] [blame] | 37 | def GetSupplementalFiles(): |
| 38 | return [] |
| 39 | |
| 40 | |
| 41 | def GetGypVars(_): |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 42 | """Returns a dictionary of all GYP vars.""" |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 43 | # GYP defines from the environment. |
| 44 | env_items = ProcessGypDefinesItems( |
| 45 | shlex.split(os.environ.get('GYP_DEFINES', ''))) |
| 46 | |
dpranke | 1654c15 | 2016-09-08 01:40:06 +0900 | [diff] [blame] | 47 | # GYP defines from the command line. |
| 48 | parser = argparse.ArgumentParser() |
| 49 | parser.add_argument('-D', dest='defines', action='append', default=[]) |
| 50 | cmdline_input_items = parser.parse_known_args()[0].defines |
| 51 | cmdline_items = ProcessGypDefinesItems(cmdline_input_items) |
| 52 | |
dpranke | 17ef776 | 2016-09-22 07:27:23 +0900 | [diff] [blame] | 53 | return dict(env_items + cmdline_items) |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 54 | |
| 55 | |
| 56 | def main(): |
dpranke | 1654c15 | 2016-09-08 01:40:06 +0900 | [diff] [blame] | 57 | gyp_environment.SetEnvironment() |
| 58 | |
dpranke | 17ef776 | 2016-09-22 07:27:23 +0900 | [diff] [blame] | 59 | print 'Updating projects from gyp files...' |
| 60 | sys.stdout.flush() |
| 61 | sys.exit(gyp.main(sys.argv[1:] + [ |
| 62 | '--check', |
| 63 | '--no-circular-check', |
| 64 | '-I', os.path.join(script_dir, 'common.gypi'), |
| 65 | '-D', 'gyp_output_dir=out'])) |
sbc | 22d1b58 | 2015-08-12 06:01:19 +0900 | [diff] [blame] | 66 | |
| 67 | if __name__ == '__main__': |
| 68 | sys.exit(main()) |