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
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 impliment a comprehensive seperation of build
architecture and target architecture in our build scripts.

Signed-off-by: Adam Farley <[email protected]>
  • Loading branch information
adamfarley committed Jan 26, 2024
1 parent c9415f1 commit 09e62f7
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 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_mac_.* ]; then
addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS architecture" "x86_64"
else
addSBOMMetadataProperty "${javaHome}" "${classpath}" "${sbomJson}" "OS architecture" "${BUILD_CONFIG[OS_ARCHITECTURE]^}"
endif

# Set default SBOM formulation
addSBOMFormulation "${javaHome}" "${classpath}" "${sbomJson}" "CycloneDX"
Expand Down Expand Up @@ -1361,8 +1370,17 @@ cleanAndMoveArchiveFiles() {
staticLibsDir="lib/static/windows-${osArch}"
;;
darwin)
# on MacOSX the layout is: Contents/Home/lib/static/darwin-amd64/
staticLibsDir="Contents/Home/lib/static/darwin-${osArch}"
# On MacOSX the layout is: Contents/Home/lib/static/darwin-[target 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.
# staticLibsDir="Contents/Home/lib/static/darwin-${osArch}"
if [ "${BUILD_CONFIG[TARGET_FILE_NAME]}" =~ .*_x64_mac_.* ]; then
staticLibsDir="Contents/Home/lib/static/darwin-amd64"
else
staticLibsDir="Contents/Home/lib/static/darwin-${osArch}"
fi
;;
linux)
# on Linux the layout is: lib/static/linux-amd64/glibc
Expand Down

0 comments on commit 09e62f7

Please sign in to comment.