summaryrefslogtreecommitdiff
path: root/build/gyp_pdfium
blob: 3dbbbeea75d8b353a7882077c9f1569aa967e710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
#
# Copyright 2014 PDFium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script is wrapper for PDFium that adds some support for how GYP
# is invoked by PDFium beyond what can be done in the gclient hooks.

import os
import platform
import sys

script_dir = os.path.dirname(os.path.realpath(__file__))
pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir))

sys.path.insert(0, os.path.join(pdfium_root, 'build_gyp', 'gyp', 'pylib'))
import gyp


def run_gyp(args):
  rc = gyp.main(args)
  if rc != 0:
    print 'Error running GYP'
    sys.exit(rc)


def main():
  args = sys.argv[1:]
  args.append(os.path.join(pdfium_root, 'build_gyp', 'all.gyp'))

  args.append('-I')
  args.append(os.path.join(pdfium_root, 'build_gyp', 'standalone.gypi'))

  args.extend(['-D', 'gyp_output_dir=out'])

  # Set the GYP DEPTH variable to the root of the PDFium project.
  args.append('--depth=' + os.path.relpath(pdfium_root))

  # GYP does not default to ninja, but PDFium should.
  if not os.environ.get('GYP_GENERATORS', ''):
    print 'GYP_GENERATORS is not set, defaulting to ninja'
    os.environ['GYP_GENERATORS'] = 'ninja'

  print 'Updating projects from gyp files...'
  sys.stdout.flush()

  run_gyp(args)


if __name__ == '__main__':
  sys.exit(main())