Path: blob/master/make/devkit/createMacosxDevkit.sh
40919 views
#!/bin/bash1#2# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4#5# This code is free software; you can redistribute it and/or modify it6# under the terms of the GNU General Public License version 2 only, as7# published by the Free Software Foundation. Oracle designates this8# particular file as subject to the "Classpath" exception as provided9# by Oracle in the LICENSE file that accompanied this code.10#11# This code is distributed in the hope that it will be useful, but WITHOUT12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License14# version 2 for more details (a copy is included in the LICENSE file that15# accompanied this code).16#17# You should have received a copy of the GNU General Public License version18# 2 along with this work; if not, write to the Free Software Foundation,19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.20#21# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA22# or visit www.oracle.com if you need additional information or have any23# questions.24#2526# This script copies parts of an Xcode installation into a devkit suitable27# for building OpenJDK and OracleJDK. The installation Xcode_X.X.xip needs28# to be either installed or extracted using for example Archive Utility.29# The easiest way to accomplish this is to right click the file in Finder30# and choose "Open With -> Archive Utility", or possible typing31# "open Xcode_9.2.xip" in a terminal.32# [email protected]3334USAGE="$0 <Xcode.app>"3536if [ "$1" = "" ]; then37echo $USAGE38exit 139fi4041XCODE_APP="$1"42XCODE_APP_DIR_NAME="${XCODE_APP##*/}"4344SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"45BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"4647# Find the version of Xcode48XCODE_VERSION="$($XCODE_APP/Contents/Developer/usr/bin/xcodebuild -version \49| awk '/Xcode/ { print $2 }' )"50SDK_VERSION="$(ls $XCODE_APP/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \51| grep [0-9] | sort -r | head -n1 | sed 's/\.sdk//')"5253DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"54DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"5556echo "Xcode version: $XCODE_VERSION"57echo "SDK version: $SDK_VERSION"58echo "Creating devkit in $DEVKIT_ROOT"5960mkdir -p $DEVKIT_ROOT6162################################################################################63# Copy the relevant parts of Xcode.app, removing things that are both big and64# unecessary for our purposes, without building an impossibly long exclude list.65EXCLUDE_DIRS=" \66Contents/_CodeSignature \67Contents/Applications \68Contents/Resources \69Contents/Library \70Contents/XPCServices \71Contents/OtherFrameworks \72Contents/Developer/Documentation \73Contents/Developer/usr/share \74Contents/Developer/usr/libexec/git-core \75Contents/Developer/usr/bin/git* \76Contents/Developer/usr/bin/svn* \77Contents/Developer/usr/lib/libgit* \78Contents/Developer/usr/lib/libsvn* \79Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man \80Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man \81Contents/Developer/Platforms/MacOSX.platform/Developer/usr/share/man \82Contents/Developer/Platforms/MacOSX.platform/usr \83Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man \84Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift* \85Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift* \86Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework \87Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec/swift* \88Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/swift* \89Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/arc \90Platforms/AppleTVSimulator.platform \91Platforms/iPhoneSimulator.platform \92Platforms/WatchSimulator.platform \93Contents/SharedFrameworks/ModelIO.framework \94Contents/SharedFrameworks/XCSUI.framework \95Contents/SharedFrameworks/SceneKit.framework \96Contents/SharedFrameworks/XCBuild.framework \97Contents/SharedFrameworks/GPUTools*.framework \98Contents/SharedFrameworks/DNTDocumentationSupport.framework/Versions/A/Resources/external \99$(cd $XCODE_APP && ls -d Contents/Developer/Platforms/* \100| grep -v MacOSX.platform | grep -v WatchSimulator.platform) \101"102103for ex in $EXCLUDE_DIRS; do104EXCLUDE_ARGS+="--exclude=$ex "105done106107echo "Copying Xcode.app..."108echo rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP/." $DEVKIT_ROOT/Xcode.app/109rsync -rlH $INCLUDE_ARGS $EXCLUDE_ARGS "$XCODE_APP/." $DEVKIT_ROOT/Xcode.app/110111################################################################################112113echo-info() {114echo "$1" >> $DEVKIT_ROOT/devkit.info115}116117echo "Generating devkit.info..."118rm -f $DEVKIT_ROOT/devkit.info119echo-info "# This file describes to configure how to interpret the contents of this devkit"120echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""121echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""122echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK_VERSION.sdk\""123echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_TOOLCHAIN_PATH\""124125################################################################################126# Copy this script127128echo "Copying this script..."129cp $0 $DEVKIT_ROOT/130131################################################################################132# Create bundle133134echo "Creating bundle..."135GZIP=$(command -v pigz)136if [ -z "$GZIP" ]; then137GZIP="gzip"138fi139(cd $DEVKIT_ROOT && tar c - . | $GZIP - > "$DEVKIT_BUNDLE")140141142