diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f282260..e7e8548 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,6 +128,10 @@ jobs: toolchain: stable override: true + - name: Add Windows GNU target + if: matrix.os == 'windows-latest' + run: rustup target add x86_64-pc-windows-gnu + - name: Install system dependencies (Linux) if: matrix.os == 'ubuntu-latest' run: | @@ -137,7 +141,12 @@ jobs: - name: Build Rust Core run: | cd attest-rs - cargo build --release + if [ "${{ matrix.os }}" = "windows-latest" ]; then + cargo build --release --target x86_64-pc-windows-gnu + else + cargo build --release + fi + shell: bash - name: Build release binary shell: bash @@ -149,15 +158,17 @@ jobs: # Link against the release build of the Rust core export CGO_ENABLED=1 - export RUST_RELEASE_PATH="$(pwd)/attest-rs/target/release" if [ "$GOOS" = "linux" ]; then + export RUST_RELEASE_PATH="$(pwd)/attest-rs/target/release" export CGO_LDFLAGS="-L${RUST_RELEASE_PATH} -lattest_rs -lssl -lcrypto -ltss2-esys -ltss2-mu -ltss2-tctildr" elif [ "$GOOS" = "darwin" ]; then + export RUST_RELEASE_PATH="$(pwd)/attest-rs/target/release" export CGO_LDFLAGS="-L${RUST_RELEASE_PATH} -lattest_rs -framework Security -framework CoreFoundation" else - # Windows linking via MSVC/CNG - export CGO_LDFLAGS="-L${RUST_RELEASE_PATH} -lattest_rs -lbcrypt -lncrypt" + # Windows linking via MinGW/GNU target + export RUST_RELEASE_PATH="$(pwd)/attest-rs/target/x86_64-pc-windows-gnu/release" + export CGO_LDFLAGS="-L${RUST_RELEASE_PATH} -lattest_rs -lbcrypt -lws2_32 -luserenv -lntdll -lole32" fi go build -o "$BINARY_NAME" ./cmd/attest diff --git a/pkg/bridge/config_windows.go b/pkg/bridge/config_windows.go index b09736f..74ae964 100644 --- a/pkg/bridge/config_windows.go +++ b/pkg/bridge/config_windows.go @@ -1,9 +1,9 @@ -// +build windows -// go:build windows +//go:build windows && cgo +// +build windows,cgo package bridge /* -#cgo LDFLAGS: -L${SRCDIR}/../../attest-rs/target/release -lattest_rs -lbcrypt -lws2_32 -luserenv -lntdll +#cgo LDFLAGS: -Wl,-rpath,${SRCDIR}/../../attest-rs/target/x86_64-pc-windows-gnu/release -L${SRCDIR}/../../attest-rs/target/x86_64-pc-windows-gnu/release -lattest_rs -lbcrypt -lws2_32 -luserenv -lntdll -lole32 */ import "C"