2 # Copyright (C) 2009 Google Inc. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of Google Inc. nor the names of its contributors
14 # may be used to endorse or promote products derived from this software
15 # without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 # This file is used by gclient execute gyp with the proper command
39 script_dir = os.path.dirname(__file__)
40 chrome_src = os.path.abspath(script_dir)
42 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
45 # Add tools/grit so that pymod_do_main(grit_info ...) can find grit_info.py.
46 sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit'))
48 def additional_include_files(args=[]):
50 Returns a list of additional (.gypi) files to include, without
51 duplicating ones that are already specified on the command line.
53 # Determine the include files specified on the command line.
54 # This doesn't cover all the different option formats you can use,
55 # but it's mainly intended to avoid duplicating flags on the automatic
56 # makefile regeneration which only uses this format.
57 specified_includes = set()
59 if arg.startswith('-I') and len(arg) > 2:
60 specified_includes.add(os.path.realpath(arg[2:]))
64 if os.path.realpath(path) not in specified_includes:
67 # Always include common.gypi
68 AddInclude(os.path.join(script_dir, 'build', 'common.gypi'))
70 # Optionally add supplemental .gypi files if present.
71 supplements = glob.glob(os.path.join(script_dir, '*', 'supplement.gypi'))
72 for supplement in supplements:
73 AddInclude(supplement)
77 if __name__ == '__main__':
81 # When building the WebKit Chromium port for Android, we have to cross-compile
82 # the source to ARM, check for the right Android NDK and set the appropriate
83 # GYP flags. Chromium's envsetup.sh script will handle these steps, but as it
84 # exports variables and commands we have to re-call ourselves afterwards.
85 if 'WEBKIT_ANDROID_BUILD' in os.environ:
86 if not '--no-envsetup-recursion' in args:
87 envsetup_location = os.path.join(chrome_src, 'build', 'android', 'envsetup.sh')
88 exit(subprocess.call(['bash', '-c', 'source %s && python gyp_webkit --no-envsetup-recursion %s' % (envsetup_location, ' '.join(args))]))
90 # FIXME: v8 requires the CXX_target variable to determine whether -m32 should be
91 # set. The current Android build set-up is not sustainable and breaks too often.
92 os.environ['CXX_target'] = glob.glob('%s/*-g++' % os.environ.get('ANDROID_TOOLCHAIN'))[0]
93 args.remove('--no-envsetup-recursion')
96 args.extend(['-I' + i for i in additional_include_files(args)])
98 # There shouldn't be a circular dependency relationship between .gyp files,
99 # but in Chromium's .gyp files, on non-Mac platforms, circular relationships
100 # currently exist. The check for circular dependencies is currently
101 # bypassed on other platforms, but is left enabled on the Mac, where a
102 # violation of the rule causes Xcode to misbehave badly.
103 # http://crbug.com/35878.
104 if sys.platform not in ('darwin',):
105 args.append('--no-circular-check')
107 generators = os.environ.get('GYP_GENERATORS', '')
108 if 'ninja' in generators:
109 args.extend([ '--toplevel-dir=../../..' ])
110 elif (sys.platform.startswith('linux') or
111 'WEBKIT_ANDROID_BUILD' in os.environ or
112 (sys.platform == 'darwin' and 'make' in generators)):
113 args.extend(['-fmake',
114 '--suffix=.chromium',
115 '--toplevel-dir=../../..',
116 # auto_regeneration doesn't work with toplevel-dir
117 '-Gauto_regeneration=0'])
119 # Other command args:
121 # gyp variable defines.
122 '-Dinside_chromium_build=0',
123 '-Dv8_use_snapshot=false',
124 '-Dmsvs_use_common_release=0',
125 '-Gmsvs_error_on_missing_sources=1',
127 # WebKit doesn't use the chromium style checker.
128 '-Dmake_clang_dir=Source/WebKit/chromium/third_party/llvm-build/Release+Asserts',
129 '-Dclang_use_chrome_plugins=0',
131 # gyp hack: otherwise gyp assumes its in chromium's src/ dir.
134 # gyp file to execute.
137 print 'Updating webkit projects from gyp files...'
141 sys.exit(gyp.main(args))