blob: fca2ca39b69977b01b105b53bf62271a880bd7f4 [file] [log] [blame]
John Abd-El-Malek6fe4aed2014-05-23 17:13:20 -07001#!/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
10import os
11import platform
12import sys
13
14script_dir = os.path.dirname(os.path.realpath(__file__))
15pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir))
16
17sys.path.insert(0, os.path.join(pdfium_root, 'build', 'gyp', 'pylib'))
18import gyp
19
20
21def run_gyp(args):
22 rc = gyp.main(args)
23 if rc != 0:
24 print 'Error running GYP'
25 sys.exit(rc)
26
27
28def main():
29 args = sys.argv[1:]
30 args.append(os.path.join(script_dir, 'all.gyp'))
Lei Zhangb693fc52015-09-15 16:37:28 -070031
John Abd-El-Malek6fe4aed2014-05-23 17:13:20 -070032 args.append('-I')
33 args.append(os.path.join(pdfium_root, 'build', 'standalone.gypi'))
Lei Zhangb693fc52015-09-15 16:37:28 -070034
John Abd-El-Malek6fe4aed2014-05-23 17:13:20 -070035 args.extend(['-D', 'gyp_output_dir=out'])
36
37 # Set the GYP DEPTH variable to the root of the PDFium project.
38 args.append('--depth=' + os.path.relpath(pdfium_root))
39
Lei Zhangb693fc52015-09-15 16:37:28 -070040 # GYP does not default to ninja, but PDFium should.
41 if not os.environ.get('GYP_GENERATORS', ''):
42 print 'GYP_GENERATORS is not set, defaulting to ninja'
43 os.environ['GYP_GENERATORS'] = 'ninja'
44
John Abd-El-Malek6fe4aed2014-05-23 17:13:20 -070045 print 'Updating projects from gyp files...'
46 sys.stdout.flush()
47
48 run_gyp(args)
49
John Abd-El-Malek961a34a2014-05-28 13:35:54 -070050
John Abd-El-Malek6fe4aed2014-05-23 17:13:20 -070051if __name__ == '__main__':
Lei Zhangb693fc52015-09-15 16:37:28 -070052 sys.exit(main())