[Build Chromium] Improve git checkout (#83225)

* [Build Chromium] Document steps for local build, improve checkout

commit e817796d107d554504870cdb8e6dd10db1079a1e
Merge: 19e6b300260 61b4e052fdd
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Thu Nov 12 13:25:09 2020 -0700

    Merge branch 'chore/build_chromium/improvements' of github.com:tsullivan/kibana into chore/build_chromium/improvements

commit 19e6b300260822418cea4dc594bdfdf621a331e0
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Thu Nov 12 13:23:01 2020 -0700

    fixes

commit 9de24ec298792a46e88207f41c9f6aff1997dbf1
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Thu Nov 12 13:22:52 2020 -0700

    add instructions to build local

commit 872c0f68e0077ad50c541b605a87253befd1a891
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Thu Nov 12 11:58:25 2020 -0700

    simplify

commit 8dae9484efcdc483ad20ceab32cae4e97735ab1c
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Thu Nov 12 10:28:18 2020 -0700

    fixes

commit 492f5cfe25e2c7ccffce55a8733383a30aae1cb6
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed Nov 11 20:15:43 2020 -0700

    --wip-- [skip ci]

commit acba359b121f7be8e6c353f90e938bc5d88658a1
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed Nov 11 15:47:50 2020 -0700

    [Build Chromium] Improve git checkout

commit 61b4e052fdd04456fe23956ad8ce99c8e771c01e
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed Nov 11 20:15:43 2020 -0700

    --wip-- [skip ci]

commit 58300c9deeca15cce838b3956c55c2994f99f530
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed Nov 11 15:47:50 2020 -0700

    [Build Chromium] Improve git checkout

* Apply suggestions from code review

Co-authored-by: Joel Griffith <joel@joelgriffith.net>

Co-authored-by: Joel Griffith <joel@joelgriffith.net>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tim Sullivan 2020-12-29 09:54:19 -07:00 committed by GitHub
parent f3b43cbf3f
commit e699d91b2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 197 additions and 89 deletions

View file

@ -1,38 +1,47 @@
import os, platform, sys
from build_util import runcmd, mkdir, md5_file, root_dir, configure_environment
from os import path
from build_util import runcmd, mkdir, md5_file, configure_environment
# This is a cross-platform initialization script which should only be run
# once per environment, and isn't intended to be run directly. You should
# run the appropriate platform init script (e.g. Linux/init.sh) which will
# call this once the platform-specific initialization has completed.
os.chdir(root_dir)
# Set to "arm" to build for ARM on Linux
arch_name = sys.argv[1] if len(sys.argv) >= 2 else 'x64'
build_path = path.abspath(os.curdir)
src_path = path.abspath(path.join(build_path, 'chromium', 'src'))
if arch_name != 'x64' and arch_name != 'arm64':
raise Exception('Unexpected architecture: ' + arch_name)
# Configure git
print('Configuring git globals...')
runcmd('git config --global core.autocrlf false')
runcmd('git config --global core.filemode false')
runcmd('git config --global branch.autosetuprebase always')
# Grab Chromium's custom build tools, if they aren't already installed
# (On Windows, they are installed before this Python script is run)
if not os.path.isdir('depot_tools'):
runcmd('git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git')
# Put depot_tools on the path so we can properly run the fetch command
configure_environment()
if not path.isdir('depot_tools'):
print('Installing depot_tools...')
runcmd('git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git')
else:
print('Updating depot_tools...')
original_dir = os.curdir
os.chdir(path.join(build_path, 'depot_tools'))
runcmd('git checkout master')
runcmd('git pull origin master')
os.chdir(original_dir)
configure_environment(arch_name, build_path, src_path)
# Fetch the Chromium source code
mkdir('chromium')
os.chdir('chromium')
runcmd('fetch chromium')
# Build Linux deps
if platform.system() == 'Linux':
os.chdir('src')
if len(sys.argv) >= 2:
sysroot_cmd = 'build/linux/sysroot_scripts/install-sysroot.py --arch=' + sys.argv[1]
print('Running `' + sysroot_cmd + '`')
runcmd(sysroot_cmd)
runcmd('build/install-build-deps.sh')
chromium_dir = path.join(build_path, 'chromium')
if not path.isdir(chromium_dir):
mkdir(chromium_dir)
os.chdir(chromium_dir)
runcmd('fetch chromium')
else:
print('Directory exists: ' + chromium_dir + '. Skipping chromium fetch.')