| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 PDFium Authors. All rights reserved. | 3 # Copyright 2014 PDFium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This script is wrapper for PDFium that adds some support for how GYP | 7 # This script is wrapper for PDFium that adds some support for how GYP |
| 8 # is invoked by PDFium beyond what can be done in the gclient hooks. | 8 # is invoked by PDFium beyond what can be done in the gclient hooks. |
| 9 | 9 |
| 10 import os | 10 import os |
| 11 import platform | 11 import platform |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 script_dir = os.path.dirname(os.path.realpath(__file__)) | 14 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 15 pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir)) | 15 pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| 16 | 16 |
| 17 sys.path.insert(0, os.path.join(pdfium_root, 'tools', 'gyp', 'pylib')) | 17 sys.path.insert(0, os.path.join(pdfium_root, 'tools', 'gyp', 'pylib')) |
| 18 import gyp | 18 import gyp |
| 19 | 19 |
| 20 | 20 |
| 21 def run_gyp(args): | 21 def run_gyp(args): |
| 22 rc = gyp.main(args) | 22 rc = gyp.main(args) |
| 23 if rc != 0: | 23 if rc != 0: |
| 24 print 'Error running GYP' | 24 print 'Error running GYP' |
| 25 sys.exit(rc) | 25 sys.exit(rc) |
| 26 | 26 |
| 27 | 27 |
| 28 def main(): | 28 def main(): |
| 29 if int(os.environ.get('GYP_PDFIUM_NO_ACTION', 0)): |
| 30 print 'Skipping gyp_pdfium due to GYP_PDFIUM_NO_ACTION env var.' |
| 31 sys.exit(0) |
| 32 |
| 29 args = sys.argv[1:] | 33 args = sys.argv[1:] |
| 30 args.append(os.path.join(pdfium_root, 'build_gyp', 'all.gyp')) | 34 args.append(os.path.join(pdfium_root, 'build_gyp', 'all.gyp')) |
| 31 | 35 |
| 32 args.append('-I') | 36 args.append('-I') |
| 33 args.append(os.path.join(pdfium_root, 'build_gyp', 'standalone.gypi')) | 37 args.append(os.path.join(pdfium_root, 'build_gyp', 'standalone.gypi')) |
| 34 | 38 |
| 35 args.extend(['-D', 'gyp_output_dir=out']) | 39 args.extend(['-D', 'gyp_output_dir=out']) |
| 36 | 40 |
| 37 # Set the GYP DEPTH variable to the root of the PDFium project. | 41 # Set the GYP DEPTH variable to the root of the PDFium project. |
| 38 args.append('--depth=' + os.path.relpath(pdfium_root)) | 42 args.append('--depth=' + os.path.relpath(pdfium_root)) |
| 39 | 43 |
| 40 # GYP does not default to ninja, but PDFium should. | 44 # GYP does not default to ninja, but PDFium should. |
| 41 if not os.environ.get('GYP_GENERATORS', ''): | 45 if not os.environ.get('GYP_GENERATORS', ''): |
| 42 print 'GYP_GENERATORS is not set, defaulting to ninja' | 46 print 'GYP_GENERATORS is not set, defaulting to ninja' |
| 43 os.environ['GYP_GENERATORS'] = 'ninja' | 47 os.environ['GYP_GENERATORS'] = 'ninja' |
| 44 | 48 |
| 45 print 'Updating projects from gyp files...' | 49 print 'Updating projects from gyp files...' |
| 46 sys.stdout.flush() | 50 sys.stdout.flush() |
| 47 | 51 |
| 48 run_gyp(args) | 52 run_gyp(args) |
| 49 | 53 |
| 50 | 54 |
| 51 if __name__ == '__main__': | 55 if __name__ == '__main__': |
| 52 sys.exit(main()) | 56 sys.exit(main()) |
| OLD | NEW |