Skip to content

Commit

Permalink
Improve how vcvarsall is located (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth authored Jan 29, 2024
1 parent 908f6f5 commit fcab5fd
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
fail-fast: false
matrix:
rust: [ stable ]
os: [ windows-2019, windows-2022 ]
os: [ windows-2019, windows-latest ]
args:
- --all-targets --features fips,unstable
- --all-targets --features fips,bindgen,unstable
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,36 @@ jobs:
working-directory: ./aws-lc-rs
run: |
./scripts/run-rustls-integration.sh
sys-crate-tests:
if: github.repository == 'aws/aws-lc-rs'
name: sys crate tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-12, macos-13-xlarge, windows-latest ]
features: [ aws-lc-sys, aws-lc-fips-sys ]
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: dtolnay/rust-toolchain@stable
id: toolchain
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
- name: Install NASM on Windows
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@v1
- name: Setup Go >=v1.18
uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v4
- name: Run cargo test
working-directory: ./sys-testing
run: cargo test --features ${{ matrix.features }} --no-default-features
- name: Run cargo run
working-directory: ./sys-testing
run: cargo run --features ${{ matrix.features }} --no-default-features
23 changes: 0 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,6 @@ env:
RUST_NIGHTLY_TOOLCHAIN: nightly

jobs:
sys-crate-tests:
if: github.repository == 'aws/aws-lc-rs'
name: sys crate tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-12 ]
features: [ aws-lc-sys, aws-lc-fips-sys ]
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: dtolnay/rust-toolchain@stable
id: toolchain
- name: Set Rust toolchain override
run: rustup override set ${{ steps.toolchain.outputs.name }}
- name: Run cargo test
working-directory: ./sys-testing
run: cargo test --features ${{ matrix.features }} --no-default-features
- name: Run cargo run
working-directory: ./sys-testing
run: cargo run --features ${{ matrix.features }} --no-default-features

aws-lc-rs-test:
if: github.repository == 'aws/aws-lc-rs'
Expand Down
2 changes: 2 additions & 0 deletions aws-lc-fips-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ impl CmakeBuilder {
let script_path = self.manifest_dir.join("builder").join("printenv.bat");
let result = test_command(script_path.as_os_str(), &[]);
if !result.status {
eprintln!("{}", result.output);
return Err("Failed to run vccarsall.bat.".to_owned());
}
eprintln!("{}", result.output);
let lines = result.output.lines();
for line in lines {
if let Some((var, val)) = line.split_once('=') {
Expand Down
43 changes: 40 additions & 3 deletions aws-lc-fips-sys/builder/printenv.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
@echo off
setlocal EnableDelayedExpansion

set "TOP_DIR=%ProgramFiles(x86)%\Microsoft Visual Studio"
for /f "usebackq tokens=* delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do (
set "VS_PATH=%%i"
set "TOP_DIR=%%i"
echo VS Installation: "!TOP_DIR!"
if exist "!TOP_DIR!\VC\Auxiliary\Build\vcvarsall.bat" (
set "VS_PATH=!TOP_DIR!\VC\Auxiliary\Build\"
echo FOUND in Installation: "!VS_PATH!"
goto FoundVS
)
goto SearchVS
)

echo Visual Studio installation not found using vswhere. Searching in default directories...

:SearchVS
for /R "%TOP_DIR%" %%a in (vcvarsall.bat) do (
if exist "%%~fa" (
set "VS_PATH=%%~dpa"
echo FOUND: "!VS_PATH!"
goto FoundVS
)
)
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64
echo vcvarsall.bat not found.
goto End

:FoundVS
call "!VS_PATH!vcvarsall.bat" x64
if !ERRORLEVEL! neq 0 (
echo Failed to set Visual Studio environment variables.
echo PATH: "!VS_PATH!vcvarsall.bat"
goto End
)
echo Visual Studio environment variables set for x64.

set
endlocal
exit /b 0

set
:End
endlocal
exit /b 1

0 comments on commit fcab5fd

Please sign in to comment.