Skip to content

Commit

Permalink
Refactor windows to make use of file
Browse files Browse the repository at this point in the history
  • Loading branch information
diemogebhardt committed Nov 26, 2024
1 parent 9197ed3 commit a5c798b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-verify-binary-architecture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ci-verify-binary-architecture

on:
workflow_dispatch:
# push:
push:

env:
CARGO_TERM_COLOR: always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release-nightly-verify-binary-architecture

on:
workflow_dispatch:
# push:
push:

env:
CARGO_TERM_COLOR: always
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-verify-binary-architecture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release-verify-binary-architecture

on:
workflow_dispatch:
# push:
push:

env:
CARGO_TERM_COLOR: always
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-bash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: run-bash

on:
workflow_dispatch:
push:
# push:

jobs:
run-bash:
Expand Down
18 changes: 7 additions & 11 deletions bin/verify-binary-architecture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,13 @@ case "${TARGET_TRIPLE}" in
;;
*"windows"*)
# Parse binary architecture
pe_header_output=$(powershell -Command "
\$bytes = [System.IO.File]::ReadAllBytes('${BINARY_PATH}');
\$header_offset = [System.BitConverter]::ToInt32(\$bytes, 0x3c);
\$machine_type = [System.BitConverter]::ToUInt16(\$bytes, \$header_offset + 4);
\$machine_type
" 2>&1) || echo "PE header extraction failed"
# Map binary architecture
case "${pe_header_output}" in
*"34404"*) BINARY_ARCHITECTURE="X64" ;; # 0x8664
*"43620"*) BINARY_ARCHITECTURE="Arm64" ;; # 0xAA64
*) echo "Unknown PE machine type: '${pe_header_output}'"; exit 1 ;;
file_output=$(file -b "${BINARY_PATH}")
BINARY_ARCHITECTURE=$(echo "${file_output}" | grep -o "x86-64\|Aarch64" | head -n1 || echo "")
# Map expected binary architecture
case "${TARGET_ARCHITECTURE}" in
"x86_64") EXPECTED_BINARY_ARCHITECTURE="x86-64" ;;
"aarch64") EXPECTED_BINARY_ARCHITECTURE="Aarch64" ;;
*) echo "Unknown Linux architecture: '${TARGET_ARCHITECTURE}'"; exit 1 ;;
esac
# Map expected binary architecture
case "${TARGET_ARCHITECTURE}" in
Expand Down

0 comments on commit a5c798b

Please sign in to comment.