3 # Copyright (c) 2012 The Chromium Authors. 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.
7 # This script is wrapper for Crosswalk that adds some support for how GYP
8 # is invoked by Chromium beyond what can be done in the gclient hooks.
16 xwalk_dir = os.path.dirname(os.path.realpath(__file__))
17 chrome_src = os.path.abspath(os.path.join(xwalk_dir, os.pardir))
19 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
22 sys.path.insert(0, os.path.join(chrome_src, 'build'))
26 # Add paths so that pymod_do_main(...) can import files.
27 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers'))
28 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit'))
29 sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build'))
30 sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build'))
31 sys.path.insert(1, os.path.join(chrome_src, 'remoting', 'tools', 'build'))
32 sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit',
33 'Source', 'build', 'scripts'))
35 # On Windows, Psyco shortens warm runs of build/gyp_chromium by about
36 # 20 seconds on a z600 machine with 12 GB of RAM, from 90 down to 70
37 # seconds. Conversely, memory usage of build/gyp_chromium with Psyco
38 # maxes out at about 158 MB vs. 132 MB without it.
40 # Psyco uses native libraries, so we need to load a different
41 # installation depending on which OS we are running under. It has not
42 # been tested whether using Psyco on our Mac and Linux builds is worth
43 # it (the GYP running time is a lot shorter, so the JIT startup cost
44 # may not be worth it).
45 if sys.platform == 'win32':
47 sys.path.insert(0, os.path.join(chrome_src, 'third_party', 'psyco_win32'))
54 def additional_include_files(args=[]):
56 Returns a list of additional (.gypi) files to include, without
57 duplicating ones that are already specified on the command line.
59 # Determine the include files specified on the command line.
60 # This doesn't cover all the different option formats you can use,
61 # but it's mainly intended to avoid duplicating flags on the automatic
62 # makefile regeneration which only uses this format.
63 specified_includes = set()
65 if arg.startswith('-I') and len(arg) > 2:
66 specified_includes.add(os.path.realpath(arg[2:]))
70 if os.path.realpath(path) not in specified_includes:
73 # Include xwalk common.gypi to effect chromium source tree.
74 AddInclude(os.path.join(xwalk_dir, 'build', 'common.gypi'))
76 # Always include common.gypi.
77 AddInclude(os.path.join(chrome_src, 'build', 'common.gypi'))
79 # Optionally add supplemental .gypi files if present.
80 supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
81 for supplement in supplements:
82 AddInclude(supplement)
86 if __name__ == '__main__':
89 # Support external media types capability such as MP4/MP3.
90 args = list(set(args))
92 ip_media_codecs = False # Default: no third-party codecs be build in.
94 if arg.startswith('-Dproprietary_codecs') or arg.startswith('-Dffmpeg_branding'):
96 elif arg == '-Dmediacodecs_EULA=1':
97 ip_media_codecs = True # Exception: mediacodecs_EULA be enabled.
102 args.append('-Dproprietary_codecs=1')
104 # Triggering media playback dynamically with third-party codecs by owner.
105 if ip_media_codecs == True:
106 args.append('-Dffmpeg_branding=Chrome')
108 # Enable Web Audio by default on Android x86
109 if landmine_utils.platform() == 'android':
110 args.append('-Duse_openmax_dl_fft=1')
112 # Enable Aura by default on all platforms except Android
113 if landmine_utils.platform() != 'android' and landmine_utils.platform() != 'mac':
114 args.append('-Duse_aura=1')
116 # Use the Psyco JIT if available.
119 print "Enabled Psyco JIT."
121 # Fall back on hermetic python if we happen to get run under cygwin.
122 # TODO(bradnelson): take this out once this issue is fixed:
123 # http://code.google.com/p/gyp/issues/detail?id=177
124 if sys.platform == 'cygwin':
125 python_dir = os.path.join(chrome_src, 'third_party', 'python_26')
126 env = os.environ.copy()
127 env['PATH'] = python_dir + os.pathsep + env.get('PATH', '')
128 p = subprocess.Popen(
129 [os.path.join(python_dir, 'python.exe')] + sys.argv,
130 env=env, shell=False)
132 sys.exit(p.returncode)
134 gyp_helper.apply_chromium_gyp_env()
136 # This could give false positives since it doesn't actually do real option
138 gyp_file_specified = False
140 if arg.endswith('.gyp'):
141 gyp_file_specified = True
144 # If we didn't get a file, check an env var, and then fall back to
145 # assuming 'all.gyp' from the same directory as the script.
146 if not gyp_file_specified:
147 gyp_file = os.environ.get('CHROMIUM_GYP_FILE')
149 # Note that CHROMIUM_GYP_FILE values can't have backslashes as
150 # path separators even on Windows due to the use of shlex.split().
151 args.extend(shlex.split(gyp_file))
153 args.append(os.path.join(xwalk_dir, 'xwalk.gyp'))
155 args.extend(['-I' + i for i in additional_include_files(args)])
157 # There shouldn't be a circular dependency relationship between .gyp files,
158 # but in Chromium's .gyp files, circular relationships currently exist.
159 # TODO(mark): Find and kill remaining circular dependencies, and remove this
160 # option. http://crbug.com/35878.
161 # TODO(tc): Fix circular dependencies in ChromiumOS then add linux2 to the
163 # TODO(tmpsantos): Make runtime a proper module and enable the circular check
165 args.append('--no-circular-check')
167 # If CHROMIUM_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
168 # to enfore syntax checking.
169 syntax_check = os.environ.get('CHROMIUM_GYP_SYNTAX_CHECK')
170 if syntax_check and int(syntax_check):
171 args.append('--check')
173 print 'Updating projects from gyp files...'
177 sys.exit(gyp.main(args))