Skip to content

Commit

Permalink
browser(webkit): use webkit generate-bundle tool to generate the bundles
Browse files Browse the repository at this point in the history
 * This changes the archive.sh script to use the webkit generate-bundle
 tool to generate the MiniBrowser bundles instead of using our custom
 logic.

 * pw_run.sh is simplified because the new bundles include a wrapper
 script that sets the needed LD_LIBRARY_PATH environment variables.
 pw_run.sh now calls this wrapper script (for GTK or WPE) instead of
 calling the MiniBrowser binary directly when running from a bundle.
  • Loading branch information
clopez committed Aug 24, 2020
1 parent cd220da commit 5c1d5a9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 86 deletions.
4 changes: 2 additions & 2 deletions browser_patches/webkit/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
1328
Changed: yurys@chromium.org Fri Aug 21 19:21:58 PDT 2020
1329
Changed: clopez@igalia.com Mon Aug 24 14:55:53 CEST 2020
83 changes: 8 additions & 75 deletions browser_patches/webkit/archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,92 +44,25 @@ main() {
fi
}

copyLibrariesForWPE() {
# Expect target directory to be passed in as first argument.
local tmpdir=$1

# copy all relevant binaries
cp -t $tmpdir ./WebKitBuild/WPE/Release/bin/MiniBrowser ./WebKitBuild/WPE/Release/bin/WPE*Process
# copy all relevant shared objects
# - exclude gstreamer plugins
LD_LIBRARY_PATH="$PWD/WebKitBuild/WPE/DependenciesWPE/Root/lib" ldd WebKitBuild/WPE/Release/bin/MiniBrowser \
| grep -o '[^ ]*WebKitBuild/WPE/[^ ]*' \
| grep -v '/libgst.*so' \
| xargs cp -t $tmpdir
LD_LIBRARY_PATH="$PWD/WebKitBuild/WPE/DependenciesWPE/Root/lib" ldd WebKitBuild/WPE/Release/bin/WPENetworkProcess \
| grep -o '[^ ]*WebKitBuild/WPE/[^ ]*' \
| grep -v '/libgst.*so' \
| xargs cp -t $tmpdir
LD_LIBRARY_PATH="$PWD/WebKitBuild/WPE/DependenciesWPE/Root/lib" ldd WebKitBuild/WPE/Release/bin/WPEWebProcess \
| grep -o '[^ ]*WebKitBuild/WPE/[^ ]*' \
| grep -v '/libgst.*so' \
| xargs cp -t $tmpdir
# Copy some wayland libraries required for Web Process
if ls WebKitBuild/WPE/DependenciesWPE/Root/lib/libva\-* 2>&1 >/dev/null; then
cp -d -t $tmpdir WebKitBuild/WPE/DependenciesWPE/Root/lib/libva\-*
fi
# Injected bundle is loaded dynamicly via dlopen => not bt listed by ldd.
cp -t $tmpdir WebKitBuild/WPE/Release/lib/libWPEInjectedBundle.so
if test -d $PWD/WebKitBuild/WPE/DependenciesWPE/Root/lib/gio/modules/; then
mkdir -p $tmpdir/gio/modules
cp -t $tmpdir/gio/modules $PWD/WebKitBuild/WPE/DependenciesWPE/Root/lib/gio/modules/*
fi

cd $tmpdir
ln -s libWPEBackend-fdo-1.0.so.1 libWPEBackend-fdo-1.0.so
cd -

# Strip copied binaries.
cd $tmpdir
strip --strip-unneeded * || true
cd -
}

copyLibrariesForGTK() {
# Expect target directory to be passed in as first argument.
local tmpdir=$1

# copy all relevant binaries
cp -t $tmpdir ./WebKitBuild/GTK/Release/bin/MiniBrowser ./WebKitBuild/GTK/Release/bin/WebKit*Process
# copy all relevant shared objects
# - exclude gstreamer plugins
# - exclude libdrm
LD_LIBRARY_PATH="$PWD/WebKitBuild/GTK/DependenciesGTK/Root/lib" ldd WebKitBuild/GTK/Release/bin/MiniBrowser \
| grep -o '[^ ]*WebKitBuild/GTK/[^ ]*' \
| grep -v '/libgst.*so' \
| grep -v '/libdrm.so' \
| xargs cp -t $tmpdir

# Injected bundle is loaded dynamicly via dlopen => not bt listed by ldd.
cp -t $tmpdir WebKitBuild/GTK/Release/lib/libwebkit2gtkinjectedbundle.so
if test -d $PWD/WebKitBuild/GTK/DependenciesGTK/Root/lib/gio/modules; then
mkdir -p $tmpdir/gio/modules
cp -t $tmpdir/gio/modules $PWD/WebKitBuild/GTK/DependenciesGTK/Root/lib/gio/modules/*
fi

# we failed to nicely build libgdk_pixbuf - expect it in the env
rm -f $tmpdir/libgdk_pixbuf*

# tar resulting directory and cleanup TMP.
cd $tmpdir
strip --strip-unneeded * || true
cd -
}

createZipForLinux() {
# create a TMP directory to copy all necessary files
local tmpdir=$(mktemp -d -t webkit-deploy-XXXXXXXXXX)
mkdir -p $tmpdir
mkdir -p $tmpdir/minibrowser-gtk
mkdir -p $tmpdir/minibrowser-wpe

# copy runner
cp -t $tmpdir $SCRIPTS_DIR/pw_run.sh
# copy protocol
node $SCRIPTS_DIR/concat_protocol.js > $tmpdir/protocol.json

copyLibrariesForWPE $tmpdir/minibrowser-wpe
copyLibrariesForGTK $tmpdir/minibrowser-gtk
# Generate and unpack MiniBrowser bundles for each port
for port in gtk wpe; do
WEBKIT_OUTPUTDIR=$(pwd)/WebKitBuild/${port^^} Tools/Scripts/generate-bundle \
--bundle=MiniBrowser --release \
--platform=${port} --destination=${tmpdir}
unzip ${tmpdir}/MiniBrowser_${port}_release.zip -d ${tmpdir}/minibrowser-${port}
rm -f ${tmpdir}/MiniBrowser_${port}_release.zip
done

# tar resulting directory and cleanup TMP.
cd $tmpdir
Expand Down
25 changes: 16 additions & 9 deletions browser_patches/webkit/pw_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ function runOSX() {

function runLinux() {
# if script is run as-is
GIO_DIR="";
LD_PATH="";
BUNDLE_DIR="";
DEPENDENCIES_FOLDER="DependenciesGTK";
MINIBROWSER_FOLDER="minibrowser-gtk";
BUILD_FOLDER="WebKitBuild/GTK";
GIO_DIR="";
if [[ "$*" == *--headless* ]]; then
DEPENDENCIES_FOLDER="DependenciesWPE";
MINIBROWSER_FOLDER="minibrowser-wpe";
BUILD_FOLDER="WebKitBuild/WPE";
fi
# Setting extra environment variables like LD_LIBRARY_PATH or WEBKIT_INJECTED_BUNDLE_PATH
# is only needed when calling MiniBrowser from the build folder. The MiniBrowser from
# the zip bundle wrapper already sets itself the needed env variables.
if [[ -d $SCRIPT_PATH/$MINIBROWSER_FOLDER ]]; then
LD_PATH="$SCRIPT_PATH/$MINIBROWSER_FOLDER"
GIO_DIR="$SCRIPT_PATH/$MINIBROWSER_FOLDER/gio/modules"
BUNDLE_DIR="$LD_PATH"
MINIBROWSER="$SCRIPT_PATH/$MINIBROWSER_FOLDER/MiniBrowser"
elif [[ -d $SCRIPT_PATH/checkout/$BUILD_FOLDER ]]; then
LD_PATH="$SCRIPT_PATH/checkout/$BUILD_FOLDER/$DEPENDENCIES_FOLDER/Root/lib:$SCRIPT_PATH/checkout/$BUILD_FOLDER/Release/bin"
GIO_DIR="$SCRIPT_PATH/checkout/$BUILD_FOLDER/$DEPENDENCIES_FOLDER/Root/lib/gio/modules"
BUNDLE_DIR="$SCRIPT_PATH/checkout/$BUILD_FOLDER/Release/lib"
MINIBROWSER="$SCRIPT_PATH/checkout/$BUILD_FOLDER/Release/bin/MiniBrowser"
elif [[ -f $SCRIPT_PATH/MiniBrowser ]]; then
LD_PATH="$SCRIPT_PATH"
GIO_DIR="$SCRIPT_PATH/gio/modules"
BUNDLE_DIR="$SCRIPT_PATH"
MINIBROWSER="$SCRIPT_PATH/MiniBrowser"
elif [[ -d $SCRIPT_PATH/$BUILD_FOLDER ]]; then
LD_PATH="$SCRIPT_PATH/$BUILD_FOLDER/$DEPENDENCIES_FOLDER/Root/lib:$SCRIPT_PATH/$BUILD_FOLDER/Release/bin"
Expand All @@ -52,11 +51,19 @@ function runLinux() {
exit 1
fi

if [[ -d "$GIO_DIR" ]]; then
if [[ -n "$GIO_DIR" ]]; then
export GIO_EXTRA_MODULES="$GIO_DIR"
fi

WEBKIT_FORCE_COMPLEX_TEXT="1" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LD_PATH" WEBKIT_INJECTED_BUNDLE_PATH="$BUNDLE_DIR" "$MINIBROWSER" "$@"
if [[ -n "$LD_PATH" ]]; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LD_PATH"
fi

if [[ -n "$BUNDLE_DIR" ]]; then
export WEBKIT_INJECTED_BUNDLE_PATH="$BUNDLE_DIR"
fi

WEBKIT_FORCE_COMPLEX_TEXT="1" "$MINIBROWSER" "$@"
}

SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)"
Expand Down

0 comments on commit 5c1d5a9

Please sign in to comment.