Eva Isabella Luna 3cda3c1ed5
[FIX] xattr command failing for JDK 8 iOS
Some versions of macOS on some machines might fail the build when xattr is invoked without sudo.
Since the reason xattr is invoked is to help with testing, and the attribute it is removing
is not relevant for iOS, this line can be safely removed from the build.
2025-07-02 22:17:57 -06:00

123 lines
4.2 KiB
Bash
Executable File

#!/bin/bash
set -e
. setdevkitpath.sh
if [[ "$TARGET_JDK" == "arm" ]]
then
export TARGET_JDK=aarch32
export TARGET_PHYS=aarch32-linux-androideabi
export JVM_VARIANTS=client
else
export TARGET_PHYS=$TARGET
fi
export FREETYPE_DIR=$PWD/freetype-$BUILD_FREETYPE_VERSION/build_android-$TARGET_SHORT
export CUPS_DIR=$PWD/cups-2.2.4
export CFLAGS+=" -DLE_STANDALONE" # -I$FREETYPE_DIR -I$CUPS_DI
# if [[ "$TARGET_JDK" == "aarch32" ]] || [[ "$TARGET_JDK" == "aarch64" ]]
# then
# export CFLAGS+=" -march=armv7-a+neon"
# fi
# It isn't good, but need make it build anyways
# cp -R $CUPS_DIR/* $ANDROID_INCLUDE/
# cp -R /usr/include/X11 $ANDROID_INCLUDE/
# cp -R /usr/include/fontconfig $ANDROID_INCLUDE/
if [[ "$BUILD_IOS" != "1" ]]; then
export CFLAGS+=" -O3 -D__ANDROID__"
ln -s -f /usr/include/X11 $ANDROID_INCLUDE/
ln -s -f /usr/include/fontconfig $ANDROID_INCLUDE/
AUTOCONF_x11arg="--x-includes=$ANDROID_INCLUDE/X11"
export LDFLAGS+=" -L`pwd`/dummy_libs"
# Create dummy libraries so we won't have to remove them in OpenJDK makefiles
mkdir -p dummy_libs
ar cru dummy_libs/libpthread.a
ar cru dummy_libs/libthread_db.a
else
ln -s -f /opt/X11/include/X11 $ANDROID_INCLUDE/
platform_args="--with-toolchain-type=clang SDKNAME=iphoneos"
# --disable-precompiled-headers
AUTOCONF_x11arg="--with-x=/opt/X11/include/X11 --prefix=/usr/lib"
sameflags="-arch arm64 -DHEADLESS=1 -I$PWD/ios-missing-include -Wno-c++11-narrowing -Wno-implicit-function-declaration -Wno-reserved-user-defined-literal -Wno-shift-negative-value"
export CFLAGS+=" $sameflags"
export LDFLAGS+=" -arch arm64"
export BUILD_SYSROOT_CFLAGS="-isysroot ${themacsysroot}"
if [[ "$J316SAP" != "1" ]]; then
HOMEBREW_NO_AUTO_UPDATE=1 brew install ldid xquartz
fi
fi
# fix building libjawt
ln -s -f $CUPS_DIR/cups $ANDROID_INCLUDE/
#FREEMARKER=$PWD/freemarker-2.3.8/lib/freemarker.jar
cd openjdk
# Apply patches
git reset --hard
if [[ "$BUILD_IOS" != "1" ]]; then
git apply --reject --whitespace=fix ../patches/jdk8u_android.diff || echo "git apply failed (universal patch set)"
if [[ "$TARGET_JDK" != "aarch32" ]]; then
git apply --reject --whitespace=fix ../patches/jdk8u_android_main.diff || echo "git apply failed (main non-universal patch set)"
else
git apply --reject --whitespace=fix ../patches/jdk8u_android_aarch32.diff || echo "git apply failed (aarch32 non-universal patch set)"
fi
if [[ "$TARGET_JDK" == "x86" ]]; then
git apply --reject --whitespace=fix ../patches/jdk8u_android_page_trap_fix.diff || echo "git apply failed (x86 page trap fix)"
fi
else
git apply --reject --whitespace=fix ../patches/jdk8u_ios.diff || echo "git apply failed (ios patch set)"
git apply --reject --whitespace=fix ../patches/jdk8u_ios_xattr.diff || echo "git apply failed (ios xattr patch set)"
git apply --reject --whitespace=fix ../patches/jdk8u_ios_fix_clang.diff || echo "git apply failed (ios clang fix patch set)"
fi
# --with-extra-cxxflags="$CXXFLAGS -Dchar16_t=uint16_t -Dchar32_t=uint32_t" \
# --with-extra-cflags="$CPPFLAGS" \
# --with-sysroot="$(xcrun --sdk iphoneos --show-sdk-path)" \
# Let's print what's available
# bash configure --help
# --with-freemarker-jar=$FREEMARKER \
# --with-toolchain-type=clang \
# --with-native-debug-symbols=none \
bash ./configure \
--openjdk-target=$TARGET_PHYS \
--with-extra-cflags="$CFLAGS" \
--with-extra-cxxflags="$CFLAGS" \
--with-extra-ldflags="$LDFLAGS" \
--enable-option-checking=fatal \
--with-jdk-variant=normal \
--with-jvm-variants="${JVM_VARIANTS/AND/,}" \
--with-cups-include=$CUPS_DIR \
--with-devkit=$TOOLCHAIN \
--with-debug-level=$JDK_DEBUG_LEVEL \
--with-fontconfig-include=$ANDROID_INCLUDE \
--with-freetype-lib=$FREETYPE_DIR/lib \
--with-freetype-include=$FREETYPE_DIR/include/freetype2 \
$AUTOCONF_x11arg $AUTOCONF_EXTRA_ARGS \
--x-libraries=/usr/lib \
$platform_args || \
error_code=$?
if [[ "$error_code" -ne 0 ]]; then
echo "\n\nCONFIGURE ERROR $error_code , config.log:"
cat config.log
exit $error_code
fi
cd build/${JVM_PLATFORM}-${TARGET_JDK}-normal-${JVM_VARIANTS}-${JDK_DEBUG_LEVEL}
make JOBS=4 images || \
error_code=$?
if [[ "$error_code" -ne 0 ]]; then
echo "Build failure, exited with code $error_code. Trying again."
make JOBS=4 images
fi