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> <gnu make binary> [<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 GNU_MAKE="$3" |
|
42 AUXTOOLS_DMG="$4" |
|
43 |
|
44 SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)" |
|
45 BUILD_DIR="${SCRIPT_DIR}/../../build/devkit" |
|
46 |
|
47 # Mount XCODE_DMG |
|
48 if [ -e "/Volumes/Xcode" ]; then |
|
49 hdiutil detach /Volumes/Xcode |
|
50 fi |
|
51 hdiutil attach $XCODE_DMG |
|
52 |
|
53 # Find the version of Xcode |
|
54 XCODE_VERSION="$(/Volumes/Xcode/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version \ |
|
55 | awk '/Xcode/ { print $2 }' )" |
|
56 SDK_VERSION="MacOSX10.9" |
|
57 if [ ! -e "/Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk" ]; then |
|
58 echo "Expected SDK version not found: ${SDK_VERSION}" |
|
59 exit 1 |
|
60 fi |
|
61 |
|
62 DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}" |
|
63 DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz" |
|
64 |
|
65 echo "Xcode version: $XCODE_VERSION" |
|
66 echo "Creating devkit in $DEVKIT_ROOT" |
|
67 |
|
68 ################################################################################ |
|
69 # Copy files to root |
|
70 mkdir -p $DEVKIT_ROOT |
|
71 if [ ! -d $DEVKIT_ROOT/Xcode.app ]; then |
|
72 echo "Copying Xcode.app..." |
|
73 cp -RH "/Volumes/Xcode/Xcode.app" $DEVKIT_ROOT/ |
|
74 fi |
|
75 # Trim out some seemingly unneeded parts to save space. |
|
76 rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Applications |
|
77 rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/iPhone* |
|
78 rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Documentation |
|
79 rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/share/man |
|
80 ( cd $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \ |
|
81 && rm -rf `ls | grep -v ${SDK_VERSION}` ) |
|
82 rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man |
|
83 |
|
84 hdiutil detach /Volumes/Xcode |
|
85 |
|
86 ################################################################################ |
|
87 # Copy Freetype into sysroot |
|
88 if [ -e "/Volumes/XQuartz-*" ]; then |
|
89 hdiutil detach /Volumes/XQuartz-* |
|
90 fi |
|
91 hdiutil attach $XQUARTZ_DMG |
|
92 |
|
93 echo "Copying freetype..." |
|
94 rm -rf /tmp/XQuartz |
|
95 pkgutil --expand /Volumes/XQuartz-*/XQuartz.pkg /tmp/XQuartz/ |
|
96 rm -rf /tmp/x11 |
|
97 mkdir /tmp/x11 |
|
98 cd /tmp/x11 |
|
99 cat /tmp/XQuartz/x11.pkg/Payload | gunzip -dc | cpio -i |
|
100 |
|
101 mkdir -p $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/ |
|
102 mkdir -p $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/lib/ |
|
103 cp -RH opt/X11/include/freetype2 \ |
|
104 $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/ |
|
105 cp -RH opt/X11/include/ft2build.h \ |
|
106 $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/ |
|
107 cp -RH opt/X11/lib/libfreetype.* \ |
|
108 $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/lib/ |
|
109 |
|
110 cd - |
|
111 |
|
112 hdiutil detach /Volumes/XQuartz-* |
|
113 |
|
114 ################################################################################ |
|
115 # Copy gnu make |
|
116 mkdir -p $DEVKIT_ROOT/bin |
|
117 cp $GNU_MAKE $DEVKIT_ROOT/bin |
|
118 |
|
119 ################################################################################ |
|
120 # Optionally copy PackageMaker |
|
121 |
|
122 if [ -e "$AUXTOOLS_DMG" ]; then |
|
123 if [ -e "/Volumes/Auxiliary Tools" ]; then |
|
124 hdiutil detach "/Volumes/Auxiliary Tools" |
|
125 fi |
|
126 hdiutil attach $AUXTOOLS_DMG |
|
127 |
|
128 echo "Copying PackageMaker.app..." |
|
129 cp -RH "/Volumes/Auxiliary Tools/PackageMaker.app" $DEVKIT_ROOT/ |
|
130 |
|
131 hdiutil detach "/Volumes/Auxiliary Tools" |
|
132 fi |
|
133 |
|
134 ################################################################################ |
|
135 # Generate devkit.info |
|
136 |
|
137 echo-info() { |
|
138 echo "$1" >> $DEVKIT_ROOT/devkit.info |
|
139 } |
|
140 |
|
141 echo "Generating devkit.info..." |
|
142 rm -f $DEVKIT_ROOT/devkit.info |
|
143 echo-info "# This file describes to configure how to interpret the contents of this devkit" |
|
144 echo-info "# The parameters used to create this devkit were:" |
|
145 echo-info "# $*" |
|
146 echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\"" |
|
147 echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\"" |
|
148 echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk\"" |
|
149 echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/bin:\$DEVKIT_ROOT/PackageMaker.app/Contents/MacOS:\$DEVKIT_TOOLCHAIN_PATH\"" |
|
150 |
|
151 ################################################################################ |
|
152 # Copy this script |
|
153 |
|
154 echo "Copying this script..." |
|
155 cp $0 $DEVKIT_ROOT/ |
|
156 |
|
157 ################################################################################ |
|
158 # Create bundle |
|
159 |
|
160 echo "Creating bundle..." |
|
161 (cd $DEVKIT_ROOT && tar c - . | gzip - > "$DEVKIT_BUNDLE") |
|