blob: 7934575df3aff8c3c63a7557a94fa9027b4cfe28 [file] [log] [blame]
commit-queue@webkit.org026ee042018-01-04 07:18:18 +00001#!/usr/bin/env perl
eric@webkit.org7ecf07c2010-02-11 01:24:04 +00002
3# Copyright (C) 2010 Google Inc. All rights reserved.
bfulgham@apple.comad653502015-10-08 00:35:57 +00004# Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
eric@webkit.org7ecf07c2010-02-11 01:24:04 +00005#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1. Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
mjs@apple.com92047332014-03-15 04:08:27 +000015# 3. Neither the name of Apple Inc. ("Apple") nor the names of
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000016# its contributors may be used to endorse or promote products derived
17# from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30# A script to expose WebKit's build directory detection logic to non-perl scripts.
31
commit-queue@webkit.org026ee042018-01-04 07:18:18 +000032use warnings;
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000033use FindBin;
34use Getopt::Long;
35
36use lib $FindBin::Bin;
37use webkitdirs;
38
eric@webkit.orgd2728e42010-02-15 04:42:02 +000039my $showConfigurationDirectory = 0;
bfulgham@apple.comad653502015-10-08 00:35:57 +000040my $showExecutablePath = 0;
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000041my $showHelp = 0;
eric@webkit.orgd2728e42010-02-15 04:42:02 +000042my $showTopLevelDirectory = 0;
43
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000044
45my $programName = basename($0);
46my $usage = <<EOF;
47Usage: $programName [options]
rniwa@webkit.org0192b952012-03-31 06:50:09 +000048 --configuration Show the build directory for a specific configuration (e.g. Debug, Release. Defaults to the active configuration set by set-webkit-configuration)
bfulgham@apple.comad653502015-10-08 00:35:57 +000049 --executablePath Show the path to the executables produced by a specific build configuration. This differs from --configuration on Windows.
rniwa@webkit.org0192b952012-03-31 06:50:09 +000050 -h|--help Show this help message
51 --top-level Show the top-level build directory
52
rniwa@webkit.org0192b952012-03-31 06:50:09 +000053 --gtk Find the build directory for the GTK+ port
rniwa@webkit.org0192b952012-03-31 06:50:09 +000054 --wincairo Find the build directory for using Cairo (rather than CoreGraphics) on Windows
eric@webkit.orgd2728e42010-02-15 04:42:02 +000055
56Either --configuration or --top-level is required.
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000057EOF
58
59setConfiguration(); # Figure out from the command line if we're --debug or --release or the default.
60
rniwa@webkit.org0192b952012-03-31 06:50:09 +000061# FIXME: Check if extra flags are valid or not.
62Getopt::Long::Configure('pass_through'); # Let --blackberry, etc... be handled by webkitdirs
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000063my $getOptionsResult = GetOptions(
eric@webkit.orgd2728e42010-02-15 04:42:02 +000064 'configuration' => \$showConfigurationDirectory,
bfulgham@apple.comad653502015-10-08 00:35:57 +000065 'executablePath' => \$showExecutablePath,
eric@webkit.orgd2728e42010-02-15 04:42:02 +000066 'top-level' => \$showTopLevelDirectory,
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000067 'help|h' => \$showHelp,
68);
69
ojan@chromium.org34e706d2012-02-01 00:32:57 +000070if (!$getOptionsResult || $showHelp) {
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000071 print STDERR $usage;
72 exit 1;
73}
74
bfulgham@apple.comad653502015-10-08 00:35:57 +000075if (!$showConfigurationDirectory && !$showTopLevelDirectory && !$showExecutablePath) {
ojan@chromium.org34e706d2012-02-01 00:32:57 +000076 print baseProductDir() . "\n";
77 print productDir() . "\n";
78} elsif ($showTopLevelDirectory) {
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000079 print baseProductDir() . "\n";
bfulgham@apple.comad653502015-10-08 00:35:57 +000080} elsif ($showExecutablePath) {
81 print executableProductDir() . "\n";
eric@webkit.org7ecf07c2010-02-11 01:24:04 +000082} else {
83 print productDir() . "\n";
84}