diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fc7062a..c101c82 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,11 +29,18 @@ jobs: run: sudo apt install -y binutils-aarch64-linux-gnu - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Use ccache + uses: hendrikmuhs/ccache-action@v1.2 + 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 diff --git a/scripts/bootstrap.js b/scripts/bootstrap.js index e2ba638..c8b94da 100755 --- a/scripts/bootstrap.js +++ b/scripts/bootstrap.js @@ -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 = { @@ -19,7 +19,7 @@ if (process.platform == 'linux') { execSync(`python3 build/linux/sysroot_scripts/install-sysroot.py --arch ${sysrootArch}`) } -execSync('git submodule sync --recursive') +execSync('git submodule sync --recursive', {stdio: 'ignore'}) execSync('git submodule update --init --recursive') const commonConfig = [ @@ -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', diff --git a/scripts/common.js b/scripts/common.js index b754276..0581ed2 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -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. @@ -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 @@ -109,6 +116,7 @@ module.exports = { verbose, version, argv, + ccWrapper, targetCpu, targetOs, streamPromise, diff --git a/scripts/test.js b/scripts/test.js index 2093c80..f1ae779 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -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') @@ -47,8 +47,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}`)