From 1ea6716f9da5560a6f42bdcfbdca8348e2964ede Mon Sep 17 00:00:00 2001 From: Austin Date: Thu, 3 Sep 2020 16:08:01 +0100 Subject: [PATCH] Fixes for Cygwin and OpenJ9 issues Signed-off-by: Austin Bailey --- sbin/build.sh | 79 +++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/sbin/build.sh b/sbin/build.sh index 416ba4270..9f591426b 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -833,10 +833,10 @@ fixJavaHomeUnderDocker() { addInfoToReleaseFile(){ # Extra information is added to the release file here - cd ${BUILD_CONFIG[JDK_PATH]} + cd $PRODUCT_HOME + JAVA_LOC="$PRODUCT_HOME/bin/java" addImplementor addBuildSHA - addBuildNumber addFullVersion addBuildOS addJVMVariant @@ -844,25 +844,18 @@ addInfoToReleaseFile(){ # OpenJ9 specific options if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_OPENJ9}" ]; then addHeapSize + addJ9Tag fi } -addBuildNumber(){ - # If variable is populated add it to the release file - if [[ ${BUILD_CONFIG[OPENJDK_BUILD_NUMBER]} ]]; then - echo -e BUILD_NUMBER=\"${BUILD_CONFIG[OPENJDK_BUILD_NUMBER]}\" >> release - fi -} - -addHeapSize(){ - local jdkPath=${BUILD_CONFIG[JDK_PATH]} - if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ]; then - if [ -d $jdkPath/jre/lib/amd64/compressedrefs ] || [ -d $jdkPath/lib/compressedrefs ]; then - echo -e HEAP_SIZE=\"Standard\" >> release - else # Large heap has the folder /jre/lib/amd64/default or /lib/default - echo -e HEAP_SIZE=\"Large\" >> release - fi +addHeapSize(){ # Adds an identifier for heap size on OpenJ9 builds + local heapSize="" + if [[ $($JAVA_LOC -version 2>&1 | grep 'Compressed References') ]]; then + heapSize="Standard" + else + heapSize="Large" fi + echo -e HEAP_SIZE=\"$heapSize\" >> release } addImplementor(){ @@ -871,54 +864,52 @@ addImplementor(){ fi } -addJVMVersion(){ - local javaLoc="${BUILD_CONFIG[JDK_PATH]}/bin/java" - if [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "cygwin" ]; then - javaLoc="${BUILD_CONFIG[JDK_PATH]}/bin/java.exe" - elif [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "darwin" ]; then - javaLoc="${BUILD_CONFIG[JDK_PATH]}/Contents/Home/bin/java" - fi - local jvmVersion = $($javaLoc -XshowSettings:properties -version 2>&1 | grep 'java.vm.version' | sed 's/^.*= //') +addJVMVersion(){ # Adds the JVM version i.e. openj9-0.21.0 + local jvmVersion=$($JAVA_LOC -XshowSettings:properties -version 2>&1 | grep 'java.vm.version' | sed 's/^.*= //' | tr -d '\r') echo -e JVM_VERSION=\"$jvmVersion\" >> release } -addFullVersion(){ - echo -e FULL_VERSION=\"${BUILD_CONFIG[TAG]}\" >> release +addFullVersion(){ # Adds the full version including build number i.e. 11.0.9+5-202009040847 + local fullVer=$($JAVA_LOC -XshowSettings:properties -version 2>&1 | grep 'java.runtime.version' | sed 's/^.*= //' | tr -d '\r') + echo -e FULL_VERSION=\"$fullVer\" >> release } addJVMVariant(){ - local jvmName="" - if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_OPENJ9}" ]; then - jvmName="Openj9"; - elif [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_CORRETTO}" ]; then - jvmName="Corretto"; - elif [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_HOTSPOT}" ]; then - jvmName="Hotspot"; - fi - echo -e JVM_VARIANT=\"$jvmName\" >> release + echo -e JVM_VARIANT=\"${BUILD_CONFIG[BUILD_VARIANT]^}\" >> release } -addBuildSHA(){ +addBuildSHA(){ # git SHA of the build repository i.e. openjdk-build local buildSHA=$(git -C ${BUILD_CONFIG[WORKSPACE_DIR]} rev-parse --short HEAD) - echo -e BUILD_SOURCE=\"$buildSHA\" >> release + echo -e BUILD_SOURCE=\"git:$buildSHA\" >> release } addBuildOS(){ - local buildOS="" - local buildVer="" - if [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "cygwin" ]; then - buildOS=$(systeminfo | sed -n 's/^OS Name:[[:blank:]]*//p') - buildVer=$(systeminfo | sed -n 's/^OS Version:[[:blank:]]*//p') - elif [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "darwin" ]; then + local buildOS="Unknown" + local buildVer="Unknown" + if [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "darwin" ]; then buildOS=$(sw_vers | sed -n 's/^ProductName:[[:blank:]]*//p') buildVer=$(sw_vers | tail -n 2 | awk '{print $2}') elif [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "linux" ]; then buildOS=$(uname -s) buildVer=$(uname -r) + else # Fall back to java properties OS/Version info + buildOS=$($JAVA_LOC -XshowSettings:properties -version 2>&1 | grep 'os.name' | sed 's/^.*= //' | tr -d '\r') + buildVer=$($JAVA_LOC -XshowSettings:properties -version 2>&1 | grep 'os.version' | sed 's/^.*= //' | tr -d '\r') fi echo -e BUILD_INFO=\"OS: $buildOS Version: $buildVer\" >> release } +addJ9Tag(){ + # java.vm.version varies or for OpenJ9 depending on if it is a release build i.e. master-*gitSha* or 0.21.0 + # This code makes sure that a version number is always present in the release file i.e. openj9-0.21.0 + if [ ${BUILD_CONFIG[RELEASE]} = false ]; then + local j9Location="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/openj9" + # Pull the tag associated with the J9 commit being used + local j9Tag=$(git -C $j9Location describe --abbrev=0) + echo -e OPENJ9_TAG=\"$j9Tag\" >> release + fi +} + ################################################################################ loadConfigFromFile