| Index: tools/grit/grit_info.py
|
| diff --git a/tools/grit/grit_info.py b/tools/grit/grit_info.py
|
| index c0e0ed8e61247318b49ee855c454d69572d3ac4c..235867bf7aa383573712205d03fddd284ec67b49 100755
|
| --- a/tools/grit/grit_info.py
|
| +++ b/tools/grit/grit_info.py
|
| @@ -14,6 +14,89 @@ import sys
|
| from grit import grd_reader
|
| from grit import util
|
|
|
| +##############################################################################
|
| +# os.path.relpath is python 2.6 only. Some bots still run 2.5 only, so I took
|
| +# the relpath implementation from the python source.
|
| +# TODO(thakis): Once we're on 2.6 everywhere, remove this and use
|
| +# os.path.relpath directly.
|
| +
|
| +# http://docs.python.org/license.html
|
| +# PSF LICENSE AGREEMENT FOR PYTHON 2.7.1
|
| +#
|
| +# 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"),
|
| +# and the Individual or Organization ("Licensee") accessing and otherwise using
|
| +# Python 2.7.1 software in source or binary form and its associated
|
| +# documentation.
|
| +#
|
| +# 2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
| +# grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
| +# analyze, test, perform and/or display publicly, prepare derivative works,
|
| +# distribute, and otherwise use Python 2.7.1 alone or in any derivative version,
|
| +# provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
| +# i.e., "Copyright © 2001-2010 Python Software Foundation; All Rights Reserved"
|
| +# are retained in Python 2.7.1 alone or in any derivative version prepared by
|
| +# Licensee.
|
| +#
|
| +# 3. In the event Licensee prepares a derivative work that is based on or
|
| +# incorporates Python 2.7.1 or any part thereof, and wants to make the
|
| +# derivative work available to others as provided herein, then Licensee hereby
|
| +# agrees to include in any such work a brief summary of the changes made to
|
| +# Python 2.7.1.
|
| +#
|
| +# 4. PSF is making Python 2.7.1 available to Licensee on an "AS IS" basis. PSF
|
| +# MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
| +# BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY
|
| +# OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
|
| +# PYTHON 2.7.1 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
|
| +#
|
| +# 5.1 PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 2.7.1 FOR
|
| +# ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
|
| +# MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.7.1, OR ANY DERIVATIVE
|
| +# THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| +#
|
| +# 6. This License Agreement will automatically terminate upon a material breach
|
| +# of its terms and conditions.
|
| +#
|
| +# 7. Nothing in this License Agreement shall be deemed to create any
|
| +# relationship of agency, partnership, or joint venture between PSF and
|
| +# Licensee. This License Agreement does not grant permission to use PSF
|
| +# trademarks or trade name in a trademark sense to endorse or promote products
|
| +# or services of Licensee, or any third party.
|
| +#
|
| +# 8. By copying, installing or otherwise using Python 2.7.1, Licensee agrees to
|
| +# be bound by the terms and conditions of this License Agreement.
|
| +
|
| +# http://svn.python.org/view/python/trunk/Lib/genericpath.py?view=markup
|
| +def commonprefix(m):
|
| + "Given a list of pathnames, returns the longest common leading component"
|
| + if not m: return ''
|
| + s1 = min(m)
|
| + s2 = max(m)
|
| + for i, c in enumerate(s1):
|
| + if c != s2[i]:
|
| + return s1[:i]
|
| + return s1
|
| +
|
| +
|
| +# http://svn.python.org/view/python/trunk/Lib/posixpath.py?view=markup
|
| +def relpath(path, start=os.path.curdir):
|
| + """Return a relative version of a path"""
|
| +
|
| + if not path:
|
| + raise ValueError("no path specified")
|
| +
|
| + start_list = os.path.abspath(start).split(os.path.sep)
|
| + path_list = os.path.abspath(path).split(os.path.sep)
|
| +
|
| + # Work out how much of the filepath is shared by start and path.
|
| + i = len(commonprefix([start_list, path_list]))
|
| +
|
| + rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
|
| + if not rel_list:
|
| + return curdir
|
| + return os.path.join(*rel_list)
|
| +##############################################################################
|
| +
|
|
|
| def Outputs(filename, defines):
|
| grd = grd_reader.Parse(
|
| @@ -66,7 +149,7 @@ def Inputs(filename, defines):
|
|
|
| # Add in the grit source files. If one of these change, we want to re-run
|
| # grit.
|
| - grit_root_dir = os.path.dirname(__file__)
|
| + grit_root_dir = relpath(os.path.dirname(__file__), os.getcwd())
|
| for root, dirs, filenames in os.walk(grit_root_dir):
|
| grit_src = [os.path.join(root, f) for f in filenames
|
| if f.endswith('.py') or f == 'resource_ids']
|
|
|