diff --git a/README.md b/README.md index 6c7ca03..44fb937 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a | `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | | `override` | Setup the last installed toolchain as the default via `rustup override` | true | +| `rust-src-dir` | Path from root directory to directory with the Rust source directory (if its not in the root of the repository) | | [`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache diff --git a/action.yml b/action.yml index 328965d..35e0d30 100644 --- a/action.yml +++ b/action.yml @@ -69,6 +69,9 @@ inputs: description: "Setup the last installed toolchain as the default via `rustup override`" required: false default: "true" + rust-src-dir: + description: "Specify path from root directory to the Rust source directory. By default root directory will be used." + required: false outputs: rustc-version: @@ -163,9 +166,13 @@ runs: targets: ${{inputs.target}} components: ${{inputs.components}} override: ${{inputs.override}} + rust_src_dir: ${{inputs.rust-src-dir}} shell: bash run: | - if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]] + if [[ -d "$rust_src_dir" ]]; then + cd "$rust_src_dir" + fi + if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml") ]] then # Install the toolchain as specified in the file # rustup show is the old way that implicitly installed a toolchain @@ -222,7 +229,7 @@ runs: if: inputs.cache == 'true' uses: Swatinem/rust-cache@v2 with: - workspaces: ${{inputs.cache-workspaces}} + workspaces: ${{ inputs.cache-workspaces || inputs.rust-src-dir }} cache-directories: ${{inputs.cache-directories}} cache-on-failure: ${{inputs.cache-on-failure}} cache-bin: ${{inputs.cache-bin}}