Skip to content

Commit

Permalink
Initial test with hardcoded version
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerben van der Stouwe committed Aug 24, 2022
1 parent fd253de commit 64d637a
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gclient
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
solutions = [
{
"managed": False,
"name": "src",
"url": "https://chromium.googlesource.com/chromium/src.git",
"custom_deps": {},
"deps_file": ".DEPS.git",
"safesync_url": ""
}
]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# headless-chromium-build
Scripts to build a headless chromium executable
Based on https://github.com/adieuadieu/serverless-chrome/tree/master/packages/lambda/builds/chromium/build
79 changes: 79 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@


set -e

BUILD_BASE=$(pwd)
VERSION=104.0.5112.97


# install dependencies
yum groupinstall -y "Development Tools"
yum install -y \
alsa-lib-devel atk-devel binutils bison bluez-libs-devel brlapi-devel \
bzip2 bzip2-devel cairo-devel cmake cups-devel dbus-devel dbus-glib-devel \
expat-devel fontconfig-devel freetype-devel gcc-c++ git glib2-devel glibc \
gperf gtk3-devel htop httpd java-1.*.0-openjdk-devel libatomic libcap-devel \
libffi-devel libgcc libgnome-keyring-devel libjpeg-devel libstdc++ libuuid-devel \
libX11-devel libxkbcommon-x11-devel libXScrnSaver-devel libXtst-devel mercurial \
mod_ssl ncurses-compat-libs nspr-devel nss-devel pam-devel pango-devel \
pciutils-devel php php-cli pkgconfig pulseaudio-libs-devel python python3 \
tar zlib zlib-devel

mkdir -p build/chromium

cd build

# install dept_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

export PATH="/opt/gtk/bin:$PATH:$BUILD_BASE/build/depot_tools"

cd chromium

# fetch chromium source code
# ref: https://www.chromium.org/developers/how-tos/get-the-code/working-with-release-branches

# git shallow clone, much quicker than a full git clone; see https://stackoverflow.com/a/39067940/3145038 for more details

git clone --branch "$VERSION" --depth 1 https://chromium.googlesource.com/chromium/src.git

# Checkout all the submodules at their branch DEPS revisions
gclient sync --with_branch_heads --jobs 16

cd src

# the following is no longer necessary since. left here for nostalgia or something.
# ref: https://chromium.googlesource.com/chromium/src/+/1824e5752148268c926f1109ed7e5ef1d937609a%5E%21
# tweak to disable use of the tmpfs mounted at /dev/shm
# sed -e '/if (use_dev_shm) {/i use_dev_shm = false;\n' -i base/files/file_util_posix.cc

#
# tweak to keep Chrome from crashing after 4-5 Lambda invocations
# see https://github.com/adieuadieu/serverless-chrome/issues/41#issuecomment-340859918
# Thank you, Geert-Jan Brits (@gebrits)!
#
SANDBOX_IPC_SOURCE_PATH="content/browser/sandbox_ipc_linux.cc"

sed -e 's/PLOG(WARNING) << "poll";/PLOG(WARNING) << "poll"; failed_polls = 0;/g' -i "$SANDBOX_IPC_SOURCE_PATH"


# specify build flags
mkdir -p out/Headless && \
echo 'import("//build/args/headless.gn")' > out/Headless/args.gn && \
echo 'is_debug = false' >> out/Headless/args.gn && \
echo 'symbol_level = 0' >> out/Headless/args.gn && \
echo 'is_component_build = false' >> out/Headless/args.gn && \
echo 'remove_webcore_debug_symbols = true' >> out/Headless/args.gn && \
echo 'enable_nacl = false' >> out/Headless/args.gn && \
gn gen out/Headless

# build chromium headless shell
ninja -C out/Headless headless_shell

cp out/Headless/headless_shell "$BUILD_BASE/bin/headless-chromium-unstripped"

cd "$BUILD_BASE"

# strip symbols
strip -o "$BUILD_BASE/bin/headless-chromium" build/chromium/src/out/Headless/headless_shell

12 changes: 12 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 0.2


phases:
build:
commands:
- ./build.sh

artifacts:
files:
- 'out/*'
- 'bin/*'

0 comments on commit 64d637a

Please sign in to comment.