commit-queue@webkit.org | 026ee04 | 2018-01-04 07:18:18 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 2 | |
| 3 | # Copyright (C) 2010 Google Inc. All rights reserved. |
bfulgham@apple.com | ad65350 | 2015-10-08 00:35:57 +0000 | [diff] [blame] | 4 | # Copyright (C) 2013, 2015 Apple Inc. All rights reserved. |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 5 | # |
| 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.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 15 | # 3. Neither the name of Apple Inc. ("Apple") nor the names of |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 16 | # 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.org | 026ee04 | 2018-01-04 07:18:18 +0000 | [diff] [blame] | 32 | use warnings; |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 33 | use FindBin; |
| 34 | use Getopt::Long; |
| 35 | |
| 36 | use lib $FindBin::Bin; |
| 37 | use webkitdirs; |
| 38 | |
eric@webkit.org | d2728e4 | 2010-02-15 04:42:02 +0000 | [diff] [blame] | 39 | my $showConfigurationDirectory = 0; |
bfulgham@apple.com | ad65350 | 2015-10-08 00:35:57 +0000 | [diff] [blame] | 40 | my $showExecutablePath = 0; |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 41 | my $showHelp = 0; |
eric@webkit.org | d2728e4 | 2010-02-15 04:42:02 +0000 | [diff] [blame] | 42 | my $showTopLevelDirectory = 0; |
| 43 | |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 44 | |
| 45 | my $programName = basename($0); |
| 46 | my $usage = <<EOF; |
| 47 | Usage: $programName [options] |
rniwa@webkit.org | 0192b95 | 2012-03-31 06:50:09 +0000 | [diff] [blame] | 48 | --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.com | ad65350 | 2015-10-08 00:35:57 +0000 | [diff] [blame] | 49 | --executablePath Show the path to the executables produced by a specific build configuration. This differs from --configuration on Windows. |
rniwa@webkit.org | 0192b95 | 2012-03-31 06:50:09 +0000 | [diff] [blame] | 50 | -h|--help Show this help message |
| 51 | --top-level Show the top-level build directory |
| 52 | |
rniwa@webkit.org | 0192b95 | 2012-03-31 06:50:09 +0000 | [diff] [blame] | 53 | --gtk Find the build directory for the GTK+ port |
rniwa@webkit.org | 0192b95 | 2012-03-31 06:50:09 +0000 | [diff] [blame] | 54 | --wincairo Find the build directory for using Cairo (rather than CoreGraphics) on Windows |
eric@webkit.org | d2728e4 | 2010-02-15 04:42:02 +0000 | [diff] [blame] | 55 | |
| 56 | Either --configuration or --top-level is required. |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 57 | EOF |
| 58 | |
| 59 | setConfiguration(); # Figure out from the command line if we're --debug or --release or the default. |
| 60 | |
rniwa@webkit.org | 0192b95 | 2012-03-31 06:50:09 +0000 | [diff] [blame] | 61 | # FIXME: Check if extra flags are valid or not. |
| 62 | Getopt::Long::Configure('pass_through'); # Let --blackberry, etc... be handled by webkitdirs |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 63 | my $getOptionsResult = GetOptions( |
eric@webkit.org | d2728e4 | 2010-02-15 04:42:02 +0000 | [diff] [blame] | 64 | 'configuration' => \$showConfigurationDirectory, |
bfulgham@apple.com | ad65350 | 2015-10-08 00:35:57 +0000 | [diff] [blame] | 65 | 'executablePath' => \$showExecutablePath, |
eric@webkit.org | d2728e4 | 2010-02-15 04:42:02 +0000 | [diff] [blame] | 66 | 'top-level' => \$showTopLevelDirectory, |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 67 | 'help|h' => \$showHelp, |
| 68 | ); |
| 69 | |
ojan@chromium.org | 34e706d | 2012-02-01 00:32:57 +0000 | [diff] [blame] | 70 | if (!$getOptionsResult || $showHelp) { |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 71 | print STDERR $usage; |
| 72 | exit 1; |
| 73 | } |
| 74 | |
bfulgham@apple.com | ad65350 | 2015-10-08 00:35:57 +0000 | [diff] [blame] | 75 | if (!$showConfigurationDirectory && !$showTopLevelDirectory && !$showExecutablePath) { |
ojan@chromium.org | 34e706d | 2012-02-01 00:32:57 +0000 | [diff] [blame] | 76 | print baseProductDir() . "\n"; |
| 77 | print productDir() . "\n"; |
| 78 | } elsif ($showTopLevelDirectory) { |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 79 | print baseProductDir() . "\n"; |
bfulgham@apple.com | ad65350 | 2015-10-08 00:35:57 +0000 | [diff] [blame] | 80 | } elsif ($showExecutablePath) { |
| 81 | print executableProductDir() . "\n"; |
eric@webkit.org | 7ecf07c | 2010-02-11 01:24:04 +0000 | [diff] [blame] | 82 | } else { |
| 83 | print productDir() . "\n"; |
| 84 | } |