2010-09-01 Andras Becsi <abecsi@webkit.org>
authorabecsi@webkit.org <abecsi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Sep 2010 10:55:31 +0000 (10:55 +0000)
committerabecsi@webkit.org <abecsi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Sep 2010 10:55:31 +0000 (10:55 +0000)
        Reviewed by Antti Koivisto.

        [Qt] Auto-generate WebKit2 forwarding headers
        https://bugs.webkit.org/show_bug.cgi?id=44692

        * MiniBrowser/qt/BrowserWindow.h: use source style includes
        * MiniBrowser/qt/MiniBrowser.pro: add missing include paths
        * Scripts/enumerate-included-framework-headers: Removed.
2010-09-01  Andras Becsi  <abecsi@webkit.org>

        Reviewed by Antti Koivisto.

        [Qt] Auto-generate WebKit2 forwarding headers
        https://bugs.webkit.org/show_bug.cgi?id=44692

        * DerivedSources.pro: let the generate-forwarding-headers.pl
        script generate forwarding headers.
        * generate-forwarding-headers.pl: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66592 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/DerivedSources.pro
WebKit2/generate-forwarding-headers.pl [new file with mode: 0755]
WebKitTools/ChangeLog
WebKitTools/MiniBrowser/qt/BrowserWindow.h
WebKitTools/MiniBrowser/qt/MiniBrowser.pro
WebKitTools/Scripts/enumerate-included-framework-headers [deleted file]

index 8c5f505..a23f4f7 100644 (file)
@@ -1,3 +1,14 @@
+2010-09-01  Andras Becsi  <abecsi@webkit.org>
+
+        Reviewed by Antti Koivisto.
+
+        [Qt] Auto-generate WebKit2 forwarding headers
+        https://bugs.webkit.org/show_bug.cgi?id=44692
+
+        * DerivedSources.pro: let the generate-forwarding-headers.pl
+        script generate forwarding headers.
+        * generate-forwarding-headers.pl: Added.
+
 2010-08-31  Dave Hyatt  <hyatt@apple.com>
 
         Reviewed by Sam Weinig.
index 2970780..0b3c0f1 100644 (file)
@@ -3,10 +3,6 @@ TARGET = dummy
 
 CONFIG -= debug_and_release
 
-WEBCORE_HEADERS_FOR_WEBKIT2 = $$system(../WebKitTools/Scripts/enumerate-included-framework-headers WebCore)
-JSC_HEADERS_FOR_WEBKIT2 = $$system(../WebKitTools/Scripts/enumerate-included-framework-headers JavaScriptCore)
-WEBKIT2_API_HEADERS = $$system(../WebKitTools/Scripts/enumerate-included-framework-headers WebKit2)
-
 WEBCORE_GENERATED_HEADERS_FOR_WEBKIT2 += \
     $$OUTPUT_DIR/WebCore/generated/HTMLNames.h \
     $$OUTPUT_DIR/WebCore/generated/JSCSSStyleDeclaration.h \
@@ -42,23 +38,10 @@ QMAKE_EXTRA_TARGETS += createdirs
 
 SRC_ROOT_DIR = $$replace(PWD, /WebKit2, /)
 
