OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright 2011 The Android Open Source Project | 3 # Copyright 2011 The Android Open Source Project |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 # This script is a wrapper which invokes gyp with the correct --depth argument, | 8 # This script is a wrapper which invokes gyp with the correct --depth argument, |
9 # and supports the automatic regeneration of build files if all.gyp is | 9 # and supports the automatic regeneration of build files if all.gyp is |
10 # changed (Linux-only). | 10 # changed (Linux-only). |
11 | 11 |
12 import glob | 12 import glob |
13 import os | 13 import os |
14 import platform | 14 import platform |
15 import shlex | 15 import shlex |
16 import sys | 16 import sys |
17 | 17 |
18 script_dir = os.path.abspath(os.path.dirname(__file__)) | 18 script_dir = os.path.abspath(os.path.dirname(__file__)) |
19 | 19 |
20 # Directory within which we can find the gyp source. | 20 # Directory within which we can find the gyp source. |
21 gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp') | 21 gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp') |
22 | 22 |
23 # Directory within which we can find most of Skia's gyp configuration files. | 23 # Directory within which we can find most of Skia's gyp configuration files. |
24 gyp_config_dir = os.path.join(script_dir, 'gyp') | 24 gyp_config_dir = os.path.join(script_dir, 'gyp') |
25 | 25 |
| 26 # Allow the user to override the directory where gyp should produce its output |
| 27 # Default to the current directory. |
| 28 gyp_output_dir = os.environ.get('SKIA_GYP_OUTPUT_DIR', '.') |
| 29 |
26 # Ensure we import our current gyp source's module, not any version | 30 # Ensure we import our current gyp source's module, not any version |
27 # pre-installed in your PYTHONPATH. | 31 # pre-installed in your PYTHONPATH. |
28 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) | 32 sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) |
29 import gyp | 33 import gyp |
30 | 34 |
31 ENVVAR_GYP_GENERATORS = 'GYP_GENERATORS' | 35 ENVVAR_GYP_GENERATORS = 'GYP_GENERATORS' |
32 ENVVAR_GYP_GENERATOR_FLAGS = 'GYP_GENERATOR_FLAGS' | 36 ENVVAR_GYP_GENERATOR_FLAGS = 'GYP_GENERATOR_FLAGS' |
33 | 37 |
34 | 38 |
35 def additional_include_files(args=[]): | 39 def additional_include_files(args=[]): |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if not gyp_file_specified: | 130 if not gyp_file_specified: |
127 args.append('skia.gyp') | 131 args.append('skia.gyp') |
128 | 132 |
129 args.extend(['-I' + i for i in additional_include_files(args)]) | 133 args.extend(['-I' + i for i in additional_include_files(args)]) |
130 args.extend(['--depth', '.']) | 134 args.extend(['--depth', '.']) |
131 | 135 |
132 # Tell gyp to write the build files into output_dir. | 136 # Tell gyp to write the build files into output_dir. |
133 args.extend(['--generator-output', os.path.abspath(get_output_dir())]) | 137 args.extend(['--generator-output', os.path.abspath(get_output_dir())]) |
134 | 138 |
135 # Tell ninja to write its output into the same directory. | 139 # Tell ninja to write its output into the same directory. |
136 args.extend(['-Goutput_dir=.']) | 140 args.extend(['-Goutput_dir=%s' % gyp_output_dir]) |
137 | 141 |
138 # By default, we build 'most' instead of 'all' or 'everything'. See skia.gyp. | 142 # By default, we build 'most' instead of 'all' or 'everything'. See skia.gyp. |
139 args.extend(['-Gdefault_target=most']) | 143 args.extend(['-Gdefault_target=most']) |
140 | 144 |
141 # Fail if any files specified in the project are missing | 145 # Fail if any files specified in the project are missing |
142 if sys.platform.startswith('win'): | 146 if sys.platform.startswith('win'): |
143 gyp_generator_flags = os.getenv(ENVVAR_GYP_GENERATOR_FLAGS, '') | 147 gyp_generator_flags = os.getenv(ENVVAR_GYP_GENERATOR_FLAGS, '') |
144 if not 'msvs_error_on_missing_sources' in gyp_generator_flags: | 148 if not 'msvs_error_on_missing_sources' in gyp_generator_flags: |
145 os.environ[ENVVAR_GYP_GENERATOR_FLAGS] = ( | 149 os.environ[ENVVAR_GYP_GENERATOR_FLAGS] = ( |
146 gyp_generator_flags + ' msvs_error_on_missing_sources=1') | 150 gyp_generator_flags + ' msvs_error_on_missing_sources=1') |
(...skipping 15 matching lines...) Expand all Loading... |
162 if res: | 166 if res: |
163 sys.exit(res) | 167 sys.exit(res) |
164 | 168 |
165 # This code is copied from Chrome's build/gyp_chromium. It's not clear why | 169 # This code is copied from Chrome's build/gyp_chromium. It's not clear why |
166 # the *_runtime variables are reversed. | 170 # the *_runtime variables are reversed. |
167 if vs2013_runtime_dll_dirs: | 171 if vs2013_runtime_dll_dirs: |
168 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | 172 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
169 vs_toolchain.CopyVsRuntimeDlls( | 173 vs_toolchain.CopyVsRuntimeDlls( |
170 os.path.join(os.getenv('CHROME_PATH'), get_output_dir()), | 174 os.path.join(os.getenv('CHROME_PATH'), get_output_dir()), |
171 (x86_runtime, x64_runtime)) | 175 (x86_runtime, x64_runtime)) |
OLD | NEW |