3 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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
7 # tree. An additional intellectual property rights grant can be found
8 # in the file PATENTS. All contributing project authors may
9 # be found in the AUTHORS file in the root of the source tree.
11 # This script is used to run GYP for WebRTC. It contains selected parts of the
12 # main function from the src/build/gyp_chromium file.
19 script_dir = os.path.dirname(os.path.realpath(__file__))
20 checkout_root = os.path.abspath(os.path.join(script_dir, os.pardir, os.pardir))
22 sys.path.insert(0, os.path.join(checkout_root, 'build'))
27 sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib'))
30 def GetSupplementalFiles():
31 """Returns a list of the supplemental files that are included in all GYP
33 # Can't use the one in gyp_chromium since the directory location of the root
35 return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi'))
38 if __name__ == '__main__':
41 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)):
42 print 'Skipping gyp_webrtc due to GYP_CHROMIUM_NO_ACTION env var.'
45 if 'SKIP_WEBRTC_GYP_ENV' not in os.environ:
46 # Update the environment based on webrtc.gyp_env
47 gyp_env_path = os.path.join(os.path.dirname(checkout_root),
49 gyp_helper.apply_gyp_environment_from_file(gyp_env_path)
51 # This could give false positives since it doesn't actually do real option
53 gyp_file_specified = False
55 if arg.endswith('.gyp'):
56 gyp_file_specified = True
59 # If we didn't get a file, assume 'all.gyp' in the root of the checkout.
60 if not gyp_file_specified:
61 # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't
62 # work, but chdir'ing and adding the relative path does. Spooky :/
63 os.chdir(checkout_root)
64 args.append('all.gyp')
66 # There shouldn't be a circular dependency relationship between .gyp files,
67 args.append('--no-circular-check')
69 # Default to ninja unless GYP_GENERATORS is set.
70 if not os.environ.get('GYP_GENERATORS'):
71 os.environ['GYP_GENERATORS'] = 'ninja'
73 vs2013_runtime_dll_dirs = None
74 if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')):
75 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
77 # Enforce gyp syntax checking. This adds about 20% execution time.
78 args.append('--check')
80 supplemental_includes = GetSupplementalFiles()
81 gn_vars_dict = gyp_chromium.GetGypVars(supplemental_includes)
83 # Automatically turn on crosscompile support for platforms that need it.
84 if all(('ninja' in os.environ.get('GYP_GENERATORS', ''),
85 gn_vars_dict.get('OS') in ['android', 'ios'],
86 'GYP_CROSSCOMPILE' not in os.environ)):
87 os.environ['GYP_CROSSCOMPILE'] = '1'
89 args.extend(['-I' + i for i in
90 gyp_chromium.additional_include_files(supplemental_includes,
93 # Set the gyp depth variable to the root of the checkout.
94 args.append('--depth=' + os.path.relpath(checkout_root))
96 print 'Updating projects from gyp files...'
100 gyp_rc = gyp.main(args)
102 if vs2013_runtime_dll_dirs:
103 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
104 vs_toolchain.CopyVsRuntimeDlls(
105 os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()),
106 (x86_runtime, x64_runtime))