Skip to content

Commit

Permalink
Add support for Windows Redist DLL as Adoptium DevKit (#3981)
Browse files Browse the repository at this point in the history
* Add support for Windows Redist DLL as Adoptium DevKit

Signed-off-by: Andrew Leonard <[email protected]>

* Add support for Windows Redist DLL as Adoptium DevKit

Signed-off-by: Andrew Leonard <[email protected]>

* Add support for Windows Redist DLL as Adoptium DevKit

Signed-off-by: Andrew Leonard <[email protected]>

* Add support for Windows Redist DLL as Adoptium DevKit

Signed-off-by: Andrew Leonard <[email protected]>

---------

Signed-off-by: Andrew Leonard <[email protected]>
  • Loading branch information
andrew-m-leonard authored Oct 9, 2024
1 parent 16cf218 commit fb30fbb
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 9 deletions.
23 changes: 22 additions & 1 deletion sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
83 changes: 75 additions & 8 deletions sbin/prepareWorkspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]}"
Expand Down Expand Up @@ -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 c:/openjdk/devkit
# For the moment this is just support for Windows Redist DLLs
downloadWindowsDevkit() {
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 " ${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 ${WIN_LOCAL_DEVKIT}"
BUILD_CONFIG[ADOPTIUM_DEVKIT_LOCATION]="${WIN_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
}

Expand Down

0 comments on commit fb30fbb

Please sign in to comment.