Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/make/devkit/createMacosxDevkit.sh
40919 views
1
#!/bin/bash
2
#
3
# Copyright (c) 2015, 2020, 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
# [email protected]
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="$(ls $XCODE_APP/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
52
| grep [0-9] | sort -r | head -n1 | sed 's/\.sdk//')"
53
54
DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"
55
DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
56
57
echo "Xcode version: $XCODE_VERSION"
58
echo "SDK version: $SDK_VERSION"
59
echo "Creating devkit in $DEVKIT_ROOT"
60
61
mkdir -p $DEVKIT_ROOT
62
63
################################################################################
64
# Copy the relevant parts of Xcode.app, removing things that are both big and
65
# unecessary for our purposes, without building an impossibly long exclude list.
66
EXCLUDE_DIRS=" \
67
Contents/_CodeSignature \
68
Contents/Applications \
69
Contents/Resources \
70
Contents/Library \
71
Contents/XPCServices \
72
Contents/OtherFrameworks \
73
Contents/Developer/Documentation \
74
Contents/Developer/usr/share \
75
Contents/Developer/usr/libexec/git-core \
76
Contents/Developer/usr/bin/git* \
77
Contents/Developer/usr/bin/svn* \
78
Contents/Developer/usr/lib/libgit* \
79
Contents/Developer/usr/lib/libsvn* \
80
Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man \
81
Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man \
82
Contents/Developer/Platforms/MacOSX.platform/Developer/usr/share/man \
83
Contents/Developer/Platforms/MacOSX.platform/usr \
84
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man \
85
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift* \
86
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift* \
87
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework \
88
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/swift* \
89
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/swift* \
90
Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/arc \
91
Platforms/AppleTVSimulator.platform \
92
Platforms/iPhoneSimulator.platform \
93
Platforms/WatchSimulator.platform \
94
Contents/SharedFrameworks/ModelIO.framework \
95
Contents/SharedFrameworks/XCSUI.framework \
96
Contents/SharedFrameworks/SceneKit.framework \
97
Contents/SharedFrameworks/XCBuild.framework \
98
Contents/SharedFrameworks/GPUTools*.framework \
99
Contents/SharedFrameworks/DNTDocumentationSupport.framework/Versions/A/Resources/external \
100
$(cd $XCODE_APP && ls -d Contents/Developer/Platforms/* \
101
| grep -v MacOSX.platform | grep -v WatchSimulator.platform) \
102
"
103
104
for ex in $EXCLUDE_DIRS; do
105
EXCLUDE_ARGS+="--exclude=$ex "
106
done
107
108
echo "Copying Xcode.app..."
109
echo rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP/." $DEVKIT_ROOT/Xcode.app/
110
rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP/." $DEVKIT_ROOT/Xcode.app/
111
112
################################################################################
113
114
echo-info() {
115
echo "$1" >> $DEVKIT_ROOT/devkit.info
116
}
117
118
echo "Generating devkit.info..."
119
rm -f $DEVKIT_ROOT/devkit.info
120
echo-info "# This file describes to configure how to interpret the contents of this devkit"
121
echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
122
echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
123
echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK_VERSION.sdk\""
124
echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_TOOLCHAIN_PATH\""
125
126
################################################################################
127
# Copy this script
128
129
echo "Copying this script..."
130
cp $0 $DEVKIT_ROOT/
131
132
################################################################################
133
# Create bundle
134
135
echo "Creating bundle..."
136
GZIP=$(command -v pigz)
137
if [ -z "$GZIP" ]; then
138
GZIP="gzip"
139
fi
140
(cd $DEVKIT_ROOT && tar c - . | $GZIP - > "$DEVKIT_BUNDLE")
141
142