summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 22:21:47 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 22:21:47 +0000
commit525c485c39044c13dd7fb08b6e90f2c2899626b0 (patch)
treea46d27f76413eed595016d5dbe69c7912afae570 /webkit
parentcddf7b3843b2af971a8b48d5b53f87d3fea0064b (diff)
downloadchromium_src-525c485c39044c13dd7fb08b6e90f2c2899626b0.zip
chromium_src-525c485c39044c13dd7fb08b6e90f2c2899626b0.tar.gz
chromium_src-525c485c39044c13dd7fb08b6e90f2c2899626b0.tar.bz2
Use forwarding headers instead of copying header files
for webkit.org checkouts. This avoid the chance of someone accidentally editing a file in WebKit/chromium/third_party/WebKit/ or the files being out of date. BUG=56677 Review URL: http://codereview.chromium.org/3961001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/support/list_headers.py23
-rw-r--r--webkit/support/setup_third_party.gyp86
-rw-r--r--webkit/support/setup_third_party.py128
3 files changed, 172 insertions, 65 deletions
diff --git a/webkit/support/list_headers.py b/webkit/support/list_headers.py
index c7397b5..e69de29 100644
--- a/webkit/support/list_headers.py
+++ b/webkit/support/list_headers.py
@@ -1,23 +0,0 @@
-#!/usr/bin/python
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""A helper script that lists the header files in the passed in argument.
-This is used by gyp to get a list of header files to copy."""
-
-import os
-import sys
-
-def main(argv):
- if len(argv) != 2:
- print 'USAGE: %s <dir>'
- return 1
-
- for filename in os.listdir(argv[1]):
- if filename.endswith('.h'):
- print os.path.join(argv[1], filename)
- return 0
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/webkit/support/setup_third_party.gyp b/webkit/support/setup_third_party.gyp
index c5cce6c..cf9d540 100644
--- a/webkit/support/setup_third_party.gyp
+++ b/webkit/support/setup_third_party.gyp
@@ -4,59 +4,61 @@
{
'variables': {
- 'list_headers_cmd': ['python', 'list_headers.py'],
- 'destination': '<(DEPTH)/third_party/WebKit/WebKit/chromium/public',
+ 'setup_third_party_cmd': ['python', 'setup_third_party.py'],
+ 'destination': '<(SHARED_INTERMEDIATE_DIR)/webkit/third_party/WebKit/WebKit/chromium/public',
+ 'destination_mac': '<(SHARED_INTERMEDIATE_DIR)/webkit/third_party/WebKit/WebKit/mac/WebCoreSupport',
},
'targets': [
{
- # TODO(tony): Would be nice if this would make symlinks on linux/mac
- # and try to make hardlinks on ntfs.
'target_name': 'third_party_headers',
'type': 'none',
- 'copies': [
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)/webkit',
+ ],
+ },
+ 'actions': [
{
- 'destination': '<(destination)',
- 'files': [
- '<!@(<(list_headers_cmd) <(DEPTH)/public/)',
+ 'action_name': 'third_party_forwarding_headers',
+ 'inputs': [
+ '<!@(<(setup_third_party_cmd) inputs <(DEPTH)/public)',
+ 'setup_third_party.py',
],
- },
- {
- 'destination': '<(destination)/gtk',
- 'files': [
- '<!@(<(list_headers_cmd) <(DEPTH)/public/gtk/)',
- ],
- },
- {
- 'destination': '<(destination)/linux',
- 'files': [
- '<!@(<(list_headers_cmd) <(DEPTH)/public/linux/)',
+ 'outputs': [
+ "<!@(<(setup_third_party_cmd) outputs <(DEPTH)/public '<(destination)')",
],
- },
- {
- 'destination': '<(destination)/mac',
- 'files': [
- '<!@(<(list_headers_cmd) <(DEPTH)/public/mac/)',
+ 'action': [
+ '<@(setup_third_party_cmd)',
+ 'setup_headers',
+ '<(DEPTH)/public',
+ '<(destination)',
],
+ 'message': 'Generating forwarding headers for third_party/WebKit/WebKit/chromium/public',
},
- {
- 'destination': '<(destination)/win',
- 'files': [
- '<!@(<(list_headers_cmd) <(DEPTH)/public/win/)',
+ ],
+ 'conditions': [
+ ['OS=="mac"', {
+ 'actions': [
+ {
+ 'action_name': 'third_party_mac_forwarding_headers',
+ 'inputs': [
+ '<!@(<(setup_third_party_cmd) inputs <(DEPTH)/../mac/WebCoreSupport)',
+ 'setup_third_party.py',
+ ],
+ 'outputs': [
+ "<!@(<(setup_third_party_cmd) outputs <(DEPTH)/../mac/WebCoreSupport '<(destination_mac)')",
+ ],
+ 'action': [
+ '<@(setup_third_party_cmd)',
+ 'setup_headers',
+ '<(DEPTH)/../mac/WebCoreSupport',
+ '<(destination_mac)',
+ ],
+ 'message': 'Generating forwarding headers for third_party/WebKit/WebKit/mac/WebCoreSupport',
+ },
],
- },
- {
- 'destination': '<(destination)/x11',
- 'files': [
- '<!@(<(list_headers_cmd) <(DEPTH)/public/x11/)',
- ],
- },
- {
- 'destination': '<(DEPTH)/third_party/WebKit/WebKit/mac/WebCoreSupport',
- 'files': [
- '<(DEPTH)/../mac/WebCoreSupport/WebSystemInterface.h',
- ],
- },
- ]
+ }],
+ ],
},
],
}
diff --git a/webkit/support/setup_third_party.py b/webkit/support/setup_third_party.py
new file mode 100644
index 0000000..172ece7
--- /dev/null
+++ b/webkit/support/setup_third_party.py
@@ -0,0 +1,128 @@
+#!/usr/bin/python
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"A helper script for setting up forwarding headers."""
+
+import errno
+import os
+import sys
+
+
+def GetHeaderFilesInDir(dir_path):
+ """Return a list of all header files in dir_path."""
+ all_files = []
+ for root, dirs, files in os.walk(dir_path):
+ all_files.extend([os.path.join(root, f) for f in files if f.endswith('.h')])
+ return all_files
+
+
+def Inputs(args):
+ """List the files in the provided input dir.
+
+ args: A list with 1 value, the input dir.
+ Returns: 0 on success, other value on error."""
+ if len(args) != 1:
+ print "'inputs' expects only one input directory."
+ return -1
+
+ for filename in GetHeaderFilesInDir(args[0]):
+ print filename
+ return 0
+
+
+def Outputs(args):
+ """Takes an input dir and an output dir and figures out new output files
+ based on copying from the input dir to the output dir.
+
+ args: A list with 2 values, the input dir and the output dir.
+ Returns: 0 on success, other value on error."""
+ if len(args) != 2:
+ print "'outputs' expects an input directory and an output directory."
+ return -1
+
+ base_input_dir = args[0]
+ output_dir = args[1]
+ input_files = GetHeaderFilesInDir(base_input_dir)
+ for filename in input_files:
+ rel_path = filename[len(base_input_dir) + 1:]
+ print os.path.join(output_dir, rel_path)
+
+
+def SetupHeaders(args):
+ """Takes an input dir and an output dir and sets up forwarding headers
+ from output dir to files in input dir.
+ args: A list with 2 values, the input dir and the output dir.
+ Returns: 0 on success, other value on error."""
+ if len(args) != 2:
+ print "'setup_headers' expects an input directory and an output directory."
+ return -1
+
+ base_input_dir = args[0]
+ output_dir = args[1]
+ input_files = GetHeaderFilesInDir(base_input_dir)
+ for input_filename in input_files:
+ rel_path = input_filename[len(base_input_dir) + 1:]
+ out_filename = os.path.join(output_dir, rel_path)
+ TryToMakeDir(os.path.split(out_filename)[0])
+ WriteSetupFilename(input_filename, out_filename)
+
+
+def TryToMakeDir(dir_name):
+ """Create the directory dir_name if it doesn't exist."""
+ try:
+ os.makedirs(dir_name)
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ raise e
+
+
+def NormalizePath(path):
+ """Normalize path for use with os.path.commonprefix.
+ On windows, this makes sure that the drive letters are always in the
+ same case."""
+ abs_path = os.path.abspath(path)
+ drive, rest = os.path.splitdrive(abs_path)
+ return os.path.join(drive.lower(), rest)
+
+
+def WriteSetupFilename(input_filename, out_filename):
+ """Create a forwarding header from out_filename to input_filename."""
+ # Figure out the relative path from out_filename to input_filename.
+ # We can't use os.path.relpath since that's a python2.6 feature and we
+ # support python 2.5.
+ input_filename = NormalizePath(input_filename)
+ out_filename = NormalizePath(out_filename)
+ ancestor = os.path.commonprefix([input_filename, out_filename])
+
+ assert os.path.isdir(ancestor)
+ num_parent_dirs = 0
+ out_dir = os.path.split(out_filename)[0]
+ while os.path.normpath(ancestor) != os.path.normpath(out_dir):
+ num_parent_dirs += 1
+ out_dir = os.path.split(out_dir)[0]
+
+ rel_path = os.path.join('/'.join(['..'] * num_parent_dirs),
+ input_filename[len(ancestor):])
+
+ out_file = open(out_filename, 'w')
+ out_file.write("""// This file is generated. Do not edit.
+#include "%s"
+""" % rel_path)
+ out_file.close()
+
+
+def Main(argv):
+ commands = {
+ 'inputs': Inputs,
+ 'outputs': Outputs,
+ 'setup_headers': SetupHeaders,
+ }
+ command = argv[1]
+ args = argv[2:]
+ return commands[command](args)
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))