Changeset 95655 in webkit


Ignore:
Timestamp:
Sep 21, 2011 11:48:16 AM (13 years ago)
Author:
mitz@apple.com
Message:

Source/JavaScriptCore: JavaScriptCore Part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
https://bugs.webkit.org/show_bug.cgi?id=68451

Reviewed by Darin Adler.

  • JavaScriptCore.xcodeproj/project.pbxproj: Added a script build phase that invokes

check-for-inappropriate-objc-class-names, allowing only class names prefixed with "JS".

Source/WebCore: WebCore part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
https://bugs.webkit.org/show_bug.cgi?id=68451

Reviewed by Darin Adler.

  • WebCore.xcodeproj/project.pbxproj: Added a script build phase that invokes

check-for-inappropriate-objc-class-names, allowing only class names prefixed with "DOM" or "Web".

Source/WebKit: WebKit part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
https://bugs.webkit.org/show_bug.cgi?id=68451

Reviewed by Darin Adler.

  • WebKit.xcodeproj/project.pbxproj: Added a script build phase that invokes

check-for-inappropriate-objc-class-names, allowing only class names prefixed with "Web" or "_Web".

Source/WebKit2: WebKit2 part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
https://bugs.webkit.org/show_bug.cgi?id=68451

Reviewed by Darin Adler.

  • WebKit2.xcodeproj/project.pbxproj: Added a script build phase that invokes

check-for-inappropriate-objc-class-names, allowing only class names prefixed with "WK" or "Web".

Tools: Tools part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
https://bugs.webkit.org/show_bug.cgi?id=68451

Reviewed by Darin Adler.

  • Scripts/check-for-inappropriate-objc-class-names: Added. Checks for

Objective-C classes with names not having one of a list of prefixes
passed on the command line.

