blob: ab2e470dce3057278d8465e2ad788d322819783d [file] [log] [blame]
sbc22d1b582015-08-12 06:01:19 +09001# Copyright (c) 2012 The Chromium Authors. All rights reserved.
scottmg@chromium.org1e50b9e2013-05-29 01:02:13 +09002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
dpranke17ef7762016-09-22 07:27:23 +09005"""This script is now only used by the closure_compilation builders."""
scottmg@chromium.org1e50b9e2013-05-29 01:02:13 +09006
dpranke1654c152016-09-08 01:40:06 +09007import argparse
sbc22d1b582015-08-12 06:01:19 +09008import glob
dpranke1654c152016-09-08 01:40:06 +09009import gyp_environment
scottmg@chromium.org1e50b9e2013-05-29 01:02:13 +090010import os
sbc22d1b582015-08-12 06:01:19 +090011import shlex
sbc22d1b582015-08-12 06:01:19 +090012import sys
scottmg@chromium.org1e50b9e2013-05-29 01:02:13 +090013
sbc22d1b582015-08-12 06:01:19 +090014script_dir = os.path.dirname(os.path.realpath(__file__))
15chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
16
dpranke1654c152016-09-08 01:40:06 +090017sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
18import gyp
19
sbc22d1b582015-08-12 06:01:19 +090020
21def 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
dpranke17ef7762016-09-22 07:27:23 +090037def GetSupplementalFiles():
38 return []
39
40
41def GetGypVars(_):
sbc22d1b582015-08-12 06:01:19 +090042 """Returns a dictionary of all GYP vars."""
sbc22d1b582015-08-12 06:01:19 +090043 # GYP defines from the environment.
44 env_items = ProcessGypDefinesItems(
45 shlex.split(os.environ.get('GYP_DEFINES', '')))
46
dpranke1654c152016-09-08 01:40:06 +090047 # 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
dpranke17ef7762016-09-22 07:27:23 +090053 return dict(env_items + cmdline_items)
sbc22d1b582015-08-12 06:01:19 +090054
55
56def main():
dpranke1654c152016-09-08 01:40:06 +090057 gyp_environment.SetEnvironment()
58
dpranke17ef7762016-09-22 07:27:23 +090059 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']))
sbc22d1b582015-08-12 06:01:19 +090066
67if __name__ == '__main__':
68 sys.exit(main())