OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 3 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license | 5 # Use of this source code is governed by a BSD-style license |
6 # that can be found in the LICENSE file in the root of the source | 6 # that can be found in the LICENSE file in the root of the source |
7 # tree. An additional intellectual property rights grant can be found | 7 # tree. An additional intellectual property rights grant can be found |
8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
10 | 10 |
11 # This file is (possibly, depending on python version) imported by | 11 # This script is used to run GYP for WebRTC. It contains selected parts of the |
kjellander_webrtc
2016/04/18 07:37:04
The diff is not every readable since both files ex
| |
12 # gyp_webrtc when GYP_PARALLEL=1 and it creates sub-processes | 12 # main function from the src/build/gyp_chromium.py file while other parts are |
13 # through the multiprocessing library. | 13 # reused to minimize code duplication. |
14 | 14 |
15 # Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for | 15 import gc |
16 # imports that don't end in .py (and aren't directories with an | 16 import glob |
17 # __init__.py). This wrapper makes "import gyp_webrtc" work with | 17 import os |
18 # those old versions and makes it possible to execute gyp_webrtc.py | 18 import sys |
19 # directly on Windows where the extension is useful. | |
20 | 19 |
21 import os | 20 script_dir = os.path.dirname(os.path.realpath(__file__)) |
21 checkout_root = os.path.abspath(os.path.join(script_dir, os.pardir, os.pardir)) | |
22 | 22 |
23 path = os.path.abspath(os.path.split(__file__)[0]) | 23 sys.path.insert(0, os.path.join(checkout_root, 'build')) |
24 execfile(os.path.join(path, 'gyp_webrtc')) | 24 import gyp_chromium |
25 import gyp_helper | |
26 import vs_toolchain | |
27 | |
28 sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib')) | |
29 import gyp | |
30 | |
31 def GetSupplementalFiles(): | |
phoglund
2016/04/18 08:24:25
Nit: two blank lines
kjellander_webrtc
2016/04/18 08:46:45
Done.
| |
32 """Returns a list of the supplemental files that are included in all GYP | |
phoglund
2016/04/18 08:24:24
Nit: """Complete one-line sentence.
More info tha
kjellander_webrtc
2016/04/18 08:46:45
Done.
| |
33 sources.""" | |
34 # Can't use the one in gyp_chromium since the directory location of the root | |
35 # is different. | |
36 return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi')) | |
37 | |
38 | |
39 def main(): | |
40 # Disabling garbage collection saves about 5% processing time. Since this is a | |
41 # short-lived process it's not a problem. | |
42 gc.disable() | |
43 | |
44 args = sys.argv[1:] | |
45 | |
46 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): | |
47 print 'Skipping gyp_webrtc due to GYP_CHROMIUM_NO_ACTION env var.' | |
48 sys.exit(0) | |
49 | |
50 if 'SKIP_WEBRTC_GYP_ENV' not in os.environ: | |
51 # Update the environment based on webrtc.gyp_env | |
phoglund
2016/04/18 08:24:25
Nit: end with .
kjellander_webrtc
2016/04/18 08:46:45
Done.
| |
52 gyp_env_path = os.path.join(os.path.dirname(checkout_root), | |
53 'webrtc.gyp_env') | |
54 gyp_helper.apply_gyp_environment_from_file(gyp_env_path) | |
55 | |
56 # This could give false positives since it doesn't actually do real option | |
57 # parsing. Oh well. | |
58 gyp_file_specified = False | |
59 for arg in args: | |
60 if arg.endswith('.gyp'): | |
61 gyp_file_specified = True | |
62 break | |
63 | |
64 # If we didn't get a file, assume 'all.gyp' in the root of the checkout. | |
65 if not gyp_file_specified: | |
66 # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't | |
67 # work, but chdir'ing and adding the relative path does. Spooky :/ | |
68 os.chdir(checkout_root) | |
69 args.append('all.gyp') | |
70 | |
71 # There shouldn't be a circular dependency relationship between .gyp files, | |
72 args.append('--no-circular-check') | |
73 | |
74 # Default to ninja unless GYP_GENERATORS is set. | |
75 if not os.environ.get('GYP_GENERATORS'): | |
76 os.environ['GYP_GENERATORS'] = 'ninja' | |
77 | |
78 # Enable check for missing sources in GYP files on Windows. | |
79 if sys.platform.startswith('win'): | |
80 gyp_generator_flags = os.getenv('GYP_GENERATOR_FLAGS', '') | |
81 if not 'msvs_error_on_missing_sources' in gyp_generator_flags: | |
82 os.environ['GYP_GENERATOR_FLAGS'] = ( | |
83 gyp_generator_flags + ' msvs_error_on_missing_sources=1') | |
84 | |
85 # Enforce gyp syntax checking. This adds about 20% execution time. | |
86 args.append('--check') | |
87 | |
88 supplemental_includes = GetSupplementalFiles() | |
89 gyp_vars = gyp_chromium.GetGypVars(supplemental_includes) | |
90 | |
91 # Automatically turn on crosscompile support for platforms that need it. | |
92 if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), | |
93 gyp_vars.get('OS') in ['android', 'ios'], | |
94 'GYP_CROSSCOMPILE' not in os.environ)): | |
95 os.environ['GYP_CROSSCOMPILE'] = '1' | |
96 | |
97 args.extend(['-I' + i for i in | |
98 gyp_chromium.additional_include_files(supplemental_includes, | |
99 args)]) | |
100 | |
101 # Set the gyp depth variable to the root of the checkout. | |
102 args.append('--depth=' + os.path.relpath(checkout_root)) | |
103 | |
104 print 'Updating projects from gyp files...' | |
105 sys.stdout.flush() | |
106 | |
107 # Off we go... | |
108 gyp_rc = gyp.main(args) | |
109 | |
110 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | |
111 if vs2013_runtime_dll_dirs: | |
112 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs | |
113 vs_toolchain.CopyVsRuntimeDlls( | |
114 os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), | |
115 (x86_runtime, x64_runtime)) | |
116 | |
117 sys.exit(gyp_rc) | |
118 | |
119 | |
120 if __name__ == '__main__': | |
121 sys.exit(main()) | |
122 | |
OLD | NEW |