Location:
trunk
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95652 r95655  
     12011-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        JavaScriptCore Part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
     4        https://bugs.webkit.org/show_bug.cgi?id=68451
     5
     6        Reviewed by Darin Adler.
     7
     8        * JavaScriptCore.xcodeproj/project.pbxproj: Added a script build phase that invokes
     9        check-for-inappropriate-objc-class-names, allowing only class names prefixed with "JS".
     10
    1112011-09-20  Gavin Barraclough  <barraclough@apple.com>
    212
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r95559 r95655  
    28752875                                933457200EBFDC3F00B80894 /* Check For Exit Time Destructors */,
    28762876                                5D29D8BE0E9860B400C3D2D0 /* Check For Weak VTables and Externals */,
     2877                                3713F014142905240036387F /* Check For Inappropriate Objective-C Class Names */,
    28772878                        );
    28782879                        buildRules = (
     
    29422943
    29432944/* Begin PBXShellScriptBuildPhase section */
     2945                3713F014142905240036387F /* Check For Inappropriate Objective-C Class Names */ = {
     2946                        isa = PBXShellScriptBuildPhase;
     2947                        buildActionMask = 2147483647;
     2948                        files = (
     2949                        );
     2950                        inputPaths = (
     2951                                "$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
     2952                        );
     2953                        name = "Check For Inappropriate Objective-C Class Names";
     2954                        outputPaths = (
     2955                        );
     2956                        runOnlyForDeploymentPostprocessing = 0;
     2957                        shellPath = /bin/sh;
     2958                        shellScript = "if [ \"${ACTION}\" = \"installhdrs\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../Tools/Scripts/check-for-inappropriate-objc-class-names ]; then\n    ../../Tools/Scripts/check-for-inappropriate-objc-class-names JS || exit $?\nfi";
     2959                };
    29442960                5D29D8BE0E9860B400C3D2D0 /* Check For Weak VTables and Externals */ = {
    29452961                        isa = PBXShellScriptBuildPhase;
  • trunk/Source/WebCore/ChangeLog

    r95654 r95655  
     12011-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        WebCore part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
     4        https://bugs.webkit.org/show_bug.cgi?id=68451
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebCore.xcodeproj/project.pbxproj: Added a script build phase that invokes
     9        check-for-inappropriate-objc-class-names, allowing only class names prefixed with "DOM" or "Web".
     10
    1112011-09-21  Dan Bernstein  <mitz@apple.com>
    212
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r95513 r95655  
    2355823558                                933457E60EBFDF6B00B80894 /* Check For Exit Time Destructors */,
    2355923559                                5D0D540D0E9862F60029E223 /* Check For Weak VTables and Externals */,
     23560                                37A1EAA3142699BC0087F425 /* Check For Inappropriate Objective-C Class Names */,
    2356023561                                5DF50887116F3077005202AB /* Check For Inappropriate Files In Framework */,
    2356123562                        );
     
    2368823689                        shellPath = /bin/sh;
    2368923690                        shellScript = "# Copy all the Inspector front-end resources.\nditto \"${SRCROOT}/inspector/front-end\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\"\nditto \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore/InspectorBackendStub.js\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\"\n\n# Remove the WebKit.qrc file since it is not used on the Mac (this file is for Qt).\nrm -f \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector/WebKit.qrc\"\n\n# Remove *.re2js files, they are only used to generate some .js files.\nrm -f \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector/\"*.re2js\n\n# Remove any .svn directories that may have been copied over.\nfind \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\" -name \".svn\" -type d | xargs rm -rf\n";
     23691                };
     23692                37A1EAA3142699BC0087F425 /* Check For Inappropriate Objective-C Class Names */ = {
     23693                        isa = PBXShellScriptBuildPhase;
     23694                        buildActionMask = 2147483647;
     23695                        files = (
     23696                        );
     23697                        inputPaths = (
     23698                                "$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
     23699                        );
     23700                        name = "Check For Inappropriate Objective-C Class Names";
     23701                        outputPaths = (
     23702                        );
     23703                        runOnlyForDeploymentPostprocessing = 0;
     23704                        shellPath = /bin/sh;
     23705                        shellScript = "if [ \"${ACTION}\" = \"installhdrs\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../Tools/Scripts/check-for-inappropriate-objc-class-names ]; then\n    ../../Tools/Scripts/check-for-inappropriate-objc-class-names DOM Web || exit $?\nfi";
    2369023706                };
    2369123707                5D0D540D0E9862F60029E223 /* Check For Weak VTables and Externals */ = {
  • trunk/Source/WebKit/ChangeLog

    r95470 r95655  
     12011-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        WebKit part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
     4        https://bugs.webkit.org/show_bug.cgi?id=68451
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebKit.xcodeproj/project.pbxproj: Added a script build phase that invokes
     9        check-for-inappropriate-objc-class-names, allowing only class names prefixed with "Web" or "_Web".
     10
    1112011-09-19  Anders Carlsson  <andersca@apple.com>
    212
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r95470 r95655  
    16421642                                9337D6540EBFE54D00DA3CB5 /* Check For Exit Time Destructors */,
    16431643                                5D0D54210E98631D0029E223 /* Check For Weak VTables and Externals */,
     1644                                3713F018142905B70036387F /* Check For Inappropriate Objective-C Class Names */,
    16441645                                5D88EE6C11407DE800BC3ABC /* Check For Framework Include Consistency */,
    16451646                                5DE6D18C0FCF231B002DE28C /* Symlink WebKitPluginHost in to place */,
     
    17311732                        shellPath = /bin/sh;
    17321733                        shellScript = "mkdir -p \"${TARGET_BUILD_DIR}/${PRIVATE_HEADERS_FOLDER_PATH}\"\nmkdir -p \"${TARGET_BUILD_DIR}/${PUBLIC_HEADERS_FOLDER_PATH}\"\nmkdir -p \"${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit\"\n\nif [ \"${ACTION}\" = \"build\" -o \"${ACTION}\" = \"install\" -o \"${ACTION}\" = \"installhdrs\" ]; then\n    make -C mac -f \"MigrateHeaders.make\" -j `/usr/sbin/sysctl -n hw.availcpu`\nfi\n";
     1734                };
     1735                3713F018142905B70036387F /* Check For Inappropriate Objective-C Class Names */ = {
     1736                        isa = PBXShellScriptBuildPhase;
     1737                        buildActionMask = 2147483647;
     1738                        files = (
     1739                        );
     1740                        inputPaths = (
     1741                                "$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
     1742                        );
     1743                        name = "Check For Inappropriate Objective-C Class Names";
     1744                        outputPaths = (
     1745                        );
     1746                        runOnlyForDeploymentPostprocessing = 0;
     1747                        shellPath = /bin/sh;
     1748                        shellScript = "if [ \"${ACTION}\" = \"installhdrs\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../Tools/Scripts/check-for-inappropriate-objc-class-names ]; then\n    ../../Tools/Scripts/check-for-inappropriate-objc-class-names Web _Web || exit $?\nfi";
    17331749                };
    17341750                5D0D54210E98631D0029E223 /* Check For Weak VTables and Externals */ = {
  • trunk/Source/WebKit2/ChangeLog

    r95631 r95655  
     12011-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        WebKit2 part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
     4        https://bugs.webkit.org/show_bug.cgi?id=68451
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebKit2.xcodeproj/project.pbxproj: Added a script build phase that invokes
     9        check-for-inappropriate-objc-class-names, allowing only class names prefixed with "WK" or "Web".
     10
    1112011-09-21  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    212
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r95448 r95655  
    39263926                                5DF408C4131DD3DB00130071 /* Check For Exit Time Destructors */,
    39273927                                5DF408C5131DD46700130071 /* Check For Weak VTables and Externals */,
     3928                                3713F0231429063D0036387F /* Check For Inappropriate Objective-C Class Names */,
    39283929                                5DF408C6131DD49700130071 /* Check For Framework Include Consistency */,
    39293930                                5DF408D1131DDBEC00130071 /* Check For Inappropriate Files In Framework */,
     
    40184019
    40194020/* Begin PBXShellScriptBuildPhase section */
     4021                3713F0231429063D0036387F /* Check For Inappropriate Objective-C Class Names */ = {
     4022                        isa = PBXShellScriptBuildPhase;
     4023                        buildActionMask = 2147483647;
     4024                        files = (
     4025                        );
     4026                        inputPaths = (
     4027                                "$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
     4028                        );
     4029                        name = "Check For Inappropriate Objective-C Class Names";
     4030                        outputPaths = (
     4031                        );
     4032                        runOnlyForDeploymentPostprocessing = 0;
     4033                        shellPath = /bin/sh;
     4034                        shellScript = "if [ \"${ACTION}\" = \"installhdrs\" ]; then\n    exit 0;\nfi\n\nif [ -f ../../Tools/Scripts/check-for-inappropriate-objc-class-names ]; then\n    ../../Tools/Scripts/check-for-inappropriate-objc-class-names WK Web || exit $?\nfi";
     4035                };
    40204036                5DF408C0131DD37C00130071 /* Check For Global Initializers */ = {
    40214037                        isa = PBXShellScriptBuildPhase;
  • trunk/Tools/ChangeLog

    r95647 r95655  
     12011-09-21  Dan Bernstein  <mitz@apple.com>
     2
     3        Tools part of: Prevent the WebKit frameworks from defining inappropriately-named Objective-C classes
     4        https://bugs.webkit.org/show_bug.cgi?id=68451
     5
     6        Reviewed by Darin Adler.
     7
     8        * Scripts/check-for-inappropriate-objc-class-names: Added. Checks for
     9        Objective-C classes with names not having one of a list of prefixes
     10        passed on the command line.
     11
    1122011-09-21  Xianzhu Wang  <wangxianzhu@chromium.org>
    213
  • trunk/Tools/Scripts/check-for-inappropriate-objc-class-names

    r95653 r95655  
    11#!/usr/bin/perl
    22
    3 # Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
     3# Copyright (C) 2006, 2007, 2008, 2010, 2011 Apple Inc. All rights reserved.
    44#
    55# Redistribution and use in source and binary forms, with or without
    66# modification, are permitted provided that the following conditions
    77# are met:
    8 #
    9 # 1.  Redistributions of source code must retain the above copyright
    10 #     notice, this list of conditions and the following disclaimer.
    11 # 2.  Redistributions in binary form must reproduce the above copyright
    12 #     notice, this list of conditions and the following disclaimer in the
    13 #     documentation and/or other materials provided with the distribution.
    14 # 3.  Neither the name of Apple Inc. ("Apple") nor the names of
    15 #     its contributors may be used to endorse or promote products derived
    16 #     from this software without specific prior written permission.
    17 #
    18 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    19 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    21 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    27 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     8# 1. Redistributions of source code must retain the above copyright
     9#    notice, this list of conditions and the following disclaimer.
     10# 2. 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#
     14# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     15# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     16# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     17# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     18# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     19# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     20# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     21# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     22# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     23# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     24# THE POSSIBILITY OF SUCH DAMAGE.
    2825
    29 # "check-for-weak-vtables-and-externals" script for WebKit Open Source Project
     26# "check-for-inappropriate-objc-class-names" script for WebKit Open Source Project
    3027
    31 # Intended to be invoked from an Xcode build step to check if there are
    32 # any weak vtables or weak externals in a target.
     28# Intended to be invoked from an Xcode build step to check if a framework
     29# defines any Objective-C class whose name does not have one of the prefixes
     30# the framework is allowed to use.
    3331
    3432use warnings;
     
    3937sub touch($);
    4038
     39my @allowedPrefixes = @ARGV;
     40
     41die "No allowed prefixes passed on the command line" if !@allowedPrefixes;
     42
    4143my $arch = $ENV{'CURRENT_ARCH'};
    42 my $configuration = $ENV{'CONFIGURATION'};
    4344my $target = $ENV{'TARGET_NAME'};
    4445my $variant = $ENV{'CURRENT_VARIANT'};
    4546my $coverageBuild = $ENV{'WEBKIT_COVERAGE_BUILD'};
    46 my $debugRoot = $ENV{'WEBKIT_DEBUG_ROOT'};
    47 
    48 $arch = $ENV{'NATIVE_ARCH'} if !$arch; # for Xcode 2.1, which does not have CURRENT_ARCH
    49 $variant = "normal" if !$variant; # for Xcode 2.1, which does not have CURRENT_VARIANT
    5047
    5148my $executablePath = "$ENV{'TARGET_BUILD_DIR'}/$ENV{'EXECUTABLE_PATH'}";
    5249
    53 my $buildTimestampPath = $ENV{'TARGET_TEMP_DIR'} . "/" . basename($0) . ".timestamp";
     50my $buildTimestampPath = $ENV{'TARGET_TEMP_DIR'} . "/" . basename($0) . join('-', @allowedPrefixes) . ".timestamp";
    5451my $buildTimestampAge = -M $buildTimestampPath;
    5552my $executablePathAge = -M $executablePath;
     53my $scriptAge = -M $0;
     54
     55my $pattern = "^(" . join('|', @allowedPrefixes) . ")";
    5656
    5757my $sawError = 0;
    5858
    59 if (!defined $executablePathAge || !defined $buildTimestampAge || $executablePathAge < $buildTimestampAge) {
    60     if (!open NM, "(nm -m '$executablePath' | c++filt | sed 's/^/STDOUT:/') 2>&1 |") {
     59if (!defined $executablePathAge || !defined $buildTimestampAge || $executablePathAge < $buildTimestampAge || $scriptAge < $buildTimestampAge) {
     60    if (!open NM, "(nm -Ugjp '$executablePath' | sed 's/^/STDOUT:/') 2>&1 |") {
    6161        print "ERROR: Could not open $executablePath\n";
    6262        $sawError = 1;
    6363        next;
    6464    }
    65     my @weakVTableClasses = ();
    66     my @weakExternalSymbols = ();
     65    my @badNames;
    6766    while (<NM>) {
    6867        if (/^STDOUT:/) {
    69             # Ignore undefined, RTTI and typeinfo symbols.
    70             next if /\bundefined\b/ or /\b__ZT[IS]/;
    71 
    72             if (/weak external vtable for (.*)$/) {
    73                 push @weakVTableClasses, $1;
    74             } elsif (/weak external (.*)$/) {
    75                 push @weakExternalSymbols, $1;
    76             }
     68            next unless /^STDOUT:_OBJC_CLASS_\$_/;
     69            chomp;
     70            my $className = substr($_, 21);
     71            push(@badNames, $className) unless $className =~ /$pattern/;
    7772        } else {
    7873            print STDERR if $_ ne "nm: no name list\n";
     
    8176    close NM;
    8277
    83     my $shortName = $executablePath;
    84     $shortName =~ s/.*\///;
     78    if (@badNames) {
    8579
    86     if (@weakVTableClasses) {
    87         print "ERROR: $shortName has a weak vtable in it ($executablePath)\n";
    88         print "ERROR: Fix by making sure the first virtual function in each of these classes is not an inline:\n";
    89         for my $class (sort @weakVTableClasses) {
    90             print "ERROR: class $class\n";
     80        my $shortName = $executablePath;
     81        $shortName =~ s/.*\///;
     82
     83        print "ERROR: $shortName defines one or more Objective-C classes with inappropriate names. ($executablePath)\n";
     84        for my $className (@badNames) {
     85            print "ERROR: Inapproriate Objective-C class name: $className.\n";
    9186        }
    92         $sawError = 1;
    93     }
    9487
    95     if (@weakExternalSymbols) {
    96         print "ERROR: $shortName has a weak external symbol in it ($executablePath)\n";
    97         print "ERROR: A weak external symbol is generated when a symbol is defined in multiple compilation units and is also marked as being exported from the library.\n";
    98         print "ERROR: A common cause of weak external symbols is when an inline function is listed in the linker export file.\n";
    99         for my $symbol (sort @weakExternalSymbols) {
    100             print "ERROR: symbol $symbol\n";
     88        if (@allowedPrefixes > 1) {
     89            print "ERROR: Objective-C class names in $target must have one of these prefixes: " . join(", ", map('"' . $_ . '"', @allowedPrefixes)) . ".\n";
     90        } else {
     91            print "ERROR: Objective-C class names in $target must have the prefix \"" . $allowedPrefixes[0] . "\".\n";
    10192        }
     93
    10294        $sawError = 1;
    10395    }
     
    110102
    111103touch($buildTimestampPath);
    112 
    113104exit 0;
    114105
Note: See TracChangeset for help on using the changeset viewer.