1 #!/usr/bin/env python 2 # 3 # Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 4 # 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. 10 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. 13 14 import glob 15 import os 16 import shlex 17 import sys 18 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)) 21 22 sys.path.insert(0, os.path.join(checkout_root, 'build')) 23 sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools')) 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 32 if __name__ == '__main__': 33 args = sys.argv[1:] 34 35 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): 36 print 'Skipping gyp_webrtc due to GYP_CHROMIUM_NO_ACTION env var.' 37 sys.exit(0) 38 39 if 'SKIP_WEBRTC_GYP_ENV' not in os.environ: 40 # Update the environment based on webrtc.gyp_env 41 gyp_env_path = os.path.join(os.path.dirname(checkout_root), 42 'webrtc.gyp_env') 43 gyp_helper.apply_gyp_environment_from_file(gyp_env_path) 44 45 # This could give false positives since it doesn't actually do real option 46 # parsing. Oh well. 47 gyp_file_specified = False 48 for arg in args: 49 if arg.endswith('.gyp'): 50 gyp_file_specified = True 51 break 52 53 # If we didn't get a file, assume 'all.gyp' in the root of the checkout. 54 if not gyp_file_specified: 55 args.append(os.path.join(checkout_root, 'all.gyp')) 56 57 # There shouldn't be a circular dependency relationship between .gyp files, 58 args.append('--no-circular-check') 59 60 # Default to ninja unless GYP_GENERATORS is set. 61 if not os.environ.get('GYP_GENERATORS'): 62 os.environ['GYP_GENERATORS'] = 'ninja' 63 64 vs2013_runtime_dll_dirs = None 65 if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')): 66 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() 67 68 # Enforce gyp syntax checking. This adds about 20% execution time. 69 args.append('--check') 70 71 supplemental_includes = gyp_chromium.GetSupplementalFiles() 72 gn_vars_dict = gyp_chromium.GetGypVars(supplemental_includes) 73 74 # Automatically turn on crosscompile support for platforms that need it. 75 if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), 76 gn_vars_dict.get('OS') in ['android', 'ios'], 77 'GYP_CROSSCOMPILE' not in os.environ)): 78 os.environ['GYP_CROSSCOMPILE'] = '1' 79 80 args.extend(['-I' + i for i in 81 gyp_chromium.additional_include_files(supplemental_includes, 82 args)]) 83 84 # Set the gyp depth variable to the root of the checkout. 85 args.append('--depth=' + os.path.relpath(checkout_root)) 86 87 print 'Updating projects from gyp files...' 88 sys.stdout.flush() 89 90 # Off we go... 91 gyp_rc = gyp.main(args) 92 93 if vs2013_runtime_dll_dirs: 94 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs 95 vs_toolchain.CopyVsRuntimeDlls( 96 os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), 97 (x86_runtime, x64_runtime)) 98 99 sys.exit(gyp_rc) 100