blob: 64d426ec0e95b7b0047ed3a512453ea8af2dab33 [file] [log] [blame]
fbarchard@google.com4a183602014-03-28 17:26:06 +00001#!/usr/bin/env python
2#
3# Copyright 2014 The LibYuv 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 libyuv. It contains selected parts of the
12# main function from the src/build/gyp_chromium file.
13
14import glob
15import os
16import shlex
17import sys
18
19checkout_root = os.path.dirname(os.path.realpath(__file__))
20
21sys.path.insert(0, os.path.join(checkout_root, 'build'))
22sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools'))
23import gyp_chromium
24import gyp_helper
kjellander@google.com973da212014-04-02 18:01:51 +000025import vs_toolchain
fbarchard@google.com4a183602014-03-28 17:26:06 +000026
27sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib'))
28import gyp
29
30
31if __name__ == '__main__':
32 args = sys.argv[1:]
33
34 # This could give false positives since it doesn't actually do real option
35 # parsing. Oh well.
36 gyp_file_specified = False
37 for arg in args:
38 if arg.endswith('.gyp'):
39 gyp_file_specified = True
40 break
41
42 # If we didn't get a file, assume 'all.gyp' in the root of the checkout.
43 if not gyp_file_specified:
44 args.append(os.path.join(checkout_root, 'all.gyp'))
45
46 # There shouldn't be a circular dependency relationship between .gyp files,
47 args.append('--no-circular-check')
48
49 # Default to ninja unless GYP_GENERATORS is set.
50 if not os.environ.get('GYP_GENERATORS'):
51 os.environ['GYP_GENERATORS'] = 'ninja'
52
fbarchard@google.com05c4c712014-04-11 23:40:41 +000053 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
fbarchard@google.com4a183602014-03-28 17:26:06 +000054
55 # Enforce gyp syntax checking. This adds about 20% execution time.
56 args.append('--check')
57
58 supplemental_includes = gyp_chromium.GetSupplementalFiles()
kjellander@google.com973da212014-04-02 18:01:51 +000059 gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes)
fbarchard@google.com4a183602014-03-28 17:26:06 +000060
61 # Automatically turn on crosscompile support for platforms that need it.
62 if all(('ninja' in os.environ.get('GYP_GENERATORS', ''),
kjellander@google.com973da212014-04-02 18:01:51 +000063 gyp_vars_dict.get('OS') in ['android', 'ios'],
fbarchard@google.com4a183602014-03-28 17:26:06 +000064 'GYP_CROSSCOMPILE' not in os.environ)):
65 os.environ['GYP_CROSSCOMPILE'] = '1'
66
fbarchard@google.com4a183602014-03-28 17:26:06 +000067 args.extend(['-I' + i for i in
68 gyp_chromium.additional_include_files(supplemental_includes,
69 args)])
70
71 # Set the gyp depth variable to the root of the checkout.
72 args.append('--depth=' + os.path.relpath(checkout_root))
73
74 print 'Updating projects from gyp files...'
75 sys.stdout.flush()
76
77 # Off we go...
78 gyp_rc = gyp.main(args)
79
80 if vs2013_runtime_dll_dirs:
81 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
kjellander@google.com973da212014-04-02 18:01:51 +000082 vs_toolchain.CopyVsRuntimeDlls(
fbarchard@google.com4a183602014-03-28 17:26:06 +000083 os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()),
84 (x86_runtime, x64_runtime))
85
86 sys.exit(gyp_rc)