18a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block#!/usr/bin/perl 2563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 38a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block# Copyright (C) 2010 Google Inc. All rights reserved. 4563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 5563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# Redistribution and use in source and binary forms, with or without 6563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# modification, are permitted provided that the following conditions 7563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# are met: 8563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 9563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 1. Redistributions of source code must retain the above copyright 10563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# notice, this list of conditions and the following disclaimer. 11563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 2. Redistributions in binary form must reproduce the above copyright 12563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# notice, this list of conditions and the following disclaimer in the 13563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# documentation and/or other materials provided with the distribution. 14563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# its contributors may be used to endorse or promote products derived 16563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# from this software without specific prior written permission. 17563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# 18563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 298a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block# A script to expose WebKit's build directory detection logic to non-perl scripts. 30563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 31563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse FindBin; 328a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockuse Getopt::Long; 338a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 34563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse lib $FindBin::Bin; 35563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkuse webkitdirs; 36563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 37692e5dbf12901edacf14812a6fae25462920af42Steve Blockmy $showConfigurationDirectory = 0; 388a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockmy $showHelp = 0; 39692e5dbf12901edacf14812a6fae25462920af42Steve Blockmy $showTopLevelDirectory = 0; 40692e5dbf12901edacf14812a6fae25462920af42Steve Block 418a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 428a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockmy $programName = basename($0); 438a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockmy $usage = <<EOF; 448a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve BlockUsage: $programName [options] 45692e5dbf12901edacf14812a6fae25462920af42Steve Block --configuration Show the build directory for a specific configuration (e.g. Debug, Release. Defaults to the active configuration set by set-webkit-configuration) 46692e5dbf12901edacf14812a6fae25462920af42Steve Block -h|--help Show this help message 47692e5dbf12901edacf14812a6fae25462920af42Steve Block --top-level Show the top-level build directory 48692e5dbf12901edacf14812a6fae25462920af42Steve Block 49692e5dbf12901edacf14812a6fae25462920af42Steve BlockEither --configuration or --top-level is required. 508a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve BlockEOF 518a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 528a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve BlocksetConfiguration(); # Figure out from the command line if we're --debug or --release or the default. 538a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 548a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockmy $getOptionsResult = GetOptions( 55692e5dbf12901edacf14812a6fae25462920af42Steve Block 'configuration' => \$showConfigurationDirectory, 56692e5dbf12901edacf14812a6fae25462920af42Steve Block 'top-level' => \$showTopLevelDirectory, 578a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 'help|h' => \$showHelp, 588a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block); 59563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 60692e5dbf12901edacf14812a6fae25462920af42Steve Blockif (!$getOptionsResult || $showHelp || (!$showConfigurationDirectory && !$showTopLevelDirectory)) { 618a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block print STDERR $usage; 628a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block exit 1; 638a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block} 64563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark 65692e5dbf12901edacf14812a6fae25462920af42Steve Blockif ($showTopLevelDirectory) { 668a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block print baseProductDir() . "\n"; 678a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block} else { 688a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block print productDir() . "\n"; 698a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block} 70