Skip to content

Commit b072770

Browse files
try different way to link
1 parent cb42071 commit b072770

3 files changed

Lines changed: 55 additions & 11 deletions

File tree

dist/index.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58328,6 +58328,7 @@ exports.SetupCCache = SetupCCache;
5832858328
const core = __nccwpck_require__(2186);
5832958329
const exec_1 = __nccwpck_require__(1514);
5833058330
const fs = __nccwpck_require__(7147);
58331+
const path = __nccwpck_require__(1017);
5833158332
function log(message, type = 'info') {
5833258333
if (type == 'info' && !core.isDebug()) {
5833358334
return;
@@ -58388,16 +58389,30 @@ function DeepEqual(a, b) {
5838858389
}
5838958390
async function SetupCCache() {
5839058391
let isFound = false;
58392+
let ccachePath = '';
5839158393
try {
58394+
let output = '';
5839258395
await (0, exec_1.exec)('which', ['ccache'], {
58393-
silent: true
58396+
silent: true,
58397+
listeners: {
58398+
stdout: (data) => { output += data.toString(); }
58399+
}
5839458400
});
58395-
isFound = true;
58401+
ccachePath = output.trim();
58402+
isFound = !!ccachePath;
5839658403
}
5839758404
catch (_a) {
5839858405
try {
5839958406
await (0, exec_1.exec)('brew', ['install', 'ccache']);
58400-
isFound = true;
58407+
let output = '';
58408+
await (0, exec_1.exec)('which', ['ccache'], {
58409+
silent: true,
58410+
listeners: {
58411+
stdout: (data) => { output += data.toString(); }
58412+
}
58413+
});
58414+
ccachePath = output.trim();
58415+
isFound = !!ccachePath;
5840158416
}
5840258417
catch (_b) {
5840358418
core.warning('ccache could not be installed. Proceeding without ccache.');
@@ -58411,8 +58426,18 @@ async function SetupCCache() {
5841158426
fs.mkdirSync(ccacheBin, { recursive: true });
5841258427
}
5841358428
process.env['CCACHE_BIN'] = ccacheBin;
58414-
await (0, exec_1.exec)(`ln -sf $(which ccache) ${ccacheBin}/clang`);
58415-
await (0, exec_1.exec)(`ln -sf $(which ccache) ${ccacheBin}/clang++`);
58429+
const clangPath = path.join(ccacheBin, 'clang');
58430+
const clang_ppPath = path.join(ccacheBin, 'clang++');
58431+
try {
58432+
fs.unlinkSync(clangPath);
58433+
}
58434+
catch (_c) { }
58435+
try {
58436+
fs.unlinkSync(clang_ppPath);
58437+
}
58438+
catch (_d) { }
58439+
fs.symlinkSync(ccachePath, clangPath);
58440+
fs.symlinkSync(ccachePath, clang_ppPath);
5841658441
core.info('ccache is enabled for Xcode builds.');
5841758442
}
5841858443
else {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utilities.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import core = require('@actions/core');
33
import { exec } from '@actions/exec';
44
import fs = require('fs');
5+
import path = require('path');
56

67
export function log(message: string, type: 'info' | 'warning' | 'error' = 'info') {
78
if (type == 'info' && !core.isDebug()) { return; }
@@ -55,15 +56,29 @@ export function DeepEqual(a: any, b: any): boolean {
5556

5657
export async function SetupCCache() {
5758
let isFound = false;
59+
let ccachePath = '';
5860
try {
61+
let output = '';
5962
await exec('which', ['ccache'], {
60-
silent: true
63+
silent: true,
64+
listeners: {
65+
stdout: (data: Buffer) => { output += data.toString(); }
66+
}
6167
});
62-
isFound = true;
68+
ccachePath = output.trim();
69+
isFound = !!ccachePath;
6370
} catch {
6471
try {
6572
await exec('brew', ['install', 'ccache']);
66-
isFound = true;
73+
let output = '';
74+
await exec('which', ['ccache'], {
75+
silent: true,
76+
listeners: {
77+
stdout: (data: Buffer) => { output += data.toString(); }
78+
}
79+
});
80+
ccachePath = output.trim();
81+
isFound = !!ccachePath;
6782
} catch {
6883
core.warning('ccache could not be installed. Proceeding without ccache.');
6984
}
@@ -76,8 +91,12 @@ export async function SetupCCache() {
7691
fs.mkdirSync(ccacheBin, { recursive: true });
7792
}
7893
process.env['CCACHE_BIN'] = ccacheBin;
79-
await exec(`ln -sf $(which ccache) ${ccacheBin}/clang`);
80-
await exec(`ln -sf $(which ccache) ${ccacheBin}/clang++`);
94+
const clangPath = path.join(ccacheBin, 'clang');
95+
const clang_ppPath = path.join(ccacheBin, 'clang++');
96+
try { fs.unlinkSync(clangPath); } catch { }
97+
try { fs.unlinkSync(clang_ppPath); } catch { }
98+
fs.symlinkSync(ccachePath, clangPath);
99+
fs.symlinkSync(ccachePath, clang_ppPath);
81100
core.info('ccache is enabled for Xcode builds.');
82101
} else {
83102
throw new Error('ccache is not available. Please install ccache to enable caching for Xcode builds.');

0 commit comments

Comments
 (0)