3 # Copyright (c) 2013 Intel Corporation. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
8 This script is responsible for generating .gclient-xwalk in the top-level
9 source directory from DEPS.xwalk.
11 User-configurable values such as |cache_dir| are fetched from .gclient instead.
20 CROSSWALK_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21 GCLIENT_ROOT = os.path.dirname(os.path.dirname(CROSSWALK_ROOT))
24 def ParseGClientConfig():
26 Parses the top-level .gclient file (NOT .gclient-xwalk) and returns the
27 values set there as a dictionary.
29 with open(os.path.join(GCLIENT_ROOT, '.gclient')) as dot_gclient:
31 exec(dot_gclient, config)
35 def GenerateGClientXWalk(options):
36 with open(os.path.join(CROSSWALK_ROOT, 'DEPS.xwalk')) as deps_file:
37 deps_contents = deps_file.read()
39 if 'XWALK_OS_ANDROID' in os.environ:
40 deps_contents += 'target_os = [\'android\']\n'
42 gclient_config = ParseGClientConfig()
44 logging.warning('--cache_dir is deprecated and will be removed in '
45 'Crosswalk 8. You should set cache_dir in .gclient '
47 cache_dir = options.cache_dir
49 cache_dir = gclient_config.get('cache_dir')
50 deps_contents += 'cache_dir = %s\n' % pprint.pformat(cache_dir)
52 with open(os.path.join(GCLIENT_ROOT, '.gclient-xwalk'), 'w') as gclient_file:
53 gclient_file.write(deps_contents)
57 option_parser = optparse.OptionParser()
58 # TODO(rakuco): Remove in Crosswalk 8.
59 option_parser.add_option('--cache-dir',
60 help='DEPRECATED Set "cache_dir" in .gclient-xwalk '
61 'to this directory, so that all git '
62 'repositories are cached there.')
63 options, _ = option_parser.parse_args()
64 GenerateGClientXWalk(options)
67 if __name__ == '__main__':