From 6e390bb28dd013c6c7c2a337aa3cfd8faf90d18b Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 8 Oct 2024 15:11:11 +0100 Subject: [PATCH 1/4] Add support for Windows Redist DLL as Adoptium DevKit Signed-off-by: Andrew Leonard --- sbin/build.sh | 23 ++++++++++- sbin/prepareWorkspace.sh | 83 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 97 insertions(+), 9 deletions(-) diff --git a/sbin/build.sh b/sbin/build.sh index 5d9ef5ac8..b92dbe086 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -76,7 +76,28 @@ addConfigureArgIfValueIsNotEmpty() { # Configure the DevKit if required configureDevKitConfigureParameter() { if [[ -n "${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" ]]; then - addConfigureArg "--with-devkit=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}" + if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then + # Windows DevKit, currently only Redist DLLs + + # This is TARGET Architecture for the Redist DLLs to use + # ARCHITECTURE is set to the "target" architecture by caller, or defaults to build architecture if not set + local dll_arch + if [[ "${ARCHITECTURE}" == "x86-32" ]]; then + dll_arch = "x86" + elif [[ "${ARCHITECTURE}" == "aarch64" ]]; then + dll_arch = "arm64" + else + dll_arch = "x64" + fi + + # Add Windows Redist DLL paths + addConfigureArg "--with-ucrt-dll-dir=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/ucrt/DLLs/${dll_arch}" + addConfigureArg "--with-msvcr-dll=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/vcruntime140.dll" + addConfigureArg "--with-vcruntime-1-dll=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/vcruntime140_1.dll" + addConfigureArg "--with-msvcp-dll=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/msvcp140.dll" + else + addConfigureArg "--with-devkit=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}" + fi fi } diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index 30ad58f46..dc33a8bbf 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -37,6 +37,8 @@ ALSA_LIB_CHECKSUM=${ALSA_LIB_CHECKSUM:-5f2cd274b272cae0d0d111e8a9e363f0878332915 ALSA_LIB_GPGKEYID=${ALSA_LIB_GPGKEYID:-A6E59C91} 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.0 +WINDOWS_REDIST_CHECKSUM="a29ada15d941a7b2065e9a4273fd6b97df44d089ed2b9f860ded442f7fe69767" copyFromDir() { echo "Copying OpenJDK source from ${BUILD_CONFIG[OPENJDK_LOCAL_SOURCE_ARCHIVE_ABSPATH]} to $(pwd)/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]} to be built" @@ -669,14 +671,8 @@ setupGpg() { echo "GNUPGHOME=$GNUPGHOME" } -# Download the required DevKit if necessary and not available in /usr/local/devkit -downloadDevkit() { - if [[ -n "${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" ]]; then - rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" - mkdir -p "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" - - BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="" - +# Download the required Linux DevKit if necessary and not available in /usr/local/devkit +downloadLinuxDevkit() { local devkit_target="${BUILD_CONFIG[OS_ARCHITECTURE]}-linux-gnu" local USR_LOCAL_DEVKIT="/usr/local/devkit/${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" @@ -733,6 +729,77 @@ downloadDevkit() { BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" fi +} + +# Download the required Windows DevKit if necessary and not available in /usr/local/devkit +# For the moment this is just support for Windows Redist DLLs +downloadWindowsDevkit() { + local USR_LOCAL_DEVKIT="/usr/local/devkit/${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" + if [[ -d "${USR_LOCAL_DEVKIT}" ]]; then + local usrLocalDevkitInfo="${USR_LOCAL_DEVKIT}/devkit.info" + if ! grep "ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" "${usrLocalDevkitInfo}"; then + echo "WARNING: Devkit ${usrLocalDevkitInfo} does not match required release:" + echo " Required: ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" + echo " ${USR_LOCAL_DEVKIT}: $(grep ADOPTIUM_DEVKIT_RELEASE= "${usrLocalDevkitInfo}")" + echo "Attempting to download the required DevKit instead" + else + # Found a matching DevKit + echo "Using matching DevKit from location ${USR_LOCAL_DEVKIT}" + BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="${USR_LOCAL_DEVKIT}" + fi + fi + + # Download from adoptium/devkit-runtimes if we have not found a matching one locally + if [[ -z "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}" ]]; then + local devkit_zip="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit/devkit.zip" + + # Determine DevKit zip to download for this release + local devkitUrl="https://github.com/adoptium/devkit-binaries/releases/download/${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" + local devkit="${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}.zip" + + # Download zip + echo "Downloading DevKit : ${devkitUrl}/${devkit}" + curl -L --fail --silent --show-error -o "${devkit_zip}" "${devkitUrl}/${devkit}" + + # Verify checksum + local expectedChecksum="${WINDOWS_REDIST_CHECKSUM}" + local actualChecksum=$(sha256File "${devkit_zip}") + if [ "${actualChecksum}" != "${expectedChecksum}" ]; then + echo "Failed to verify checksum on ${devkit_zip}" + + echo "Expected ${expectedChecksum} got ${actualChecksum}" + exit 1 + fi + + unzip "${devkit_zip}" -d "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" + rm "${devkit_zip}" + + # Validate devkit.info matches value passed in + local devkitInfo="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit/devkit.info" + if ! grep "ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" "${devkitInfo}"; then + echo "ERROR: Devkit does not match required release:" + echo " Required: ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" + echo " Downloaded: $(grep ADOPTIUM_DEVKIT_RELEASE= "${devkitInfo}")" + exit 1 + fi + + BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" + fi +} + +# Download the required DevKit if necessary and not available in /usr/local/devkit +downloadDevkit() { + if [[ -n "${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" ]]; then + rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" + mkdir -p "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit" + + BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="" + + if [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "linux" ]; then + downloadLinuxDevkit + elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then + downloadWindowsDevkit + fi fi } From e26159d7ff7be6b112520c85dee6e3938e3a1a5c Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 8 Oct 2024 15:29:22 +0100 Subject: [PATCH 2/4] Add support for Windows Redist DLL as Adoptium DevKit Signed-off-by: Andrew Leonard --- sbin/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/build.sh b/sbin/build.sh index b92dbe086..104665023 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -83,11 +83,11 @@ configureDevKitConfigureParameter() { # ARCHITECTURE is set to the "target" architecture by caller, or defaults to build architecture if not set local dll_arch if [[ "${ARCHITECTURE}" == "x86-32" ]]; then - dll_arch = "x86" + dll_arch="x86" elif [[ "${ARCHITECTURE}" == "aarch64" ]]; then - dll_arch = "arm64" + dll_arch="arm64" else - dll_arch = "x64" + dll_arch="x64" fi # Add Windows Redist DLL paths From f3d00b8d8e236b19d252d0e5bb0f619a542b3ee7 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Tue, 8 Oct 2024 15:52:16 +0100 Subject: [PATCH 3/4] Add support for Windows Redist DLL as Adoptium DevKit Signed-off-by: Andrew Leonard --- sbin/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbin/build.sh b/sbin/build.sh index 104665023..a51c4947c 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -91,10 +91,10 @@ configureDevKitConfigureParameter() { fi # Add Windows Redist DLL paths - addConfigureArg "--with-ucrt-dll-dir=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/ucrt/DLLs/${dll_arch}" - addConfigureArg "--with-msvcr-dll=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/vcruntime140.dll" - addConfigureArg "--with-vcruntime-1-dll=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/vcruntime140_1.dll" - addConfigureArg "--with-msvcp-dll=" "{BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/msvcp140.dll" + addConfigureArg "--with-ucrt-dll-dir=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/ucrt/DLLs/${dll_arch}" + addConfigureArg "--with-msvcr-dll=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/vcruntime140.dll" + addConfigureArg "--with-vcruntime-1-dll=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/vcruntime140_1.dll" + addConfigureArg "--with-msvcp-dll=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}/${dll_arch}/msvcp140.dll" else addConfigureArg "--with-devkit=" "${BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]}" fi From f041fdf8d0489c073c584f2d5d80d6ef0d2a6b44 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Wed, 9 Oct 2024 10:32:22 +0100 Subject: [PATCH 4/4] Add support for Windows Redist DLL as Adoptium DevKit Signed-off-by: Andrew Leonard --- sbin/prepareWorkspace.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index dc33a8bbf..81c9e4263 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -731,21 +731,21 @@ downloadLinuxDevkit() { fi } -# Download the required Windows DevKit if necessary and not available in /usr/local/devkit +# Download the required Windows DevKit if necessary and not available in c:/openjdk/devkit # For the moment this is just support for Windows Redist DLLs downloadWindowsDevkit() { - local USR_LOCAL_DEVKIT="/usr/local/devkit/${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" - if [[ -d "${USR_LOCAL_DEVKIT}" ]]; then - local usrLocalDevkitInfo="${USR_LOCAL_DEVKIT}/devkit.info" - if ! grep "ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" "${usrLocalDevkitInfo}"; then - echo "WARNING: Devkit ${usrLocalDevkitInfo} does not match required release:" + local WIN_LOCAL_DEVKIT="/cygdrive/C/openjdk/devkit/${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" + if [[ -d "${WIN_LOCAL_DEVKIT}" ]]; then + local winLocalDevkitInfo="${WIN_LOCAL_DEVKIT}/devkit.info" + if ! grep "ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" "${winLocalDevkitInfo}"; then + echo "WARNING: Devkit ${winLocalDevkitInfo} does not match required release:" echo " Required: ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" - echo " ${USR_LOCAL_DEVKIT}: $(grep ADOPTIUM_DEVKIT_RELEASE= "${usrLocalDevkitInfo}")" + echo " ${WIN_LOCAL_DEVKIT}: $(grep ADOPTIUM_DEVKIT_RELEASE= "${winLocalDevkitInfo}")" echo "Attempting to download the required DevKit instead" else # Found a matching DevKit - echo "Using matching DevKit from location ${USR_LOCAL_DEVKIT}" - BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="${USR_LOCAL_DEVKIT}" + echo "Using matching DevKit from location ${WIN_LOCAL_DEVKIT}" + BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="${WIN_LOCAL_DEVKIT}" fi fi