Skip to content
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

Add support for creating source archives #2702

Merged
merged 1 commit into from
Sep 10, 2021
Merged
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 makejdk-any-platform.1
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ specify any custom user configuration arguments.
.BR \-\-clean-git-repo
clean out any 'bad' local git repo you already have.
.TP
.BR \-\-create-source-archive
create an archive of the sources which got used to build OpenJDK
.TP
.BR \-d ", " \-\-destination " " \fI<path>\fR
specify the location for the built binary, e.g. /path/.
This is typically used in conjunction with \fB<-T>\fR to create a custom path
Expand Down
38 changes: 38 additions & 0 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,40 @@ buildTemplatedFile() {
-e "s|{makeCommandArg}|${FULL_MAKE_COMMAND}|" >"${BUILD_CONFIG[WORKSPACE_DIR]}/config/configure-and-build.sh"
}

createSourceArchive() {
local sourceDir="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}"
local sourceArchiveTargetPath="$(getSourceArchivePath)"
local tmpSourceVCS="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/tmp-openjdk-git"
local srcArchiveName
if echo ${BUILD_CONFIG[TARGET_FILE_NAME]} | grep -q hotspot; then
# Transform 'OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.12_7.tar.gz' to 'OpenJDK11U-sources_11.0.12_7.tar.gz'
srcArchiveName=$(echo "${BUILD_CONFIG[TARGET_FILE_NAME]//-jdk_*(?)_hotspot_/-sources_}")
else
srcArchiveName=$(echo "${BUILD_CONFIG[TARGET_FILE_NAME]//-jdk/-sources}")
fi

local oldPwd="${PWD}"
cd "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}"
echo "Temporarily moving VCS source dir to ${tmpSourceVCS}"
mv "${sourceDir}/.git" "${tmpSourceVCS}"
echo "Temporarily moving source dir to ${sourceArchiveTargetPath}"
mv "${sourceDir}" "${sourceArchiveTargetPath}"

echo "OpenJDK source archive path will be ${sourceArchiveTargetPath}."
createArchive "${sourceArchiveTargetPath}" "${srcArchiveName}"

echo "Restoring source dir from ${sourceArchiveTargetPath} to ${sourceDir}"
mv "${sourceArchiveTargetPath}" "${sourceDir}"
echo "Restoring VCS source dir from ${tmpSourceVCS} to ${sourceDir}/.git"
mv "${tmpSourceVCS}" "${sourceDir}/.git"
cd "${oldPwd}"
}

executeTemplatedFile() {

if [ "${BUILD_CONFIG[CREATE_SOURCE_ARCHIVE]}" == "true" ]; then
createSourceArchive
fi
stepIntoTheWorkingDirectory

echo "Currently at '${PWD}'"
Expand Down Expand Up @@ -675,6 +708,11 @@ getTestImageArchivePath() {
echo "${jdkArchivePath}-test-image"
}

getSourceArchivePath() {
local jdkArchivePath=$(getJdkArchivePath)
echo "${jdkArchivePath}-src"
}

getDebugImageArchivePath() {
local jdkArchivePath=$(getJdkArchivePath)
echo "${jdkArchivePath}-debug-image"
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 @@ -48,6 +48,7 @@ COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG
COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG
COPY_TO_HOST
CREATE_DEBUG_IMAGE
CREATE_SOURCE_ARCHIVE
CUSTOM_CACERTS
CROSSCOMPILE
DEBUG_DOCKER
Expand Down Expand Up @@ -234,6 +235,9 @@ function parseConfigurationArguments() {
"--create-debug-image" )
BUILD_CONFIG[CREATE_DEBUG_IMAGE]="true";;

"--create-source-archive" )
BUILD_CONFIG[CREATE_SOURCE_ARCHIVE]=true;;

"--disable-adopt-branch-safety" )
BUILD_CONFIG[DISABLE_ADOPT_BRANCH_SAFETY]=true;;

Expand Down Expand Up @@ -447,6 +451,9 @@ function configDefaults() {
# The default behavior of whether we want to create a separate debug symbols archive
BUILD_CONFIG[CREATE_DEBUG_IMAGE]="false"

# The default behavior of whether we want to create a separate source archive
BUILD_CONFIG[CREATE_SOURCE_ARCHIVE]="false"

BUILD_CONFIG[SIGN]="false"
BUILD_CONFIG[JDK_BOOT_DIR]=""

Expand Down