2
0

gyp_libyuv 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # This script is used to run GYP for libyuv. It contains selected parts of the
  11. # main function from the src/build/gyp_chromium file.
  12. import glob
  13. import os
  14. import shlex
  15. import sys
  16. checkout_root = os.path.dirname(os.path.realpath(__file__))
  17. sys.path.insert(0, os.path.join(checkout_root, 'build'))
  18. import gyp_chromium
  19. import gyp_helper
  20. import vs_toolchain
  21. sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib'))
  22. import gyp
  23. def GetSupplementalFiles():
  24. """Returns a list of the supplemental files that are included in all GYP
  25. sources."""
  26. # Can't use the one in gyp_chromium since the directory location of the root
  27. # is different.
  28. return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi'))
  29. if __name__ == '__main__':
  30. args = sys.argv[1:]
  31. if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)):
  32. print 'Skipping gyp_libyuv due to GYP_CHROMIUM_NO_ACTION env var.'
  33. sys.exit(0)
  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. # If we didn't get a file, assume 'all.gyp' in the root of the checkout.
  42. if not gyp_file_specified:
  43. # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't
  44. # work, but chdir'ing and adding the relative path does. Spooky :/
  45. os.chdir(checkout_root)
  46. args.append('all.gyp')
  47. # There shouldn't be a circular dependency relationship between .gyp files,
  48. args.append('--no-circular-check')
  49. # Default to ninja unless GYP_GENERATORS is set.
  50. if not os.environ.get('GYP_GENERATORS'):
  51. os.environ['GYP_GENERATORS'] = 'ninja'
  52. vs2013_runtime_dll_dirs = None
  53. if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')):
  54. vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
  55. # Enforce gyp syntax checking. This adds about 20% execution time.
  56. args.append('--check')
  57. supplemental_includes = gyp_chromium.GetSupplementalFiles()
  58. gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes)
  59. # Automatically turn on crosscompile support for platforms that need it.
  60. if all(('ninja' in os.environ.get('GYP_GENERATORS', ''),
  61. gyp_vars_dict.get('OS') in ['android', 'ios'],
  62. 'GYP_CROSSCOMPILE' not in os.environ)):
  63. os.environ['GYP_CROSSCOMPILE'] = '1'
  64. args.extend(['-I' + i for i in
  65. gyp_chromium.additional_include_files(supplemental_includes,
  66. args)])
  67. # Set the gyp depth variable to the root of the checkout.
  68. args.append('--depth=' + os.path.relpath(checkout_root))
  69. print 'Updating projects from gyp files...'
  70. sys.stdout.flush()
  71. # Off we go...
  72. gyp_rc = gyp.main(args)
  73. if vs2013_runtime_dll_dirs:
  74. x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
  75. vs_toolchain.CopyVsRuntimeDlls(
  76. os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()),
  77. (x86_runtime, x64_runtime))
  78. sys.exit(gyp_rc)