1#!/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')) 22import gyp_chromium 23import gyp_helper 24import vs_toolchain 25 26sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib')) 27import gyp 28 29def GetSupplementalFiles(): 30 """Returns a list of the supplemental files that are included in all GYP 31 sources.""" 32 # Can't use the one in gyp_chromium since the directory location of the root 33 # is different. 34 return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi')) 35 36 37if __name__ == '__main__': 38 args = sys.argv[1:] 39 40 if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): 41 print 'Skipping gyp_libyuv due to GYP_CHROMIUM_NO_ACTION env var.' 42 sys.exit(0) 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 # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't 55 # work, but chdir'ing and adding the relative path does. Spooky :/ 56 os.chdir(checkout_root) 57 args.append('all.gyp') 58 59 # There shouldn't be a circular dependency relationship between .gyp files, 60 args.append('--no-circular-check') 61 62 # Default to ninja unless GYP_GENERATORS is set. 63 if not os.environ.get('GYP_GENERATORS'): 64 os.environ['GYP_GENERATORS'] = 'ninja' 65 66 vs2013_runtime_dll_dirs = None 67 if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')): 68 vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() 69 70 # Enforce gyp syntax checking. This adds about 20% execution time. 71 args.append('--check') 72 73 supplemental_includes = gyp_chromium.GetSupplementalFiles() 74 gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes) 75 76 # Automatically turn on crosscompile support for platforms that need it. 77 if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), 78 gyp_vars_dict.get('OS') in ['android', 'ios'], 79 'GYP_CROSSCOMPILE' not in os.environ)): 80 os.environ['GYP_CROSSCOMPILE'] = '1' 81 82 args.extend(['-I' + i for i in 83 gyp_chromium.additional_include_files(supplemental_includes, 84 args)]) 85 86 # Set the gyp depth variable to the root of the checkout. 87 args.append('--depth=' + os.path.relpath(checkout_root)) 88 89 print 'Updating projects from gyp files...' 90 sys.stdout.flush() 91 92 # Off we go... 93 gyp_rc = gyp.main(args) 94 95 if vs2013_runtime_dll_dirs: 96 x64_runtime, x86_runtime = vs2013_runtime_dll_dirs 97 vs_toolchain.CopyVsRuntimeDlls( 98 os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), 99 (x86_runtime, x64_runtime)) 100 101 sys.exit(gyp_rc) 102