Skip to content

Commit

Permalink
Support cross compiling with prebuilt NASM (#528)
Browse files Browse the repository at this point in the history
* Support cross compiling to x86_64-pc-windows-gnu

* Update aws-lc-sys/builder/prebuilt-nasm.sh

Co-authored-by: Sean McGrail <549813+skmcgrail@users.noreply.github.com>

---------

Co-authored-by: Sean McGrail <549813+skmcgrail@users.noreply.github.com>
  • Loading branch information
justsmth and skmcgrail authored Sep 27, 2024
1 parent 4d5cf82 commit 21da240
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,20 @@ jobs:
. "$HOME/.cargo/env"
cargo test -p aws-lc-rs
cargo test -p aws-lc-rs --no-default-features --features=fips
cross-x86_64-pc-windows-gnu:
if: github.repository_owner == 'aws'
name: cross (prebuilt nasm) - x86_64-pc-windows-gnu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: dtolnay/rust-toolchain@stable
id: toolchain
with:
toolchain: 'stable'
target: x86_64-pc-windows-gnu
- name: Install mingw
run: sudo apt-get update && sudo apt-get install --assume-yes mingw-w64
- name: Run cargo test
run: cargo build -p aws-lc-rs --features prebuilt-nasm --target x86_64-pc-windows-gnu
8 changes: 7 additions & 1 deletion aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,16 @@ impl CmakeBuilder {
emit_warning("!!! Using pre-built NASM binaries !!!");
emit_warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

let script_name = if cfg!(target_os = "windows") {
"prebuilt-nasm.bat"
} else {
"prebuilt-nasm.sh"
};

let script_path = self
.manifest_dir
.join("builder")
.join("prebuilt-nasm.bat")
.join(script_name)
.display()
.to_string();
let script_path = script_path.replace('\\', "/");
Expand Down
27 changes: 27 additions & 0 deletions aws-lc-sys/builder/prebuilt-nasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

while [[ $# -gt 0 ]]; do
case "$1" in
-o)
shift
path="$1"
filename="$(basename "$path")"
filename="$(echo "$filename" | cut -f 1 -d '.')"
cp "$SCRIPT_DIR/prebuilt-nasm/${filename}".obj "$path"
exit 0
;;
*)
shift
;;
esac
done

# If we reach here, it means we didn't find the -o option
echo "PATH: $path" >&2
echo "FILENAME: $filename" >&2
echo "SCRIPT_DIR: $SCRIPT_DIR" >&2
exit 1

0 comments on commit 21da240

Please sign in to comment.