Skip to content

Commit

Permalink
Chrobalt build
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidokert committed Jul 13, 2024
1 parent 4df7f33 commit 50b4d3a
Show file tree
Hide file tree
Showing 11 changed files with 595 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/actions/pre_commit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pre-commit
description: Runs pre-commit
inputs:
base_ref:
description: "Ref to run from"
required: true
runs:
using: "composite"
steps:
- run: python -m pip install pre-commit
shell: bash
- run: python -m pip freeze --local
shell: bash
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pre-commit run --show-diff-on-failure --color=always --all-files
shell: bash
140 changes: 140 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Android build

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- '*_workflows'
push:
branches:
- '*_workflows'
workflow_dispatch:

jobs:
docker-build-image:
runs-on: ubuntu-latest

env:
docker_tag: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}

steps:
- uses: actions/checkout@v4
#- name: Dump context
# uses: crazy-max/ghaction-dump-context@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull just in case
run: docker pull ghcr.io/${{ github.repository }}/linux || true
- name: Build containers using docker-compose
run: docker-compose build
- name: Re-tag
run: docker tag ghcr.io/${{ github.repository }}/linux:latest ghcr.io/${{ github.repository }}/linux:${{ env.docker_tag }}
- name: Work
run: docker push ghcr.io/${{ github.repository }}/linux:${{ env.docker_tag }}
outputs:
docker_tag: ghcr.io/${{ github.repository }}/linux:${{ env.docker_tag }}

build:
needs: [docker-build-image]
runs-on: [self-hosted, chrobalt-linux-runner]
container: ${{ needs.docker-build-image.outputs.docker_tag }}
env:
DEPOT_TOOLS_UPDATE: 0
DEPOT_TOOLS_REPORT_BUILD: 0
DEPOT_TOOLS_COLLECT_METRICS: 0
DEPOT_TOOLS_METRICS: 0
SCCACHE: 1
SCCACHE_GCS_BUCKET: cobalt-actions-sccache-linux
SCCACHE_GCS_SERVICE_ACCOUNT: [email protected]
SCCACHE_GCS_RW_MODE: READ_WRITE
SCCACHE_IDLE_TIMEOUT: 0 # prevent sccache server from shutting down after long idle.
BUILD_DIR: out/Default

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: src
# - name: Dump context
# uses: crazy-max/ghaction-dump-context@v2
- name: Get depot tools
# run: git clone -b dev https://github.com/kaidokert/depot_tools.git
run: git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- name: Add directory to PATH
run: echo "$GITHUB_WORKSPACE/depot_tools" >> $GITHUB_PATH
- name: Generate gclient file
run: gclient config --name=src https://github.com/${{ github.repository }}
- name: Set target OS
# echo "target_os_only=True" >> .gclient
run: |
echo "target_os=['android']" >> .gclient
gclient validate
- name: Gclient sync
run: gclient sync -v --shallow --no-history -r ${{ github.sha }}
- name: DF
run: df -h
- name: Du
run: du -ht 500M
- name: sccache check
run: sccache -s
- name: gn gen
run: |
cd src
mkdir -p ${BUILD_DIR}
cp chrobalt/android/args.gn ${BUILD_DIR}
gn gen ${BUILD_DIR}
- name: gn dump args
run: |
cd src
gn args --list --short ${BUILD_DIR}
- name: ninja base_unittests
run: |
cd src
ninja -C ${BUILD_DIR} base_unittests
- name: ninja sql_unittests
run: |
cd src
ninja -C ${BUILD_DIR} sql_unittests
- name: ninja net_unittests
run: |
cd src
ninja -C ${BUILD_DIR} net_unittests
- name: ninja url_unittests
run: |
cd src
ninja -C ${BUILD_DIR} url_unittests
- name: ninja ipc_tests
run: |
cd src
ninja -C ${BUILD_DIR} ipc_tests
- name: ninja mojo_unittests
run: |
cd src
ninja -C ${BUILD_DIR} mojo_unittests
- name: ninja gpu_unittests
run: |
cd src
ninja -C ${BUILD_DIR} gpu_unittests
# V8 utility stuff
- name: ninja gin_unittests
run: |
cd src
ninja -C ${BUILD_DIR} gin_unittests
- name: ninja blink_unittests
run: |
cd src
ninja -C ${BUILD_DIR} blink_unittests
- name: ninja content_shell
run: |
cd src
ninja -C ${BUILD_DIR} content_shell
- name: sccache check
run: sccache -s
- name: Any speed
run: echo Any speed
135 changes: 135 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Linux Build

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- '*_workflows'
push:
branches:
- '*_workflows'
workflow_dispatch:

jobs:
docker-build-image:
runs-on: ubuntu-latest

env:
docker_tag: ${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}

steps:
- uses: actions/checkout@v4
#- name: Dump context
# uses: crazy-max/ghaction-dump-context@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull just in case
run: docker pull ghcr.io/${{ github.repository }}/linux || true
- name: Build containers using docker-compose
run: docker-compose build
- name: Re-tag
run: docker tag ghcr.io/${{ github.repository }}/linux:latest ghcr.io/${{ github.repository }}/linux:${{ env.docker_tag }}
- name: Work
run: docker push ghcr.io/${{ github.repository }}/linux:${{ env.docker_tag }}
outputs:
docker_tag: ghcr.io/${{ github.repository }}/linux:${{ env.docker_tag }}

