Home | History | Annotate | Download | only in chromium
      1 #!/usr/bin/env python
      2 # Copyright (C) 2009 Google Inc. All rights reserved.
      3 #
      4 # Redistribution and use in source and binary forms, with or without
      5 # modification, are permitted provided that the following conditions are
      6 # met:
      7 #
      8 #   * Redistributions of source code must retain the above copyright notice,
      9 #     this list of conditions and the following disclaimer.
     10 #   * Redistributions in binary form must reproduce the above copyright
     11 #     notice, this list of conditions and the following disclaimer in the
     12 #     documentation and/or other materials provided with the distribution.
     13 #   * Neither the name of Google Inc. nor the names of its contributors
     14 #     may be used to endorse or promote products derived from this software
     15 #     without specific prior written permission.
     16 #
     17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28 #
     29 
     30 # This file is used by gclient execute gyp with the proper command
     31 # line arguments.
     32 
     33 import glob
     34 import os
     35 import shlex
     36 import sys
     37 
     38 script_dir = os.path.dirname(__file__)
     39 
     40 sys.path.append(os.path.join(script_dir, 'tools', 'gyp', 'pylib'))
     41 import gyp
     42 
     43 def additional_include_files(args=[]):
     44   """
     45   Returns a list of additional (.gypi) files to include, without
     46   duplicating ones that are already specified on the command line.
     47   """
     48   # Determine the include files specified on the command line.
     49   # This doesn't cover all the different option formats you can use,
     50   # but it's mainly intended to avoid duplicating flags on the automatic
     51   # makefile regeneration which only uses this format.
     52   specified_includes = set()
     53   for arg in args:
     54     if arg.startswith('-I') and len(arg) > 2:
     55       specified_includes.add(os.path.realpath(arg[2:]))
     56 
     57   result = []
     58   def AddInclude(path):
     59     if os.path.realpath(path) not in specified_includes:
     60       result.append(path)
     61 
     62   # Always include common.gypi
     63   AddInclude(os.path.join(script_dir, 'build', 'common.gypi'))
     64 
     65   # Optionally add supplemental .gypi files if present.
     66   supplements = glob.glob(os.path.join(script_dir, '*', 'supplement.gypi'))
     67   for supplement in supplements:
     68     AddInclude(supplement)
     69 
     70   return result
     71 
     72 if __name__ == '__main__':
     73 
     74   args = sys.argv[1:]
     75 
     76   # Add includes.
     77   args.extend(['-I' + i for i in additional_include_files(args)])
     78 
     79   # There shouldn't be a circular dependency relationship between .gyp files,
     80   # but in Chromium's .gyp files, on non-Mac platforms, circular relationships
     81   # currently exist.  The check for circular dependencies is currently
     82   # bypassed on other platforms, but is left enabled on the Mac, where a
     83   # violation of the rule causes Xcode to misbehave badly.
     84   # http://crbug.com/35878.
     85   if sys.platform not in ('darwin',):
     86     args.append('--no-circular-check')
     87 
     88   # On linux, we want gyp to output a makefile (default is scons).
     89   if sys.platform == 'linux2':
     90     args.extend(['-fmake',
     91                  '--suffix=.chromium',
     92                  '--toplevel-dir=../../..',
     93                  # auto_regeneration doesn't work with toplevel-dir
     94                  '-Gauto_regeneration=0'])
     95 
     96   # Other command args:
     97   args.extend([
     98                # gyp variable defines.
     99                '-Dinside_chromium_build=0',
    100                '-Dv8_use_snapshot=false',
    101                '-Dmsvs_use_common_release=0',
    102 
    103                # gyp hack: otherwise gyp assumes its in chromium's src/ dir.
    104                '--depth=./',
    105 
    106                # gyp file to execute.
    107                'WebKit.gyp'])
    108 
    109   print 'Updating webkit projects from gyp files...'
    110   sys.stdout.flush()
    111 
    112   # Off we go...
    113   sys.exit(gyp.main(args))
    114