Reporting/Chromium: restore Mac build scripts (#101238) (#101428)

* Reporting/Chromium: restore Mac build scripts

* fix accuracy of the readme

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tim Sullivan 2021-06-04 14:25:14 -07:00 committed by GitHub
parent 21610db4e1
commit 810c4067b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 22 deletions

View file

@ -1,26 +1,29 @@
# Chromium build
We ship our own headless build of Chromium which is significantly smaller than
the standard binaries shipped by Google. The scripts in this folder can be used
to accept a commit hash from the Chromium repository, and initialize the build
on Ubuntu Linux.
We ship our own headless build of Chromium for Linux and Mac OS, using a
version of the source that corresponds to the requirements of the Puppeteer
node module. The scripts in this folder can be used to accept a commit hash
from the Chromium repository, and initialize the build in a workspace.
## Why do we do this
By default, Puppeteer will download a zip file containing the Chromium browser for any
OS. This creates problems on Linux, because Chromium has a dependency on X11, which
is often not installed for a server environment. We don't want to make a requirement
for Linux that you need X11 to run Kibana. To work around this, we create our own Chromium
build, using the
**Linux**: By default, Puppeteer will download a zip file containing the
Chromium browser for any OS. This creates problems on Linux, because Chromium
has a dependency on X11, which is often not installed for a server environment.
We don't want to make a requirement for Linux that you need X11 to run Kibana.
To work around this, we create our own Chromium build, using the
[`headless_shell`](https://chromium.googlesource.com/chromium/src/+/5cf4b8b13ed518472038170f8de9db2f6c258fe4/headless)
build target. There are no (trustworthy) sources of these builds available elsewhere.
build target. There are no (trustworthy) sources of these builds available
elsewhere.
Fortunately, creating the custom builds is only necessary for Linux. When you have a build
of Kibana for Linux, or if you use a Linux desktop to develop Kibana, you have a copy of
`headless_shell` bundled inside. When you have a Windows or Mac build of Kibana, or use
either of those for development, you have a copy of the full build of Chromium, which
was downloaded from the main [Chromium download
location](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html).
**Mac**: We do this on Mac because Elastic signs the Kibanna release artifact
with Apple to work with Gatekeeper on Mac OS. Having our own binary of Chromium
and bundling it with Kibana is integral to the artifact signing process.
**Windows**: No custom build is necessary for Windows. We are able to use the
full build of Chromium, downloaded from the main [Chromium download
location](https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html),
using the revision that corresponds with the Puppeteer dependency.
## Build Script Usage

View file

@ -6,7 +6,7 @@ from build_util import (
md5_file,
)
# This file builds Chromium headless on Linux.
# This file builds Chromium headless on Mac and Linux.
# Verify that we have an argument, and if not print instructions
if (len(sys.argv) < 2):
@ -68,7 +68,6 @@ if platform.system() == 'Linux':
print('Running install-build-deps...')
runcmd(src_path + '/build/install-build-deps.sh')
print('Updating all modules')
runcmd('gclient sync -D')
@ -89,7 +88,7 @@ runcmd('gn gen out/headless')
print('Compiling... this will take a while')
runcmd('autoninja -C out/headless headless_shell')
# Optimize the output on Linux x64 by stripping inessentials from the binary
# Optimize the output on Linux x64 and Mac by stripping inessentials from the binary
# ARM must be cross-compiled from Linux and can not read the ARM binary in order to strip
if platform.system() != 'Windows' and arch_name != 'arm64':
print('Optimizing headless_shell')
@ -112,10 +111,18 @@ def archive_file(name):
archive.write(from_path, to_path)
return to_path
# Add dependencies that must be bundled with the Chromium executable.
# Each platform has slightly different requirements for what dependencies
# must be bundled with the Chromium executable.
archive_file('headless_shell')
archive_file(path.join('swiftshader', 'libEGL.so'))
archive_file(path.join('swiftshader', 'libGLESv2.so'))
if platform.system() == 'Linux':
archive_file(path.join('swiftshader', 'libEGL.so'))
archive_file(path.join('swiftshader', 'libGLESv2.so'))
elif platform.system() == 'Darwin':
archive_file('headless_shell')
archive_file('libswiftshader_libEGL.dylib')
archive_file('libswiftshader_libGLESv2.dylib')
archive_file(path.join('Helpers', 'chrome_crashpad_handler'))
archive.close()

View file

@ -0,0 +1,30 @@
# Based on //build/headless.gn
# Embed resource.pak into binary to simplify deployment.
headless_use_embedded_resources = true
# In order to simplify deployment we build ICU data file
# into binary.
icu_use_data_file = false
# Use embedded data instead external files for headless in order
# to simplify deployment.
v8_use_external_startup_data = false
enable_nacl = false
enable_print_preview = false
enable_basic_printing = false
enable_remoting = false
use_alsa = false
use_cups = false
use_dbus = false
use_gio = false
# Please, consult @elastic/kibana-security before changing/removing this option.
use_kerberos = false
use_libpci = false
use_pulseaudio = false
use_udev = false
is_debug = false
symbol_level = 0
is_component_build = false