Skip to content

Commit 9a8b11b

Browse files
judovanakarianna
andauthored
adaptation of JDK-8 to build with in-tree freetype (#4287)
* Initial minimalistic adaptation of 8 to build with in-tree freetype * Determining free type absed on jdk's 8 tag the if is to long, will refactor * Simplified the condition * The in-tree freetype will appear in 482-b02 * Update sbin/build.sh Co-authored-by: Martijn Verburg <martijnverburg@gmail.com> * No longer building freetype if it exists in sources * Get rid of relative path * Aligned modified block to two spaces * Enforced the freetype switches checks * Update sbin/prepareWorkspace.sh Co-authored-by: Martijn Verburg <martijnverburg@gmail.com> * Update sbin/prepareWorkspace.sh Co-authored-by: Martijn Verburg <martijnverburg@gmail.com> * Update sbin/prepareWorkspace.sh Co-authored-by: Martijn Verburg <martijnverburg@gmail.com> * Small rephrasing ow errors * Renamed main freetype methods to match theirs real meaning setDefaultFreeType->setBundledFreeType setFreeTypeFromSrcs->setFreeTypeFromExternalSrcs --------- Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>
1 parent a5a8f52 commit 9a8b11b

File tree

2 files changed

+79
-24
lines changed

2 files changed

+79
-24
lines changed

sbin/build.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -640,22 +640,34 @@ configureAlsaLocation() {
640640
fi
641641
}
642642

643+
setBundledFreeType() {
644+
echo "Freetype set from bundled in jdk"
645+
freetypeDir=${BUILD_CONFIG[FREETYPE_DIRECTORY]:-bundled}
646+
}
647+
648+
setFreeTypeFromExternalSrcs() {
649+
echo "Freetype set from local sources"
650+
addConfigureArg "--with-freetype-src=" "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/freetype"
651+
}
652+
653+
setFreeTypeFromInstalled() {
654+
echo "Freetype set from installed binary"
655+
freetypeDir=${BUILD_CONFIG[FREETYPE_DIRECTORY]:-"${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedfreetype"}
656+
}
657+
643658
configureFreetypeLocation() {
644659
if [[ ! "${CONFIGURE_ARGS}" =~ "--with-freetype" ]]; then
645660
if [[ "${BUILD_CONFIG[FREETYPE]}" == "true" ]]; then
646661
local freetypeDir="${BUILD_CONFIG[FREETYPE_DIRECTORY]}"
647-
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
648-
case "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" in
649-
jdk8* | jdk9* | jdk10*) addConfigureArg "--with-freetype-src=" "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/freetype" ;;
650-
*) freetypeDir=${BUILD_CONFIG[FREETYPE_DIRECTORY]:-bundled} ;;
651-
esac
662+
if isFreeTypeInSources ; then
663+
setBundledFreeType
652664
else
653-
case "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" in
654-
jdk8* | jdk9* | jdk10*) freetypeDir=${BUILD_CONFIG[FREETYPE_DIRECTORY]:-"${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedfreetype"} ;;
655-
*) freetypeDir=${BUILD_CONFIG[FREETYPE_DIRECTORY]:-bundled} ;;
656-
esac
665+
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
666+
setFreeTypeFromExternalSrcs
667+
else
668+
setFreeTypeFromInstalled
669+
fi
657670
fi
658-
659671
if [[ -n "$freetypeDir" ]]; then
660672
echo "setting freetype dir to ${freetypeDir}"
661673
addConfigureArg "--with-freetype=" "${freetypeDir}"

sbin/prepareWorkspace.sh

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,48 @@ FREETYPE_FONT_SHARED_OBJECT_FILENAME="libfreetype.so*"
4040
# sha256 of https://github.com/adoptium/devkit-binaries/releases/tag/vs2022_redist_14.40.33807_10.0.26100.1742
4141
WINDOWS_REDIST_CHECKSUM="ac6060f5f8a952f59faef20e53d124c2c267264109f3f6fabeb2b7aefb3e3c62"
4242

