Home | History | Annotate | Download | only in libyuv
      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 
     14 import glob
     15 import os
     16 import shlex
     17 import sys
     18 
     19 checkout_root = os.path.dirname(os.path.realpath(__file__))
     20 
     21 sys.path.insert(0, os.path.join(checkout_root, 'build'))
     22 sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools'))
     23 import gyp_chromium
     24 import gyp_helper
     25 import vs_toolchain
     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   # 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 
     53   vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
     54 
     55   # Enforce gyp syntax checking. This adds about 20% execution time.
     56   args.append('--check')
     57 
     58   supplemental_includes = gyp_chromium.GetSupplementalFiles()
     59   gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes)
     60 
     61   # Automatically turn on crosscompile support for platforms that need it.
     62   if all(('ninja' in os.environ.get('GYP_GENERATORS', ''),
     63           gyp_vars_dict.get('OS') in ['android', 'ios'],
     64           'GYP_CROSSCOMPILE' not in os.environ)):
     65     os.environ['GYP_CROSSCOMPILE'] = '1'
     66 
     67   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
     82     vs_toolchain.CopyVsRuntimeDlls(
     83         os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()),
     84         (x86_runtime, x64_runtime))
     85 
     86   sys.exit(gyp_rc)
     87