48755
|
1 |
#!/bin/bash
|
|
2 |
#
|
|
3 |
# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
4 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
5 |
#
|
|
6 |
# This code is free software; you can redistribute it and/or modify it
|
|
7 |
# under the terms of the GNU General Public License version 2 only, as
|
|
8 |
# published by the Free Software Foundation. Oracle designates this
|
|
9 |
# particular file as subject to the "Classpath" exception as provided
|
|
10 |
# by Oracle in the LICENSE file that accompanied this code.
|
|
11 |
#
|
|
12 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
16 |
# accompanied this code).
|
|
17 |
#
|
|
18 |
# You should have received a copy of the GNU General Public License version
|
|
19 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
20 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
21 |
#
|
|
22 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
23 |
# or visit www.oracle.com if you need additional information or have any
|
|
24 |
# questions.
|
|
25 |
#
|
|
26 |
|
|
27 |
# This script copies parts of an Xcode installation into a devkit suitable
|
|
28 |
# for building OpenJDK and OracleJDK. The installation Xcode_X.X.xip needs
|
|
29 |
# to be either installed or extracted using for example Archive Utility.
|
|
30 |
# The easiest way to accomplish this is to right click the file in Finder
|
|
31 |
# and choose "Open With -> Archive Utility", or possible typing
|
|
32 |
# "open Xcode_9.2.xip" in a terminal.
|
|
33 |
# erik.joelsson@oracle.com
|
|
34 |
|
|
35 |
USAGE="$0 <Xcode.app>"
|
|
36 |
|
|
37 |
if [ "$1" = "" ]; then
|
|
38 |
echo $USAGE
|
|
39 |
exit 1
|
|
40 |
fi
|
|
41 |
|
|
42 |
XCODE_APP="$1"
|
|
43 |
XCODE_APP_DIR_NAME="${XCODE_APP##*/}"
|
|
44 |
|
|
45 |
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
|
|
46 |
BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
|
|
47 |
|
|
48 |
# Find the version of Xcode
|
|
49 |
XCODE_VERSION="$($XCODE_APP/Contents/Developer/usr/bin/xcodebuild -version \
|
|
50 |
| awk '/Xcode/ { print $2 }' )"
|
|
51 |
SDK_VERSION="MacOSX10.13"
|
|
52 |
if [ ! -e "$XCODE_APP/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk" ]; then
|
|
53 |
echo "Expected SDK version not found: ${SDK_VERSION}"
|
|
54 |
exit 1
|
|
55 |
fi
|
|
56 |
|
|
57 |
DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"
|
|
58 |
DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
|
|
59 |
|
|
60 |
echo "Xcode version: $XCODE_VERSION"
|
|
61 |
echo "Creating devkit in $DEVKIT_ROOT"
|
|
62 |
|
|
63 |
mkdir -p $DEVKIT_ROOT
|
|
64 |
|
|
65 |
################################################################################
|
|
66 |
# Copy the relevant parts of Xcode.app, removing things that are both big and
|
|
67 |
# unecessary for our purposes, without building an impossibly long exclude list.
|
|
68 |
#
|
|
69 |
# Not including WatchSimulator.platform makes ibtool crashes in some situations.
|
|
70 |
# It doesn't seem to matter which extra platform is included, but that is the
|
|
71 |
# smallest one.
|
|
72 |
|
|
73 |
EXCLUDE_DIRS=" \
|
|
74 |
Contents/_CodeSignature \
|
|
75 |
$XCODE_APP_DIR_NAME/Contents/Applications \
|
|
76 |
$XCODE_APP_DIR_NAME/Contents/Resources \
|
|
77 |
$XCODE_APP_DIR_NAME/Contents/Library \
|
|
78 |
$XCODE_APP_DIR_NAME/Contents/XPCServices \
|
|
79 |
$XCODE_APP_DIR_NAME/Contents/OtherFrameworks \
|
|
80 |
$XCODE_APP_DIR_NAME/Contents/Developer/Documentation \
|
|
81 |
$XCODE_APP_DIR_NAME/Contents/Developer/usr/share \
|
|
82 |
$XCODE_APP_DIR_NAME/Contents/Developer/usr/libexec/git-core \
|
|
83 |
$XCODE_APP_DIR_NAME/Contents/Developer/usr/bin/git* \
|
|
84 |
$XCODE_APP_DIR_NAME/Contents/Developer/usr/bin/svn* \
|
|
85 |
$XCODE_APP_DIR_NAME/Contents/Developer/usr/lib/libgit* \
|
|
86 |
$XCODE_APP_DIR_NAME/Contents/Developer/usr/lib/libsvn* \
|
|
87 |
$XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man \
|
|
88 |
$XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man \
|
|
89 |
$XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/share/man \
|
|
90 |
$XCODE_APP_DIR_NAME/Contents/Developer/Platforms/MacOSX.platform/usr \
|
|
91 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man \
|
|
92 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift* \
|
|
93 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift* \
|
|
94 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework \
|
|
95 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/swift* \
|
|
96 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/swift* \
|
|
97 |
$XCODE_APP_DIR_NAME/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/arc \
|
|
98 |
Platforms/AppleTVSimulator.platform \
|
|
99 |
Platforms/iPhoneSimulator.platform \
|
|
100 |
$XCODE_APP_DIR_NAME/Contents/SharedFrameworks/LLDB.framework \
|
|
101 |
$XCODE_APP_DIR_NAME/Contents/SharedFrameworks/ModelIO.framework \
|
|
102 |
$XCODE_APP_DIR_NAME/Contents/SharedFrameworks/XCSUI.framework \
|
|
103 |
$XCODE_APP_DIR_NAME/Contents/SharedFrameworks/SceneKit.framework \
|
|
104 |
$XCODE_APP_DIR_NAME/Contents/SharedFrameworks/XCBuild.framework \
|
|
105 |
$XCODE_APP_DIR_NAME/Contents/SharedFrameworks/GPUTools.framework \
|
|
106 |
$(cd $XCODE_APP/.. && ls -d $XCODE_APP_DIR_NAME/Contents/Developer/Platforms/* \
|
|
107 |
| grep -v MacOSX.platform | grep -v WatchSimulator.platform) \
|
|
108 |
"
|
|
109 |
|
|
110 |
for ex in $EXCLUDE_DIRS; do
|
|
111 |
EXCLUDE_ARGS+="--exclude=$ex "
|
|
112 |
done
|
|
113 |
|
|
114 |
echo "Copying Xcode.app..."
|
|
115 |
echo rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP" $DEVKIT_ROOT/
|
|
116 |
rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP" $DEVKIT_ROOT/
|
|
117 |
|
|
118 |
################################################################################
|
|
119 |
|
|
120 |
echo-info() {
|
|
121 |
echo "$1" >> $DEVKIT_ROOT/devkit.info
|
|
122 |
}
|
|
123 |
|
|
124 |
echo "Generating devkit.info..."
|
|
125 |
rm -f $DEVKIT_ROOT/devkit.info
|
|
126 |
echo-info "# This file describes to configure how to interpret the contents of this devkit"
|
|
127 |
echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
|
|
128 |
echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
|
|
129 |
echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK_VERSION.sdk\""
|
|
130 |
echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_TOOLCHAIN_PATH\""
|
|
131 |
|
|
132 |
################################################################################
|
|
133 |
# Copy this script
|
|
134 |
|
|
135 |
echo "Copying this script..."
|
|
136 |
cp $0 $DEVKIT_ROOT/
|
|
137 |
|
|
138 |
################################################################################
|
|
139 |
# Create bundle
|
|
140 |
|
|
141 |
echo "Creating bundle..."
|
|
142 |
GZIP=$(command -v pigz)
|
|
143 |
if [ -z "$GZIP" ]; then
|
|
144 |
GZIP="gzip"
|
|
145 |
fi
|
|
146 |
(cd $DEVKIT_ROOT && tar c - . | $GZIP - > "$DEVKIT_BUNDLE")
|