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))
21 chrome_build_dir = os.path.join(checkout_root, 'build')
23 sys.path.insert(0, chrome_build_dir)
27 sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib'))
31 if __name__ == '__main__':
34 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)):
35 print 'Skipping gyp_webrtc due to GYP_CHROMIUM_NO_ACTION env var.'
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),
42 gyp_helper.apply_gyp_environment_from_file(gyp_env_path)
44 # This could give false positives since it doesn't actually do real option
46 gyp_file_specified = False
48 if arg.endswith('.gyp'):
49 gyp_file_specified = True
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'))
56 # There shouldn't be a circular dependency relationship between .gyp files,
57 args.append('--no-circular-check')
59 # Default to ninja unless GYP_GENERATORS is set.
60 if not os.environ.get('GYP_GENERATORS'):
61 os.environ['GYP_GENERATORS'] = 'ninja'
63 # Enforce gyp syntax checking. This adds about 20% execution time.
64 args.append('--check')
66 supplemental_includes = gyp_chromium.GetSupplementalFiles()
67 if not gyp_chromium.RunGN(supplemental_includes):
69 args.extend(['-I' + i for i in
70 gyp_chromium.additional_include_files(supplemental_includes,
73 # Set the gyp depth variable to the root of the checkout.
74 args.append('--depth=' + os.path.relpath(checkout_root))
76 print 'Updating projects from gyp files...'
80 sys.exit(gyp.main(args))