-for(HEADER, WEBCORE_HEADERS_FOR_WEBKIT2) {
-    DESTDIR_BASE = "WebCore"
-
-    HEADER_NAME = $$basename(HEADER)
-    HEADER_PATH = $$SRC_ROOT_DIR/$$DESTDIR_BASE/$$HEADER
-    HEADER_TARGET = $$replace(HEADER_PATH, [^a-zA-Z0-9_], -)
-    HEADER_TARGET = "qtheader-$${HEADER_TARGET}"
-    DESTDIR = $$OUTPUT_DIR/include/$$DESTDIR_BASE
-
-    #FIXME: This should be organized out into a function
-    eval($${HEADER_TARGET}.target = $$DESTDIR/$$HEADER_NAME)
-    eval($${HEADER_TARGET}.depends = $$HEADER_PATH)
-    eval($${HEADER_TARGET}.commands = echo $${DOUBLE_ESCAPED_QUOTE}\$${LITERAL_HASH}include \\\"$$HEADER_PATH\\\"$${DOUBLE_ESCAPED_QUOTE} > $$eval($${HEADER_TARGET}.target))
-
-    QMAKE_EXTRA_TARGETS += $$HEADER_TARGET
-    generated_files.depends += $$eval($${HEADER_TARGET}.target)
-}
+fwheader_generator.commands = perl $${SRC_ROOT_DIR}/WebKit2/generate-forwarding-headers.pl $${OUTPUT_DIR}/include qt
+fwheader_generator.depends  = $${SRC_ROOT_DIR}/WebKit2/generate-forwarding-headers.pl
+generated_files.depends     += fwheader_generator
+QMAKE_EXTRA_TARGETS         += fwheader_generator
 
 for(HEADER, WEBCORE_GENERATED_HEADERS_FOR_WEBKIT2) {
     HEADER_NAME = $$basename(HEADER)
@@ -75,38 +58,4 @@ for(HEADER, WEBCORE_GENERATED_HEADERS_FOR_WEBKIT2) {
     generated_files.depends += $$eval($${HEADER_TARGET}.target)
 }
 
-for(HEADER, JSC_HEADERS_FOR_WEBKIT2) {
-    DESTDIR_BASE = "JavaScriptCore"
-
-    HEADER_NAME = $$basename(HEADER)
-    HEADER_PATH = $$SRC_ROOT_DIR/$$DESTDIR_BASE/$$HEADER
-    HEADER_TARGET = $$replace(HEADER_PATH, [^a-zA-Z0-9_], -)
-    HEADER_TARGET = "qtheader-$${HEADER_TARGET}"
-    DESTDIR = $$OUTPUT_DIR/include/$$DESTDIR_BASE
-
-    eval($${HEADER_TARGET}.target = $$DESTDIR/$$HEADER_NAME)
-    eval($${HEADER_TARGET}.depends = $$HEADER_PATH)
-    eval($${HEADER_TARGET}.commands = echo $${DOUBLE_ESCAPED_QUOTE}\$${LITERAL_HASH}include \\\"$$HEADER_PATH\\\"$${DOUBLE_ESCAPED_QUOTE} > $$eval($${HEADER_TARGET}.target))
-
-    QMAKE_EXTRA_TARGETS += $$HEADER_TARGET
-    generated_files.depends += $$eval($${HEADER_TARGET}.target)
-}
-
-for(HEADER, WEBKIT2_API_HEADERS) {
-    DESTDIR_BASE = "WebKit2"
-
-    HEADER_NAME = $$basename(HEADER)
-    HEADER_PATH = $$PWD/$$HEADER
-    HEADER_TARGET = $$replace(HEADER_PATH, [^a-zA-Z0-9_], -)
-    HEADER_TARGET = "qtheader-$${HEADER_TARGET}"
-    DESTDIR = $$OUTPUT_DIR/include/$$DESTDIR_BASE
-
-    eval($${HEADER_TARGET}.target = $$DESTDIR/$$HEADER_NAME)
-    eval($${HEADER_TARGET}.depends = $$HEADER_PATH)
-    eval($${HEADER_TARGET}.commands = echo $${DOUBLE_ESCAPED_QUOTE}\$${LITERAL_HASH}include \\\"$$HEADER_PATH\\\"$${DOUBLE_ESCAPED_QUOTE} > $$eval($${HEADER_TARGET}.target))
-
-    QMAKE_EXTRA_TARGETS += $$HEADER_TARGET
-    generated_files.depends += $$eval($${HEADER_TARGET}.target)
-}
-
 QMAKE_EXTRA_TARGETS += generated_files
diff --git a/WebKit2/generate-forwarding-headers.pl b/WebKit2/generate-forwarding-headers.pl
new file mode 100755 (executable)
index 0000000..6a779c2
--- /dev/null
@@ -0,0 +1,92 @@
+#!/usr/bin/perl -w
+# Copyright (C) 2010 Andras Becsi (abecsi@inf.u-szeged.hu), University of Szeged
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# A script which searches for headers included by WebKit2 files
+# and generates forwarding headers for these headers.
+
+use strict;
+use Cwd qw(abs_path realpath);
+use File::Find;
+use File::Basename;
+use File::Spec::Functions;
+
+my $srcRoot = realpath(File::Spec->catfile(dirname(abs_path($0)), ".."));
+my @platformPrefixes = ("android", "brew", "cf", "chromium", "curl", "efl", "gtk", "haiku", "mac", "qt", "soup", "v8", "win", "wx");
+my @frameworks = ( "JavaScriptCore", "WebCore", "WebKit2");
+my @skippedPrefixes;
+my @frameworkHeaders;
+my $framework;
+my %neededHeaders;
+
+my $outputDirectory = $ARGV[0];
+shift;
+my $platform  = $ARGV[0];
+
+foreach my $prefix (@platformPrefixes) {
+    push(@skippedPrefixes, $prefix) unless ($prefix =~ $platform);
+}
+
+foreach (@frameworks) {
+    $framework = $_;
+    find(\&collectNeededHeaders, File::Spec->catfile($srcRoot, "WebKit2"));
+    find(\&collectFameworkHeaderPaths, File::Spec->catfile($srcRoot, $framework));
+    createForwardingHeadersForFramework();
+}
+
+sub collectNeededHeaders {
+    my $filePath = $File::Find::name;
+    my $file = $_;
+    if ($filePath =~ '\.h$|\.cpp$') {
+        open(FILE, "<$file") or die "Could not open $filePath.\n";
+        while (<FILE>) {
+           if (m/^#.*<$framework\/(.*\.h)/) {
+               $neededHeaders{$1} = 1;
+           }
+        }
+        close(FILE);
+    }
+}
+
+sub collectFameworkHeaderPaths {
+    my $filePath = $File::Find::name;
+    my $file = $_;
+    if ($filePath =~ '\.h$' && $filePath !~ "ForwardingHeaders" && grep{$file eq $_} keys %neededHeaders) {
+        my $headerPath = substr($filePath, length("$srcRoot/$framework/"));
+        push(@frameworkHeaders, $headerPath) unless (grep($headerPath =~ "$_/", @skippedPrefixes));
+    }
+}
+
+sub createForwardingHeadersForFramework {
+    foreach my $header (@frameworkHeaders) {
+        my $forwardingHeaderPath = File::Spec->catfile($outputDirectory, $framework, basename($header));
+        if (! -e $forwardingHeaderPath) {
+            print "[Create forwarding header for $framework/$header]\n";
+            open(FORWARDING_HEADER, ">$forwardingHeaderPath") or die "Could not open $forwardingHeaderPath.\n";
+            print FORWARDING_HEADER "#include \"$header\"\n";
+            close(FORWARDING_HEADER);
+        }
+    }
+}
+
index 940533a..0981782 100644 (file)
@@ -1,3 +1,14 @@
+2010-09-01  Andras Becsi  <abecsi@webkit.org>
+
+        Reviewed by Antti Koivisto.
+
+        [Qt] Auto-generate WebKit2 forwarding headers
+        https://bugs.webkit.org/show_bug.cgi?id=44692
+
+        * MiniBrowser/qt/BrowserWindow.h: use source style includes
+        * MiniBrowser/qt/MiniBrowser.pro: add missing include paths
+        * Scripts/enumerate-included-framework-headers: Removed.
+
 2010-08-31  Ademar de Souza Reis Jr  <ademar.reis@openbossa.org>
 
         Reviewed by Adam Barth.
index 3ff7e72..99d3e82 100644 (file)
 
 #define PLATFORM(x) 0
 
-#include <stdint.h>
+#include "WKContext.h"
+#include "WKRetainPtr.h"
+#include "qgraphicswkview.h"
 #include <QtGui>
-#include <WebKit2/WKRetainPtr.h>
-#include <WebKit2/WKContext.h>
 #include <QGraphicsScene>
 #include <QGraphicsView>
-#include <WebKit2/qgraphicswkview.h>
+#include <stdint.h>
 
 class BrowserView : public QGraphicsView {
     Q_OBJECT
index b34b8f7..274b9e5 100644 (file)
@@ -14,6 +14,8 @@ isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../..
 include(../../../WebKit.pri)
 
 INCLUDEPATH += \
+    $$PWD/../../../WebKit2/ \
+    $$PWD/../../../WebKit2/UIProcess/API/cpp \
     $$PWD/../../../WebKit2/UIProcess/API/C \
     $$PWD/../../../WebKit2/UIProcess/API/qt \
     $$OUTPUT_DIR/include
diff --git a/WebKitTools/Scripts/enumerate-included-framework-headers b/WebKitTools/Scripts/enumerate-included-framework-headers
deleted file mode 100755 (executable)
index 598a790..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2009, 2010 University of Szeged
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# A script to find and enumerate headers included from the given frameworks by files in the
-# current directory (and subdirectories).
-
-# FIXME: This should be rewritten in perl.
-# FIXME: Currently only works for qt.
-
-platform_prefixes=android/\|brew/\|cf/\|chromium/\|curl\|efl/\|gtk/\|haiku/\|mac/\|soup\|v8\|win/\|wx/
-
-for framework in $*; do
-    headers=`find . \( -name '*.cpp' -o -name '*.h' \) -exec grep "<$framework/" {} ';' | sed -e 's|.*/\(.*\.h\).*|\1|' | sort -u`
-
-    for header in $headers
-    do
-        header_paths=`find ../$framework -name $header | sed "s/..\/$framework\///"`
-
-        if test `echo $header_paths | wc -w` -eq 1
-        then
-            header_path=$header_paths
-            if test `echo $header_path | grep -c -E $platform_prefixes` -ne 0
-            then
-                continue
-            fi
-        else
-            for path in $header_paths
-            do
-                if test `echo $path | grep -c -E $platform_prefixes` -eq 0
-                then
-                    header_path=$path
-                    break
-                fi
-            done
-        fi
-
-        echo -n "$header_path "
-    done
-done