Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new flag create-symlink #172

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,23 @@ jobs:
uses: ./
with:
append-timestamp: ${{ matrix.append-timestamp }}

test_option_create_symlink:
# Test that the 'create-symlink' option is available.
runs-on: ubuntu-latest
strategy:
matrix:
create-symlink: [true, false]
steps:
- uses: actions/checkout@v2
- name: Run ccache-action
uses: ./
with:
create-symlink: ${{ matrix.create-symlink }}
- name: Test symlink
run: |
if [ ${{ matrix.create-symlink }} = true ]; then
ls -l $(which gcc) | grep $(which ccache)
else
ls -l $(which gcc) | grep -v $(which ccache)
fi
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ or by manipulating `PATH` (ccache only):

(works for both `ubuntu` and `macos`)

or by setting create-symlink to `true`:

```yaml
- name: ccache
uses: hendrikmuhs/[email protected]
with:
create-symlink: true
```


Ccache/sccache gets installed by this action if it is not installed yet.

### Example workflow
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: "Append a timestamp to the cache key (default: true)"
default: true
required: false
create-symlink:
description: "If set to 'true', create symlinks for ccache in /usr/local/bin to override default toolchains"
default: false
required: false
runs:
using: "node16"
main: "dist/restore/index.js"
Expand Down
9 changes: 9 additions & 0 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59626,6 +59626,15 @@ async function configure(ccacheVariant, platform) {
if (platform === "darwin") {
await execBash(`ccache --set-config=compiler_check=content`);
}
if (core.getBooleanInput("create-symlink")) {
const ccache = await io.which("ccache");
await execBash(`ln -s ${ccache} /usr/local/bin/gcc`);
await execBash(`ln -s ${ccache} /usr/local/bin/g++`);
await execBash(`ln -s ${ccache} /usr/local/bin/cc`);
await execBash(`ln -s ${ccache} /usr/local/bin/c++`);
await execBash(`ln -s ${ccache} /usr/local/bin/clang`);
await execBash(`ln -s ${ccache} /usr/local/bin/clang++`);
}
core.info("Cccache config:");
await execBash("ccache -p");
}
Expand Down
9 changes: 9 additions & 0 deletions src/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ async function configure(ccacheVariant : string, platform : string) : Promise<vo
if (platform === "darwin") {
await execBash(`ccache --set-config=compiler_check=content`);
}
if (core.getBooleanInput("create-symlink")) {
const ccache = await io.which("ccache");
await execBash(`ln -s ${ccache} /usr/local/bin/gcc`);
await execBash(`ln -s ${ccache} /usr/local/bin/g++`);
await execBash(`ln -s ${ccache} /usr/local/bin/cc`);
await execBash(`ln -s ${ccache} /usr/local/bin/c++`);
await execBash(`ln -s ${ccache} /usr/local/bin/clang`);
await execBash(`ln -s ${ccache} /usr/local/bin/clang++`);
}
core.info("Cccache config:");
await execBash("ccache -p");
} else {
Expand Down
Loading