Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / build / gyp_webrtc
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 chrome_build_dir = os.path.join(checkout_root, 'build')
22
23 sys.path.insert(0, chrome_build_dir)
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
63   # Enforce gyp syntax checking. This adds about 20% execution time.
64   args.append('--check')
65
66   supplemental_includes = gyp_chromium.GetSupplementalFiles()
67   if not gyp_chromium.RunGN(supplemental_includes):
68     sys.exit(1)
69   args.extend(['-I' + i for i in
70                gyp_chromium.additional_include_files(supplemental_includes,
71                                                      args)])
72
73   # Set the gyp depth variable to the root of the checkout.
74   args.append('--depth=' + os.path.relpath(checkout_root))
75
76   print 'Updating projects from gyp files...'
77   sys.stdout.flush()
78
79   # Off we go...
80   sys.exit(gyp.main(args))