Skip to content

Commit

Permalink
Temporarily patch architecture confusion when cross-compiling on mac (#…
Browse files Browse the repository at this point in the history
…3619)

Currently, when we build an x64 mac build on an arm64 machine, we put
arm64 all over the place by mistake.

This change is to partially compensate for that mistake until such
time as we can implement a comprehensive separation of build
architecture and target architecture in our build scripts.

Signed-off-by: Adam Farley <adfarley@redhat.com>
  • Loading branch information
adamfarley authored Jan 30, 2024
1 parent c9415f1 commit a9a2395
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,16 @@ generateSBoM() {
# Below add property to metadata
# Add OS full version (Kernel is covered in the first field)
addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS version" "${BUILD_CONFIG[OS_FULL_VERSION]^}"
addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS architecture" "${BUILD_CONFIG[OS_ARCHITECTURE]^}"
# TODO: Replace this "if" with its predecessor (commented out below) once
# OS_ARCHITECTURE has been replaced by the new target architecture variable.
# This is because OS_ARCHITECTURE is currently the build arch, not the target arch,
# and that confuses things when cross-compiling an x64 mac build on arm mac.
# addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS architecture" "${BUILD_CONFIG[OS_ARCHITECTURE]^}"
if [[ "${BUILD_CONFIG[TARGET_FILE_NAME]}" =~ .*_x64_.* ]]; then
addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS architecture" "x86_64"
else
addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS architecture" "${BUILD_CONFIG[OS_ARCHITECTURE]^}"
fi

# Set default SBOM formulation
addSBOMFormulation "${javaHome}" "${classpath}" "${sbomJson}" "CycloneDX"
Expand Down Expand Up @@ -1354,14 +1363,24 @@ cleanAndMoveArchiveFiles() {
if [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" = "x86_64" ]; then
osArch="amd64"
fi

# TODO: Remove the "if" below once OS_ARCHITECTURE has been replaced.
# This is because OS_ARCHITECTURE is currently the build arch, not the target arch,
# and that confuses things when cross-compiling an x64 mac build on arm mac.
if [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" = "arm64" ]; then
if [[ "${BUILD_CONFIG[TARGET_FILE_NAME]}" =~ .*_x64_.* ]]; then
osArch="amd64"
fi
fi

pushd ${staticLibsImagePath}
case "${BUILD_CONFIG[OS_KERNEL_NAME]}" in
*cygwin*)
# on Windows the expected layout is: lib/static/windows-amd64/
staticLibsDir="lib/static/windows-${osArch}"
;;
darwin)
# on MacOSX the layout is: Contents/Home/lib/static/darwin-amd64/
# On MacOSX the layout is: Contents/Home/lib/static/darwin-[target architecture]/
staticLibsDir="Contents/Home/lib/static/darwin-${osArch}"
;;
linux)
Expand Down

0 comments on commit a9a2395

Please sign in to comment.