Skip to content

Add gtest support on jdk15+ #4134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ if your ssh key has a passphrase, add it to ssh-agent (e.g.: ssh-add ~/.ssh/id_r
--sign
sign the OpenJDK binary that you build.

--skip-gtest
Skips automatic download and configuration of gtest support.

--sudo
run the docker container as root.

Expand Down
3 changes: 3 additions & 0 deletions makejdk-any-platform.1
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ if your ssh key has a passphrase, add it to ssh-agent (e.g.: ssh-add ~/.ssh/id_r
specify the location for the certificate. For windows this is the p12
certificate to sign the DLL.
.TP
.BR \-\-skip-gtest
Skips automatic download and configuration of gtest support.
.TP
.BR \-\-sudo
run the docker container as root.
.TP
Expand Down
7 changes: 7 additions & 0 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,12 @@ configureZlibLocation() {
fi
}

configureGtestLocation() {
if [ "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" -ge 15 ] && [ "${BUILD_CONFIG[GTEST]}" = "true" ]; then
addConfigureArg "--with-gtest=" "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedgtest"
fi
}

# Configure the command parameters
configureCommandParameters() {
configureVersionStringParameter
Expand Down Expand Up @@ -624,6 +630,7 @@ configureCommandParameters() {

configureFreetypeLocation
configureZlibLocation
configureGtestLocation

echo "Completed configuring the version string parameter, config args are now: ${CONFIGURE_ARGS}"
}
Expand Down
7 changes: 7 additions & 0 deletions sbin/common/config_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ FREETYPE_DIRECTORY
FREETYPE_FONT_BUILD_TYPE_PARAM
FREETYPE_FONT_VERSION
GRADLE_USER_HOME_DIR
GTEST
KEEP_CONTAINER
JDK_BOOT_DIR
JDK_PATH
Expand Down Expand Up @@ -317,6 +318,9 @@ function parseConfigurationArguments() {
"--skip-alsa" | "-A" )
BUILD_CONFIG[ALSA]=false;;

"--skip-gtest" )
BUILD_CONFIG[GTEST]=false;;

"--help" | "-h" )
man ./makejdk-any-platform.1 && exit 0;;

Expand Down Expand Up @@ -675,6 +679,9 @@ function configDefaults() {

# Used in 'release' file for jdk8u
BUILD_CONFIG[VENDOR]=${BUILD_CONFIG[VENDOR]:-"Undefined Vendor"}

# By default, build test-image with gtest support
BUILD_CONFIG[GTEST]=true
}

# Declare the map of build configuration that we're going to use
Expand Down
21 changes: 21 additions & 0 deletions sbin/prepareWorkspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ FREETYPE_FONT_SHARED_OBJECT_FILENAME="libfreetype.so*"
# sha256 of https://github.com/adoptium/devkit-binaries/releases/tag/vs2022_redist_14.40.33807_10.0.26100.1742
WINDOWS_REDIST_CHECKSUM="ac6060f5f8a952f59faef20e53d124c2c267264109f3f6fabeb2b7aefb3e3c62"

GTEST_VERSION=1.16.0
GTEST_CHECKSUM="78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399"

copyFromDir() {
echo "Copying OpenJDK source from ${BUILD_CONFIG[OPENJDK_LOCAL_SOURCE_ARCHIVE_ABSPATH]} to $(pwd)/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]} to be built"
# We really do not want to use .git for dirs, as we expect user have them set up, ignoring them
Expand Down Expand Up @@ -817,12 +820,26 @@ downloadBootJdkIfNeeded () {
fi
}

downloadGtest() {
local gtestUnpacked="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedgtest"
if [ -e "${gtestUnpacked}" ]; then
echo "Reusing $gtestUnpacked"
else
local gtestArchive="${BUILD_CONFIG[WORKSPACE_DIR]}/libs/googletest-${GTEST_VERSION}.tar.gz"
downloadFile "${gtestArchive}" "https://github.com/google/googletest/releases/download/v${GTEST_VERSION}/googletest-${GTEST_VERSION}.tar.gz" "${GTEST_CHECKSUM}"
mkdir -p "${gtestUnpacked}"
tar -xzf "${gtestArchive}" --strip-components=1 -C "${gtestUnpacked}"
rm -f "${gtestArchive}"
fi
}

# Download all of the dependencies for OpenJDK (Alsa, FreeType, boot-jdk etc.)
downloadingRequiredDependencies() {
if [[ "${BUILD_CONFIG[CLEAN_LIBS]}" == "true" ]]; then
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/freetype" || true
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedalsa" || true
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedfreetype" || true
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedgtest" || true
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" || true
fi

Expand Down Expand Up @@ -861,6 +878,10 @@ downloadingRequiredDependencies() {
else
echo "Skipping Freetype"
fi

if [ "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" -ge 15 ] && [ "${BUILD_CONFIG[GTEST]}" = "true" ]; then
downloadGtest
fi
}

function moveTmpToWorkspaceLocation() {
Expand Down
Loading