OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright 2014 PDFium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
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. | |
9 | |
10 import os | |
11 import platform | |
12 import sys | |
13 | |
14 script_dir = os.path.dirname(os.path.realpath(__file__)) | |
15 pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir)) | |
16 output_rel_dir = 'out' | |
17 | |
18 sys.path.insert(0, os.path.join(pdfium_root, 'tools', 'gyp', 'pylib')) | |
19 import gyp | |
20 | |
21 # vs_toolchain needs to be after gyp path setting since it also uses gyp. | |
22 sys.path.insert(0, os.path.join(pdfium_root, 'build')) | |
23 import vs_toolchain | |
24 | |
25 def run_gyp(args): | |
26 rc = gyp.main(args) | |
27 | |
28 # Copy Windows toolchain DLLs. | |
29 vs_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | |
30 if vs_runtime_dll_dirs: | |
31 x64_runtime, x86_runtime = vs_runtime_dll_dirs | |
32 vs_toolchain.CopyVsRuntimeDlls( | |
33 os.path.join(pdfium_root, output_rel_dir), (x86_runtime, x64_runtime)) | |
34 | |
35 if rc != 0: | |
36 print 'Error running GYP' | |
37 sys.exit(rc) | |
38 | |
39 | |
40 def main(): | |
41 if int(os.environ.get('GYP_PDFIUM_NO_ACTION', 0)): | |
42 print 'Skipping gyp_pdfium due to GYP_PDFIUM_NO_ACTION env var.' | |
43 sys.exit(0) | |
44 | |
45 args = sys.argv[1:] | |
46 args.append(os.path.join(pdfium_root, 'build_gyp', 'all.gyp')) | |
47 | |
48 args.append('-I') | |
49 args.append(os.path.join(pdfium_root, 'build_gyp', 'standalone.gypi')) | |
50 | |
51 args.extend(['-D', 'gyp_output_dir=' + output_rel_dir]) | |
52 | |
53 # Set the GYP DEPTH variable to the root of the PDFium project. | |
54 args.append('--depth=' + os.path.relpath(pdfium_root)) | |
55 | |
56 # GYP does not default to ninja, but PDFium should. | |
57 if not os.environ.get('GYP_GENERATORS', ''): | |
58 print 'GYP_GENERATORS is not set, defaulting to ninja' | |
59 os.environ['GYP_GENERATORS'] = 'ninja' | |
60 | |
61 # Set up the environment variables. | |
62 vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | |
63 | |
64 print 'Updating projects from gyp files...' | |
65 sys.stdout.flush() | |
66 | |
67 run_gyp(args) | |
68 | |
69 | |
70 if __name__ == '__main__': | |
71 sys.exit(main()) | |
OLD | NEW |