Skip to content

Commit cb42071

Browse files
try debugging ccache
1 parent 8bbb1ae commit cb42071

4 files changed

Lines changed: 42 additions & 5 deletions

File tree

dist/index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58327,6 +58327,7 @@ exports.DeepEqual = DeepEqual;
5832758327
exports.SetupCCache = SetupCCache;
5832858328
const core = __nccwpck_require__(2186);
5832958329
const exec_1 = __nccwpck_require__(1514);
58330+
const fs = __nccwpck_require__(7147);
5833058331
function log(message, type = 'info') {
5833158332
if (type == 'info' && !core.isDebug()) {
5833258333
return;
@@ -58404,6 +58405,14 @@ async function SetupCCache() {
5840458405
}
5840558406
if (isFound) {
5840658407
await (0, exec_1.exec)('ccache', ['-s']);
58408+
const runnerTemp = process.env['RUNNER_TEMP'];
58409+
const ccacheBin = `${runnerTemp}/ccache_bin`;
58410+
if (!fs.existsSync(ccacheBin)) {
58411+
fs.mkdirSync(ccacheBin, { recursive: true });
58412+
}
58413+
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++`);
5840758416
core.info('ccache is enabled for Xcode builds.');
5840858417
}
5840958418
else {
@@ -59341,16 +59350,26 @@ async function execXcodeBuild(xcodeBuildArgs) {
5934159350
}
5934259351
},
5934359352
env: {
59353+
...process.env,
5934459354
CC: 'ccache clang',
59345-
CXX: 'ccache clang++'
59355+
CXX: 'ccache clang++',
59356+
PATH: `${process.env.CCACHE_BIN}:${process.env.PATH}`,
59357+
CCACHE_LOGFILE: path.join(process.cwd(), 'ccache.log')
5934659358
},
5934759359
ignoreReturnCode: true
5934859360
});
5934959361
await parseBundleLog(output);
5935059362
if (exitCode !== 0) {
5935159363
throw new Error(`xcodebuild exited with code: ${exitCode}`);
5935259364
}
59353-
await (0, exec_1.exec)('ccache', ['-s']);
59365+
core.startGroup('CCache');
59366+
try {
59367+
await (0, exec_1.exec)('ccache', ['-s']);
59368+
await (0, exec_1.exec)('cat', [path.join(process.cwd(), 'ccache.log')]);
59369+
}
59370+
finally {
59371+
core.endGroup();
59372+
}
5935459373
}
5935559374
async function execWithXcBeautify(xcodeBuildArgs) {
5935659375
try {

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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import core = require('@actions/core');
33
import { exec } from '@actions/exec';
4+
import fs = require('fs');
45

56
export function log(message: string, type: 'info' | 'warning' | 'error' = 'info') {
67
if (type == 'info' && !core.isDebug()) { return; }
@@ -69,6 +70,14 @@ export async function SetupCCache() {
6970
}
7071
if (isFound) {
7172
await exec('ccache', ['-s']);
73+
const runnerTemp = process.env['RUNNER_TEMP'];
74+
const ccacheBin = `${runnerTemp}/ccache_bin`;
75+
if (!fs.existsSync(ccacheBin)) {
76+
fs.mkdirSync(ccacheBin, { recursive: true });
77+
}
78+
process.env['CCACHE_BIN'] = ccacheBin;
79+
await exec(`ln -sf $(which ccache) ${ccacheBin}/clang`);
80+
await exec(`ln -sf $(which ccache) ${ccacheBin}/clang++`);
7281
core.info('ccache is enabled for Xcode builds.');
7382
} else {
7483
throw new Error('ccache is not available. Please install ccache to enable caching for Xcode builds.');

src/xcode.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,16 +931,25 @@ async function execXcodeBuild(xcodeBuildArgs: string[]) {
931931
}
932932
},
933933
env: {
934+
...process.env,
934935
CC: 'ccache clang',
935-
CXX: 'ccache clang++'
936+
CXX: 'ccache clang++',
937+
PATH: `${process.env.CCACHE_BIN}:${process.env.PATH}`,
938+
CCACHE_LOGFILE: path.join(process.cwd(), 'ccache.log')
936939
},
937940
ignoreReturnCode: true
938941
});
939942
await parseBundleLog(output);
940943
if (exitCode !== 0) {
941944
throw new Error(`xcodebuild exited with code: ${exitCode}`);
942945
}
943-
await exec('ccache', ['-s']);
946+
core.startGroup('CCache');
947+
try {
948+
await exec('ccache', ['-s']);
949+
await exec('cat', [path.join(process.cwd(), 'ccache.log')]);
950+
} finally {
951+
core.endGroup();
952+
}
944953
}
945954

946955
async function execWithXcBeautify(xcodeBuildArgs: string[]) {

0 commit comments

Comments
 (0)