Skip to content

Commit

Permalink
Configures ccache and merges all builds into one PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommie committed Dec 23, 2023
1 parent 853e712 commit 9e2750e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 18 deletions.
90 changes: 73 additions & 17 deletions .github/workflows/v8build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,87 @@ jobs:
platform: macos-latest
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore CCache
uses: actions/cache@v3
with:
submodules: true
fetch-depth: 1
- name: Update depot_tools fetch config
run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
shell: bash
path: .ccache
key: ${{ runner.os }}:${{ matrix.os }}:${{ matrix.arch }}:libv8:ccache
restore-keys: |
${{ runner.os }}:${{ matrix.os }}:${{ matrix.arch }}:libv8:ccache
- name: Install CCache
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -yq ccache
sudo update-ccache-symlinks
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
- name: Install CCache
if: matrix.platform == 'macos-latest'
run: |
brew install ccache
echo "$(brew --prefix ccache)/libexec" >> "$GITHUB_PATH"
- name: Configure CCache
run: |
echo "CCACHE_CPP2=yes" >> "$GITHUB_ENV"
echo "CCACHE_SLOPPINESS=time_macros" >> "$GITHUB_ENV"
ccacheDir="${GITHUB_WORKSPACE}/.ccache"
mkdir -p "$ccacheDir"
echo "CCACHE_DIR=$ccacheDir" >> "$GITHUB_ENV"
- name: Install g++-aarch64-linux-gnu
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: sudo apt update && sudo apt install g++-aarch64-linux-gnu -y

- name: Install setuptools
if: matrix.platform == 'macos-latest'
run: python3 -m ensurepip --default-pip && python3 -m pip install --upgrade setuptools

- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 1

- name: Update depot_tools fetch config
run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

- name: Build V8 (${{ matrix.os }})
if: matrix.os == 'linux'
run: cd deps && ./build.py --no-clang --arch ${{ matrix.arch }} --os ${{ matrix.v8os }}
- name: Build V8 (${{ matrix.os }})
if: matrix.os == 'darwin' || matrix.os == 'android'
run: cd deps && ./build.py --arch ${{ matrix.arch }} --os ${{ matrix.v8os }}
run: cd deps && ./build.py --ccache --arch ${{ matrix.arch }} --os ${{ matrix.v8os }}

- name: Show CCache Status
run: ccache -s

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
# The name matches the directory under deps/.
name: ${{ matrix.os }}_${{ matrix.arch }}
if-no-files-found: error
path: deps/${{ matrix.os }}_${{ matrix.arch }}/libv8.a
retention-days: 2

commit:
name: Commit Built Artifacts
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: deps

- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update V8 static library for ${{ matrix.os }} ${{ matrix.arch }}
branch-suffix: random
delete-branch: true
title: V8 static library for ${{ matrix.os }} ${{ matrix.arch }}
body: Auto-generated pull request to build V8 for ${{ matrix.os }} ${{ matrix.arch }}
commit-message: Update compiled V8 libraries
branch-suffix: random
delete-branch: true
title: V8 libraries for all targets
body: Auto-generated pull request of built V8 libraries
7 changes: 6 additions & 1 deletion deps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

parser = argparse.ArgumentParser()
parser.add_argument('--debug', dest='debug', action='store_true')
parser.add_argument('--ccache', action='store_true')
parser.add_argument('--clang', dest='clang', action='store_true')
parser.add_argument('--no-clang', dest='clang', action='store_false')
parser.add_argument('--arch',
dest='arch',
Expand All @@ -24,13 +26,14 @@
dest='os',
choices=['android', 'ios', 'linux', 'mac', 'windows'],
default=platform.system().lower())
parser.set_defaults(debug=False, clang=True)
parser.set_defaults(debug=False, ccache=False, clang=None)
args = parser.parse_args()

deps_path = os.path.dirname(os.path.realpath(__file__))
v8_path = os.path.join(deps_path, "v8")
tools_path = os.path.join(deps_path, "depot_tools")
is_windows = platform.system().lower() == "windows"
is_clang = args.clang if args.clang is not None else args.os != "linux"

def get_custom_deps():
# These deps are unnecessary for building.
Expand Down Expand Up @@ -143,6 +146,8 @@ def main():

arch = v8_arch()
gnargs = gn_args % (is_debug, is_clang, args.os, arch, arch, symbol_level, strip_debug_info)
if args.ccache:
gnargs += 'cc_wrapper = "ccache"\n'
gen_args = gnargs.replace('\n', ' ')

subprocess.check_call(cmd([gn_path, "gen", build_path, "--args=" + gen_args]),
Expand Down

0 comments on commit 9e2750e

Please sign in to comment.