Skip to content

Commit

Permalink
ci: Use ccache
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Jan 19, 2025
1 parent 5406a37 commit dd58409
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ jobs:
run: sudo apt install -y binutils-aarch64-linux-gnu

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use ccache
uses: hendrikmuhs/[email protected]
with:
key: ccache-${{ matrix.os }}-${{ matrix.arch }}

- name: Build
run: |
node scripts/bootstrap.js --target-cpu=${{ matrix.arch }}
node scripts/bootstrap.js --target-cpu=${{ matrix.arch }} --cc-wrapper=ccache
node scripts/build.js out/Release
- name: Create distribution
Expand Down
6 changes: 5 additions & 1 deletion scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the license that can be found in the
// LICENSE file.

const {targetCpu, targetOs, execSync, spawnSync} = require('./common')
const {ccWrapper, targetCpu, targetOs, execSync, spawnSync} = require('./common')

// Get the arch of sysroot.
let sysrootArch = {
Expand Down Expand Up @@ -38,6 +38,10 @@ const releaseConfig = [
'is_official_build=true',
]

if (ccWrapper) {
commonConfig.push(`cc_wrapper="${ccWrapper}"`,
'clang_use_chrome_plugins=false')
}
if (targetOs == 'linux') {
// Use prebuilt clang binaries.
commonConfig.push('is_clang=true',
Expand Down
10 changes: 9 additions & 1 deletion scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ const version = String(execSync('git describe --always --tags')).trim()

// Get target_cpu from args.gn.
let targetCpu = process.arch
let ccWrapper = null
if (fs.existsSync('out/Release/args.gn')) {
const content = String(fs.readFileSync('out/Release/args.gn'))
const match = content.match(/target_cpu = "(.*)"/)
let match = content.match(/target_cpu = "(.*)"/)
if (match && match.length > 1)
targetCpu = match[1]
match = content.match(/cc_wrapper = "(.*)"/)
if (match && match.length > 1)
ccWrapper = match[1]
}

// Get target OS.
Expand All @@ -52,6 +56,9 @@ const argv = process.argv.slice(2).filter((arg) => {
if (arg == '-v' || arg == '--verbose') {
verbose = true
return false
} else if (arg.startsWith('--cc-wrapper=')) {
ccWrapper = arg.substr(arg.indexOf('=') + 1)
return false
} else if (arg.startsWith('--target-cpu=')) {
targetCpu = arg.substr(arg.indexOf('=') + 1)
return false
Expand Down Expand Up @@ -109,6 +116,7 @@ module.exports = {
verbose,
version,
argv,
ccWrapper,
targetCpu,
targetOs,
streamPromise,
Expand Down
5 changes: 3 additions & 2 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the license that can be found in the
// LICENSE file.

const {argv, version, targetCpu, targetOs, execSync} = require('./common')
const {argv, ccWrapper, version, targetCpu, targetOs, execSync} = require('./common')

const path = require('path')
const extract = require('./libs/extract-zip')
Expand Down Expand Up @@ -49,8 +49,9 @@ function runEachTest(project, projectPath) {
execSync(`python3 ${path.join(tmppath, 'gn/tools/clang/scripts/update.py')}`)
}

const args = ccWrapper ? `--args=cc_wrapper="${ccWrapper}"` : ''
const gn = path.join(tmppath, 'gn', 'gn')
execSync(`${gn} gen ${outdir}`, {cwd: projectPath})
execSync(`${gn} gen ${outdir} ${args}`, {cwd: projectPath})

console.log(`Building project "${project}"...`)
execSync(`ninja -C ${outdir}`)
Expand Down

0 comments on commit dd58409

Please sign in to comment.