43+
44+
checkBundledFreetypeJdkConfig() {
45+
if [ "${BUILD_CONFIG[FREETYPE_DIRECTORY]}" = "bundled" ] ; then
46+
if [ "${BUILD_CONFIG[FREETYPE]}" = "false" ] ; then
47+
echo "--freetype-dir 'bundled' is in contradiction with -skip-freetype"
48+
exit 1
49+
fi
50+
echo "--freetype-dir is set to 'bundled' which is unusual, but accepted. It should be default."
51+
elif [ "${BUILD_CONFIG[FREETYPE_DIRECTORY]}" = "system" ] ; then
52+
echo "--freetype-dir is set to 'system' which is unusual, but accepted. Use --skip-freetype instead."
53+
elif [ -n "${BUILD_CONFIG[FREETYPE_DIRECTORY]}" ] ; then
54+
echo "--freetype-dir is not accepted for JDK with bundled freetype."
55+
exit 1
56+
fi
57+
}
58+
59+
checkNoBundledFreetypeJdkConfig() {
60+
if [ "${BUILD_CONFIG[FREETYPE]}" = "false" ] && [ -n "${BUILD_CONFIG[FREETYPE_DIRECTORY]}" ] ; then
61+
echo "--freetype-dir is declared together with --skip-freetype, that is invalid, as JDK would build against system freetype anyway."
62+
exit 1
63+
fi
64+
}
65+
66+
isFreeTypeInSources() {
67+
local libfreetypeid="libfreetype/src"
68+
local location="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}"
69+
if [ ! -e "$location" ] ; then
70+
echo "No jdk sources exists to to determine $libfreetypeid presence"
71+
exit 1
72+
fi
73+
local found=0
74+
find "$location" | grep -q "$libfreetypeid" || found=$?
75+
if [ $found -eq 0 ] ; then
76+
echo "$libfreetypeid found in $location"
77+
checkBundledFreetypeJdkConfig
78+
else
79+
echo "$libfreetypeid not found in $location"
80+
checkNoBundledFreetypeJdkConfig
81+
fi
82+
return $found
83+
}
84+
4385
copyFromDir() {
4486
echo "Copying OpenJDK source from ${BUILD_CONFIG[OPENJDK_LOCAL_SOURCE_ARCHIVE_ABSPATH]} to $(pwd)/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]} to be built"
4587
# We really do not want to use .git for dirs, as we expect user have them set up, ignoring them
@@ -824,6 +866,8 @@ downloadBootJdkIfNeeded () {
824866

825867
# Download all of the dependencies for OpenJDK (Alsa, FreeType, boot-jdk etc.)
826868
downloadingRequiredDependencies() {
869+
local freeTypeInSources=0
870+
isFreeTypeInSources || freeTypeInSources="$?"
827871
if [[ "${BUILD_CONFIG[CLEAN_LIBS]}" == "true" ]]; then
828872
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/freetype" || true
829873
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedalsa" || true
@@ -850,19 +894,18 @@ downloadingRequiredDependencies() {
850894
fi
851895

852896
if [[ "${BUILD_CONFIG[FREETYPE]}" == "true" ]]; then
853-
case "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" in
854-
jdk8* | jdk9* | jdk10*)
855-
if [ -z "${BUILD_CONFIG[FREETYPE_DIRECTORY]}" ]; then
856-
echo "Checking and download FreeType Font dependency"
857-
checkingAndDownloadingFreeType
858-
else
859-
echo ""
860-
echo "---> Skipping the process of checking and downloading the FreeType Font dependency, a pre-built version provided at ${BUILD_CONFIG[FREETYPE_DIRECTORY]} <---"
861-
echo ""
862-
fi
863-
;;
864-
*) echo "Using bundled Freetype" ;;
865-
esac
897+
if [ "0${freeTypeInSources}" -ne 0 ] ; then
898+
if [ -z "${BUILD_CONFIG[FREETYPE_DIRECTORY]}" ]; then
899+
echo "Checking and downloading FreeType Font dependency"
900+
checkingAndDownloadingFreeType
901+
else
902+
echo ""
903+
echo "---> Skipping the process of checking and downloading the FreeType Font dependency, a pre-built version is provided at ${BUILD_CONFIG[FREETYPE_DIRECTORY]} <---"
904+
echo ""
905+
fi
906+
else
907+
echo "Using bundled Freetype"
908+
fi
866909
else
867910
echo "Skipping Freetype"
868911
fi
@@ -947,10 +990,10 @@ createSourceTagFile(){
947990
function configureWorkspace() {
948991
if [[ "${BUILD_CONFIG[ASSEMBLE_EXPLODED_IMAGE]}" != "true" ]]; then
949992
createWorkspace
993+
checkoutAndCloneOpenJDKGitRepo
950994
downloadingRequiredDependencies
951995
downloadDevkit
952996
relocateToTmpIfNeeded
953-
checkoutAndCloneOpenJDKGitRepo
954997
applyPatches
955998
if [ "${BUILD_CONFIG[CUSTOM_CACERTS]}" = "true" ] ; then
956999
prepareMozillaCacerts

0 commit comments

Comments
 (0)