Created
November 18, 2021 12:40
-
-
Save dkocher/8a4b67dd0bcf3489a056fbadef834e24 to your computer and use it in GitHub Desktop.
Java Runtime Universal Binary (x86_64+arm64)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
UNIVERSAL_JDK=$(pwd)/$3 | |
ARM64_JDK=$(pwd)/$1 | |
X86_64_JDK=$(pwd)/$2 | |
${ARM64_JDK}/Contents/Home/bin/jlink --add-modules ALL-MODULE-PATH --strip-debug --no-man-pages --no-header-files --compress=2 --output ${ARM64_JDK}/Contents/jre | |
rm -rf ${ARM64_JDK}/Contents/Home | |
mv ${ARM64_JDK}/Contents/jre ${ARM64_JDK}/Contents/Home | |
${X86_64_JDK}/Contents/Home/bin/jlink --add-modules ALL-MODULE-PATH --strip-debug --no-man-pages --no-header-files --compress=2 --output ${X86_64_JDK}/Contents/jre | |
rm -rf ${X86_64_JDK}/Contents/Home | |
mv ${X86_64_JDK}/Contents/jre ${X86_64_JDK}/Contents/Home | |
# We ditto both in case there is something present in one but not both. | |
ditto ${ARM64_JDK} ${UNIVERSAL_JDK} | |
ditto ${X86_64_JDK} ${UNIVERSAL_JDK} | |
for subdir in MacOS Home/bin Home/lib ; do | |
pushd ${UNIVERSAL_JDK}/Contents/${subdir} | |
find . -type f | while read file ; do | |
FILE_TYPE=$(file "${file}") | |
[[ ${FILE_TYPE} =~ "Mach-O" ]] || continue | |
if [[ -f "${ARM64_JDK}/Contents/${subdir}/${file}" && -f "${X86_64_JDK}/Contents/${subdir}/${file}" ]] ; then | |
lipo -output ${file} -create ${ARM64_JDK}/Contents/${subdir}/${file} ${X86_64_JDK}/Contents/${subdir}/${file} | |
fi | |
done | |
done | |
sed -i '' 's:x86_64:x86_64+arm64:' ${UNIVERSAL_JDK}/Contents/Home/release |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment