Skip to content

Commit

Permalink
Add msvc response file integration test
Browse files Browse the repository at this point in the history
Builds against windows and performs a series of compilation checks to ensure that the mock project builds and response files are properly expanded
  • Loading branch information
temportalflux committed Mar 9, 2023
1 parent 0749f40 commit c165b3b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,61 @@ jobs:
${SCCACHE_PATH} --show-stats
${SCCACHE_PATH} --show-stats | grep -e "Cache hits\s*[1-9]"
test-mock-msvc:
runs-on: windows-2019
env:
TARGET: x86_64-pc-windows-msvc
SCCACHE_EXE: ${{ github.workspace }}\\target\\x86_64-pc-windows-msvc\\debug\\sccache.exe
SCCACHE_LOG: "trace"
SCCACHE_ERROR_LOG: "${{ github.workspace }}\\server_log.txt"

steps:
- uses: ilammy/[email protected]

- name: Clone repository
uses: actions/checkout@v3

- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: "stable"
target: $TARGET

- name: Build
run: cargo build --bin sccache --target $env:TARGET --features=openssl/vendored

- name: Compile MSVC (no cache)
shell: bash
working-directory: ./tests/msvc
run: cl "@args.rsp"

- name: Start Server
shell: bash
run: $SCCACHE_EXE --start-server

- name: Compile - Cache Miss
shell: bash
working-directory: ./tests/msvc
run: |
$SCCACHE_EXE "$(where cl.exe)" -c "@args.rsp"
$SCCACHE_EXE --show-stats
$SCCACHE_EXE --show-stats | grep -e "Cache misses\s*[1-9]"
- name: Compile - Cache Hit
shell: bash
working-directory: ./tests/msvc
run: |
$SCCACHE_EXE "$(where cl.exe)" -c "@args.rsp"
$SCCACHE_EXE --show-stats
$SCCACHE_EXE --show-stats | grep -e "Cache hits\s*[1-9]"
- name: Stop Server
if: success() || failure()
shell: bash
run: $SCCACHE_EXE --stop-server

- name: Show Server Log
if: success() || failure()
shell: bash
run: cat "$SCCACHE_ERROR_LOG"
2 changes: 2 additions & 0 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,8 @@ impl<'a> Iterator for ExpandIncludeFile<'a> {
}
};

trace!("Expanded response file {:?} to {:?}", file_path, content);

// Parse the response file contents, taking into account quote-wrapped strings and new-line separators.
// Special implementation to account for MSVC response file format.
let resp_file_args = SplitMsvcResponseFileArgs::from(&content).collect::<Vec<_>>();
Expand Down
1 change: 1 addition & 0 deletions tests/msvc/args.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo.cpp -Fofoo.o
6 changes: 6 additions & 0 deletions tests/msvc/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>

int main() {
std::cout << "Hello World!\n";
return 0;
}

0 comments on commit c165b3b

Please sign in to comment.