kjellander@webrtc.org | 7d7f089 | 2014-01-31 09:34:51 +0000 | [diff] [blame] | 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)) |
kjellander@webrtc.org | 7d7f089 | 2014-01-31 09:34:51 +0000 | [diff] [blame] | 21 | |
kjellander@webrtc.org | 6b0cbcb | 2014-03-10 09:51:17 +0000 | [diff] [blame] | 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')) |
kjellander@webrtc.org | 7d7f089 | 2014-01-31 09:34:51 +0000 | [diff] [blame] | 24 | import gyp_chromium |
| 25 | import gyp_helper |
| 26 | |
| 27 | sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib')) |
| 28 | import gyp |
| 29 | |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | args = sys.argv[1:] |
| 33 | |
| 34 | if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): |
| 35 | print 'Skipping gyp_webrtc due to GYP_CHROMIUM_NO_ACTION env var.' |
| 36 | sys.exit(0) |
| 37 | |
| 38 | if 'SKIP_WEBRTC_GYP_ENV' not in os.environ: |
| 39 | # Update the environment based on webrtc.gyp_env |
| 40 | gyp_env_path = os.path.join(os.path.dirname(checkout_root), |
| 41 | 'webrtc.gyp_env') |
| 42 | gyp_helper.apply_gyp_environment_from_file(gyp_env_path) |
| 43 | |
| 44 | # This could give false positives since it doesn't actually do real option |
| 45 | # parsing. Oh well. |
| 46 | gyp_file_specified = False |
| 47 | for arg in args: |
| 48 | if arg.endswith('.gyp'): |
| 49 | gyp_file_specified = True |
| 50 | break |
| 51 | |
| 52 | # If we didn't get a file, assume 'all.gyp' in the root of the checkout. |
| 53 | if not gyp_file_specified: |
| 54 | args.append(os.path.join(checkout_root, 'all.gyp')) |
| 55 | |
| 56 | # There shouldn't be a circular dependency relationship between .gyp files, |
| 57 | args.append('--no-circular-check') |
| 58 | |
| 59 | # Default to ninja unless GYP_GENERATORS is set. |
| 60 | if not os.environ.get('GYP_GENERATORS'): |
| 61 | os.environ['GYP_GENERATORS'] = 'ninja' |
| 62 | |
kjellander@webrtc.org | c2313fb | 2014-03-12 14:41:58 +0000 | [diff] [blame] | 63 | vs2013_runtime_dll_dirs = gyp_chromium.DownloadVsToolChain() |
kjellander@webrtc.org | 6b0cbcb | 2014-03-10 09:51:17 +0000 | [diff] [blame] | 64 | |
kjellander@webrtc.org | 7d7f089 | 2014-01-31 09:34:51 +0000 | [diff] [blame] | 65 | # Enforce gyp syntax checking. This adds about 20% execution time. |
| 66 | args.append('--check') |
| 67 | |
| 68 | supplemental_includes = gyp_chromium.GetSupplementalFiles() |
kjellander@webrtc.org | 6b0cbcb | 2014-03-10 09:51:17 +0000 | [diff] [blame] | 69 | gn_vars_dict = gyp_chromium.GetGypVarsForGN(supplemental_includes) |
| 70 | |
| 71 | # Automatically turn on crosscompile support for platforms that need it. |
| 72 | if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), |
| 73 | gn_vars_dict.get('OS') in ['android', 'ios'], |
| 74 | 'GYP_CROSSCOMPILE' not in os.environ)): |
| 75 | os.environ['GYP_CROSSCOMPILE'] = '1' |
| 76 | |
| 77 | if not gyp_chromium.RunGN(gn_vars_dict): |
kjellander@webrtc.org | 7d7f089 | 2014-01-31 09:34:51 +0000 | [diff] [blame] | 78 | sys.exit(1) |
| 79 | args.extend(['-I' + i for i in |
| 80 | gyp_chromium.additional_include_files(supplemental_includes, |
| 81 | args)]) |
| 82 | |
| 83 | # Set the gyp depth variable to the root of the checkout. |
| 84 | args.append('--depth=' + os.path.relpath(checkout_root)) |
| 85 | |
| 86 | print 'Updating projects from gyp files...' |
| 87 | sys.stdout.flush() |
| 88 | |
| 89 | # Off we go... |
kjellander@webrtc.org | 6b0cbcb | 2014-03-10 09:51:17 +0000 | [diff] [blame] | 90 | gyp_rc = gyp.main(args) |
| 91 | |
| 92 | if vs2013_runtime_dll_dirs: |
| 93 | x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
| 94 | gyp_chromium.CopyVsRuntimeDlls( |
| 95 | os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), |
| 96 | (x86_runtime, x64_runtime)) |
| 97 | |
| 98 | sys.exit(gyp_rc) |