#!/usr/bin/perl

# Copyright (C) 2006, 2007 Apple Inc. 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. 
# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
#     its contributors may be used to endorse or promote products derived
#     from this software without specific prior written permission. 
#
# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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.

# "check-for-global-initializers" script for Web Kit Open Source Project

# Intended to be invoked from an Xcode build step to check if there are
# any global initializers in a target.

use warnings;
use strict;

my $arch = $ENV{'CURRENT_ARCH'};
my $configuration = $ENV{'CONFIGURATION'};
my $target = $ENV{'TARGET_NAME'};
my $variant = $ENV{'CURRENT_VARIANT'};
my $coverageBuild = $ENV{'WEBKIT_COVERAGE_BUILD'};

$arch = $ENV{'NATIVE_ARCH'} if !$arch; # for Xcode 2.1, which does not have CURRENT_ARCH
$variant = "normal" if !$variant; # for Xcode 2.1, which does not have CURRENT_VARIANT

my $executablePath = "$ENV{'TARGET_BUILD_DIR'}/$ENV{'EXECUTABLE_PATH'}";
my $executableAge = -M $executablePath;

my $list = $ENV{"LINK_FILE_LIST_${variant}_${arch}"};

if (!open LIST, $list) {
    print "Could not open $list\n";
    exit 1;
}

my @files = <LIST>;
chomp @files;
close LIST;

my $sawError = 0;

for my $file (sort @files) {
    if (defined $executableAge) {
        my $fileAge = -M $file;
        next if defined $fileAge && $fileAge > $executableAge;
    }
    if (!open NM, "(nm '$file' | sed 's/^/STDOUT:/') 2>&1 |") {
        print "Could not open $file\n";
        $sawError = 1;
        next;
    }
    my $sawGlobal = 0;
    while (<NM>) {
        if (/^STDOUT:/) {
            $sawGlobal = 1 if /__GLOBAL__I/;
        } else {
            print STDERR if $_ ne "nm: no name list\n";
        }
    }
    close NM;
    if ($sawGlobal) {
        my $shortName = $file;
        $shortName =~ s/.*\///;

        # Special cases for files that have initializers in debug builds.
        if ($configuration eq "Debug") {
            if ($target eq "JavaScriptCore") {
                next if $shortName eq "nodes.o";
                next if $shortName eq "AllInOneFile.o";
            }
            if ($target eq "WebCore") {
                next if $shortName eq "CachedPage.o";
                next if $shortName eq "Frame.o";
                next if $shortName eq "Node.o";
                next if $shortName eq "Page.o";
                next if $shortName eq "Range.o";
                next if $shortName eq "RenderObject.o";
                next if $shortName eq "SubresourceLoader.o";
                next if $shortName eq "bidi.o";
                next if $shortName eq "kjs_events.o";
            }
        }

        print "$shortName has a global initializer in it! ($file)\n";
        $sawError = 1;
    }
}

if ($sawError and !$coverageBuild) {
    unlink $executablePath;
    exit 1;
}
