kibana/x-pack/build_chromium/build_util.py
Tim Sullivan e699d91b2c
[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>
2020-12-29 09:54:19 -07:00

46 lines
1.5 KiB
Python

import os, hashlib, platform, sys
# This file contains various utility functions used by the init and build scripts
def runcmdsilent(cmd):
"""Executes a string command in the shell"""
print(' > ' + cmd)
return os.system(cmd)
def runcmd(cmd):
"""Executes a string command in the shell"""
print(' > ' + cmd)
result = os.system(cmd)
if result != 0:
raise Exception(cmd + ' returned ' + str(result))
def mkdir(dir):
print(' > mkdir -p ' + dir)
"""Makes a directory if it doesn't exist"""
if not os.path.exists(dir):
return os.makedirs(dir)
def md5_file(filename):
"""Builds a hex md5 hash of the given file"""
md5 = hashlib.md5()
with open(filename, 'rb') as f:
for chunk in iter(lambda: f.read(128 * md5.block_size), b''):
md5.update(chunk)
return md5.hexdigest()
def configure_environment(arch_name, build_path, src_path):
"""Runs install scripts for deps, and configures temporary environment variables required by Chromium's build"""
if platform.system() == 'Linux':
if arch_name:
print('Running sysroot install script...')
sysroot_cmd = src_path + '/build/linux/sysroot_scripts/install-sysroot.py --arch=' + arch_name
runcmd(sysroot_cmd)
print('Running install-build-deps...')
runcmd(src_path + '/build/install-build-deps.sh')
depot_tools_path = os.path.join(build_path, 'depot_tools')
full_path = depot_tools_path + os.pathsep + os.environ['PATH']
print('Updating PATH for depot_tools: ' + full_path)
os.environ['PATH'] = full_path