build:
needs: [docker-build-image]
runs-on: [self-hosted, chrobalt-linux-runner]
container: ${{ needs.docker-build-image.outputs.docker_tag }}
env:
DEPOT_TOOLS_UPDATE: 0
DEPOT_TOOLS_REPORT_BUILD: 0
DEPOT_TOOLS_COLLECT_METRICS: 0
DEPOT_TOOLS_METRICS: 0
SCCACHE: 1
SCCACHE_GCS_BUCKET: cobalt-actions-sccache-linux
SCCACHE_GCS_SERVICE_ACCOUNT: [email protected]
SCCACHE_GCS_RW_MODE: READ_WRITE
SCCACHE_IDLE_TIMEOUT: 0 # prevent sccache server from shutting down after long idle.
BUILD_DIR: out/Default

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: src
# - name: Dump context
# uses: crazy-max/ghaction-dump-context@v2
- name: Get depot tools
# run: git clone -b dev https://github.com/kaidokert/depot_tools.git
run: git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- name: Add directory to PATH
run: echo "$GITHUB_WORKSPACE/depot_tools" >> $GITHUB_PATH
- name: Generate gclient file
run: gclient config --name=src https://github.com/${{ github.repository }}
- name: Gclient sync
run: gclient sync -v --shallow --no-history -r ${{ github.sha }}
- name: DF
run: df -h
- name: Du
run: du -ht 500M
- name: sccache check
run: sccache -s
- name: gn gen
run: |
cd src
mkdir -p ${BUILD_DIR}
cp chrobalt/linux/args.gn ${BUILD_DIR}
gn gen ${BUILD_DIR}
- name: gn dump args
run: |
cd src
gn args --list --short ${BUILD_DIR}
- name: ninja base_unittests
run: |
cd src
ninja -C ${BUILD_DIR} base_unittests
- name: ninja sql_unittests
run: |
cd src
ninja -C ${BUILD_DIR} sql_unittests
- name: ninja net_unittests
run: |
cd src
ninja -C ${BUILD_DIR} net_unittests
- name: ninja url_unittests
run: |
cd src
ninja -C ${BUILD_DIR} url_unittests
- name: ninja ipc_tests
run: |
cd src
ninja -C ${BUILD_DIR} ipc_tests
- name: ninja mojo_unittests
run: |
cd src
ninja -C ${BUILD_DIR} mojo_unittests
- name: ninja gpu_unittests
run: |
cd src
ninja -C ${BUILD_DIR} gpu_unittests
# V8 utility stuff
- name: ninja gin_unittests
run: |
cd src
ninja -C ${BUILD_DIR} gin_unittests
- name: ninja blink_unittests
run: |
cd src
ninja -C ${BUILD_DIR} blink_unittests
- name: ninja content_shell
run: |
cd src
ninja -C ${BUILD_DIR} content_shell
- name: sccache check
run: sccache -s
- name: Any speed
run: echo Any speed
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

default_language_version:
python: python3
files: |
(?x)^(
(
.github|
chrobalt|
)
)
repos:
- repo: https://cobalt.googlesource.com/pre-commit-hooks
rev: e1668fe86af3810fbca72b8653fe478e66a0afdc # v3.2.0
hooks:
- id: check-case-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
4 changes: 4 additions & 0 deletions chrobalt/android/args.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cc_wrapper = "sccache"
symbol_level = 0
target_os = "android"
target_cpu = "arm64"
76 changes: 76 additions & 0 deletions chrobalt/build/gn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python3
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os
from pathlib import Path
from typing import List

_BUILD_TYPES = ['debug', 'devel', 'qa']

def main(out_directory: str, platform: str, build_type: str,
overwrite_args: bool, gn_gen_args: List[str]):
platform_path = 'chrobalt/linux'
dst_args_gn_file = os.path.join(out_directory, 'args.gn')
src_args_gn_file = os.path.join(platform_path, 'args.gn')
Path(out_directory).mkdir(parents=True, exist_ok=True)

if __name__ == '__main__':
parser = argparse.ArgumentParser()
builds_directory_group = parser.add_mutually_exclusive_group()
builds_directory_group.add_argument(
'out_directory',
type=str,
nargs='?',
help='Path to the directory to build in.')

parser.add_argument(
'-p',
'--platform',
default='linux-x64x11',
choices=['linux-x64x11'],
help='The platform to build.')
parser.add_argument(
'-c',
'-C',
'--build_type',
default='devel',
choices=_BUILD_TYPES,
help='The build_type (configuration) to build with.')
parser.add_argument(
'--overwrite_args',
default=False,
action='store_true',
help='Whether or not to overwrite an existing args.gn file if one exists '
'in the out directory. In general, if the file exists, you should run '
'`gn args <out_directory>` to edit it instead.')
parser.add_argument(
'--no-check',
default=False,
action='store_true',
help='Pass this flag to disable the header dependency gn check.')
script_args, gen_args = parser.parse_known_args()

if not script_args.no_check:
gen_args.append('--check')

if script_args.out_directory:
builds_out_directory = script_args.out_directory
else:
builds_directory = 'out'
builds_out_directory = os.path.join(
builds_directory, f'{script_args.platform}_{script_args.build_type}')
main(builds_out_directory, script_args.platform, script_args.build_type,
script_args.overwrite_args, gen_args)
Loading

0 comments on commit 50b4d3a

Please sign in to comment.