31123
|
1 |
#!/bin/bash
|
|
2 |
#
|
|
3 |
# Copyright (c) 2015, 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 part of an Xcode installer into a devkit suitable
|
|
28 |
# for building OpenJDK and OracleJDK. The installation .dmg files for Xcode
|
|
29 |
# and the aux tools need to be available.
|
|
30 |
# erik.joelsson@oracle.com
|
|
31 |
|
|
32 |
USAGE="$0 <Xcode.dmg> <XQuartz.dmg> [<auxtools.dmg>]"
|
|
33 |
|
|
34 |
if [ "$1" = "" ] || [ "$2" = "" ]; then
|
|
35 |
echo $USAGE
|
|
36 |
exit 1
|
|
37 |
fi
|
|
38 |
|
|
39 |
XCODE_DMG="$1"
|
|
40 |
XQUARTZ_DMG="$2"
|
|
41 |
AUXTOOLS_DMG="$3"
|
|
42 |
|
|
43 |
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
|
|
44 |
BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
|
|
45 |
|
|
46 |
# Mount XCODE_DMG
|
|
47 |
if [ -e "/Volumes/Xcode" ]; then
|
|
48 |
hdiutil detach /Volumes/Xcode
|
|
49 |
fi
|
|
50 |
hdiutil attach $XCODE_DMG
|
|
51 |
|
|
52 |
# Find the version of Xcode
|
|
53 |
XCODE_VERSION="$(/Volumes/Xcode/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version \
|
|
54 |
| awk '/Xcode/ { print $2 }' )"
|
|
55 |
|
|
56 |
DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-devkit"
|
|
57 |
DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
|
|
58 |
|
|
59 |
echo "Xcode version: $XCODE_VERSION"
|
|
60 |
echo "Creating devkit in $DEVKIT_ROOT"
|
|
61 |
|
|
62 |
################################################################################
|
|
63 |
# Copy files to root
|
|
64 |
mkdir -p $DEVKIT_ROOT
|
|
65 |
if [ ! -d $DEVKIT_ROOT/Xcode.app ]; then
|
|
66 |
echo "Copying Xcode.app..."
|
|
67 |
cp -RH "/Volumes/Xcode/Xcode.app" $DEVKIT_ROOT/
|
|
68 |
fi
|
|
69 |
# Trim out some seemingly unneeded parts to save space.
|
|
70 |
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Applications
|
|
71 |
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/iPhone*
|
|
72 |
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Documentation
|
|
73 |
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/share/man
|
|
74 |
if [ -e $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk ]; then
|
|
75 |
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
|
|
76 |
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man
|
|
77 |
fi
|
|
78 |
|
|
79 |
hdiutil detach /Volumes/Xcode
|
|
80 |
|
|
81 |
################################################################################
|
|
82 |
# Copy Freetype into sysroot
|
|
83 |
if [ -e "/Volumes/XQuartz-*" ]; then
|
|
84 |
hdiutil detach /Volumes/XQuartz-*
|
|
85 |
fi
|
|
86 |
hdiutil attach $XQUARTZ_DMG
|
|
87 |
|
|
88 |
echo "Copying freetype..."
|
|
89 |
rm -rf /tmp/XQuartz
|
|
90 |
pkgutil --expand /Volumes/XQuartz-*/XQuartz.pkg /tmp/XQuartz/
|
|
91 |
rm -rf /tmp/x11
|
|
92 |
mkdir /tmp/x11
|
|
93 |
cd /tmp/x11
|
|
94 |
cat /tmp/XQuartz-*/x11.pkg/Payload | gunzip -dc |cpio -i
|
|
95 |
|
|
96 |
cp -RH opt/X11/include/freetype2 \
|
|
97 |
$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
|
|
98 |
cp -RH opt/X11/include/ft2build.h \
|
|
99 |
$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
|
|
100 |
cp -RH opt/X11/lib/libfreetype.* \
|
|
101 |
$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/
|
|
102 |
|
|
103 |
cd -
|
|
104 |
|
|
105 |
hdiutil detach /Volumes/XQuartz-*
|
|
106 |
|
|
107 |
################################################################################
|
|
108 |
# Optionally copy PackageMaker
|
|
109 |
|
|
110 |
if [ -e "$AUXTOOLS_DMG" ]; then
|
|
111 |
if [ -e "/Volumes/Auxiliary Tools" ]; then
|
|
112 |
hdiutil detach "/Volumes/Auxiliary Tools"
|
|
113 |
fi
|
|
114 |
hdiutil attach $AUXTOOLS_DMG
|
|
115 |
|
|
116 |
echo "Copying PackageMaker.app..."
|
|
117 |
cp -RH "/Volumes/Auxiliary Tools/PackageMaker.app" $DEVKIT_ROOT/
|
|
118 |
|
|
119 |
hdiutil detach "/Volumes/Auxiliary Tools"
|
|
120 |
fi
|
|
121 |
|
|
122 |
################################################################################
|
|
123 |
# Generate devkit.info
|
|
124 |
|
|
125 |
echo-info() {
|
|
126 |
echo "$1" >> $DEVKIT_ROOT/devkit.info
|
|
127 |
}
|
|
128 |
|
|
129 |
echo "Generating devkit.info..."
|
|
130 |
rm -f $DEVKIT_ROOT/devkit.info
|
|
131 |
echo-info "# This file describes to configure how to interpret the contents of this devkit"
|
|
132 |
echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
|
|
133 |
echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
|
|
134 |
echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk\""
|
|
135 |
echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/PackageMaker.app/Contents/MacOS:\$DEVKIT_TOOLCHAIN_PATH\""
|
|
136 |
|
|
137 |
################################################################################
|
|
138 |
# Copy this script
|
|
139 |
|
|
140 |
echo "Copying this script..."
|
|
141 |
cp $0 $DEVKIT_ROOT/
|
|
142 |
|
|
143 |
################################################################################
|
|
144 |
# Create bundle
|
|
145 |
|
|
146 |
echo "Creating bundle..."
|
|
147 |
(cd $DEVKIT_ROOT && tar c - . | gzip - > "$DEVKIT_BUNDLE")
|