Skip to content

Instantly share code, notes, and snippets.

@aleitner
Last active February 6, 2024 17:17

Revisions

  1. aleitner revised this gist Feb 6, 2024. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -89,14 +89,22 @@ apply_patches() {
    exit 1
    fi

    echo "Applying patches from ${PATCHES_DIR} to ${CEF_DIR}..."

    # First, copy the directory structure and files over
    cp -rv "${PATCHES_DIR}"/*/ "${CEF_DIR}/"

    # Then, apply each patch file
    local patch_file
    echo "Applying patches from ${PATCHES_DIR}..."
    for patch_file in "${PATCHES_DIR}"/*.patch; do
    if [ -f "$patch_file" ]; then
    git apply "$patch_file"
    # Ensure we are in the correct directory when applying patches
    (cd "${CEF_DIR}" && git apply "$patch_file") || {
    echo "Failed to apply patch: $patch_file"
    exit 1
    }
    fi
    done
    cp -rv "${PATCHES_DIR}"/*/ ./
    }

    # copy CEF to installation directory
    @@ -264,4 +272,4 @@ else
    run_build
    fi

    echo "Build process completed successfully"
    echo "Build process completed successfully"
  2. aleitner revised this gist Feb 6, 2024. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,14 @@
    set -euo pipefail

    usage() {
    echo "Usage: $0 [--manual-build] [--x64-build|--arm64-build] [--no-build]"
    echo " --manual-build Run the build process manually without automatic tools."
    echo " --x64-build Perform an x64 build (default)."
    echo " --arm64-build Perform an ARM64 cross-compile build."
    echo " --no-build Skip the build and update CEF from a predefined URL."
    echo "Usage: $0 [options]"
    echo "Options:"
    echo " --manual-build Run the build process manually without automatic tools."
    echo " --x64-build Perform an x64 build (default)."
    echo " --arm64-build Perform an ARM64 cross-compile build."
    echo " --no-build Skip the build and update CEF from a predefined URL."
    echo " --patches-dir <dir> Specify the directory containing patch files to apply (only with --manual-build)."
    echo " -h, --help Show this message."
    exit 1
    }

  3. aleitner revised this gist Feb 6, 2024. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@ usage() {
    MANUAL_BUILD=false
    BUILD_FLAG="--x64-build" # Set the default build flag to x64
    OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64
    PATCHES_DIR=""
    NO_BUILD=false
    CEF_VERSION="119.4.7+g55e15c8+chromium-119.0.6045.199"
    CEF_URL="https://cef-builds.spotifycdn.com/cef_binary_${CEF_VERSION}_linux64.tar.bz2" # Define the URL where the CEF should be downloaded from
    @@ -41,6 +42,10 @@ while [[ $# -gt 0 ]]; do
    OUT_DIR="out/Release_GN_arm64"
    shift
    ;;
    --patches-dir)
    PATCHES_DIR="$2"
    shift 2
    ;;
    -h|--help)
    usage
    ;;
    @@ -69,6 +74,28 @@ CEF_INSTALL_DIR="/opt/cef"
    mkdir -p "${BUILD_DIR}"
    mkdir -p "${AUTOMATE_DIR}"

    # Function to apply patch files from PATCHES_DIR to CEF_DIR
    apply_patches() {
    if [ -z "${PATCHES_DIR}" ]; then
    echo "No patches directory specified, skipping patch application."
    return 0
    fi

    if [ ! -d "${PATCHES_DIR}" ]; then
    echo "The specified patches directory does not exist: ${PATCHES_DIR}"
    exit 1
    fi

    local patch_file
    echo "Applying patches from ${PATCHES_DIR}..."
    for patch_file in "${PATCHES_DIR}"/*.patch; do
    if [ -f "$patch_file" ]; then
    git apply "$patch_file"
    fi
    done
    cp -rv "${PATCHES_DIR}"/*/ ./
    }

    # copy CEF to installation directory
    copy_distribution_to_opt() {
    local src_dir="$1"
    @@ -147,6 +174,9 @@ run_manual_build() {
    --force-clean \
    --force-clean-deps

    # Apply any patches if specified
    apply_patches

    # Update PATH
    export PATH="${CHROMIUM_DIR}/depot_tools:$PATH"

  4. aleitner revised this gist Dec 15, 2023. 1 changed file with 17 additions and 2 deletions.
    19 changes: 17 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -85,21 +85,36 @@ copy_distribution_to_opt() {

    no_build() {
    local temp_file="/tmp/cef.tar.bz2"
    local temp_extract_dir="/tmp/cef_extract"

    echo "Downloading from URL: $CEF_URL..."
    if ! curl -L -o "$temp_file" "$CEF_URL"; then
    echo "Download failed!"
    exit 1
    fi

    echo 'Creating temporary extraction directory...'
    if ! mkdir -p "$temp_extract_dir"; then
    echo "Failed to create temporary extraction directory: $temp_extract_dir"
    rm -f "$temp_file"
    exit 1
    fi

    echo 'Extracting file...'
    sudo tar -xjf "$temp_file" --strip-components=1 -C "${CEF_INSTALL_DIR}"
    if ! tar -xjf "$temp_file" --strip-components=1 -C "$temp_extract_dir"; then
    echo "Failed to extract files to $temp_extract_dir"
    rm -f "$temp_file"
    exit 1
    fi

    echo 'Removing downloaded tarball...'
    rm -f "$temp_file"

    # Use copy_distribution_to_opt to copy files to their destination
    copy_distribution_to_opt "${CEF_INSTALL_DIR}"
    copy_distribution_to_opt "$temp_extract_dir"

    # Cleaning up temporary extraction directory
    rm -rf "$temp_extract_dir"
    }

    # Function to run the build command
  5. aleitner revised this gist Dec 15, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ MANUAL_BUILD=false
    BUILD_FLAG="--x64-build" # Set the default build flag to x64
    OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64
    NO_BUILD=false
    CEF_VERSION="119.4.7+g55e15c8+chromium_119.0.6045.199"
    CEF_VERSION="119.4.7+g55e15c8+chromium-119.0.6045.199"
    CEF_URL="https://cef-builds.spotifycdn.com/cef_binary_${CEF_VERSION}_linux64.tar.bz2" # Define the URL where the CEF should be downloaded from
    CEF_COMMIT_HASH=$(echo $CEF_VERSION | cut -d '+' -f 2 | cut -c 2-)

  6. aleitner revised this gist Dec 15, 2023. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -87,17 +87,19 @@ no_build() {
    local temp_file="/tmp/cef.tar.bz2"

    echo "Downloading from URL: $CEF_URL..."
    wget -O "$temp_file" "$CEF_URL"
    if ! curl -L -o "$temp_file" "$CEF_URL"; then
    echo "Download failed!"
    exit 1
    fi

    echo 'Extracting file...'
    sudo tar -xjf "$temp_file" --strip-components=1 -C "${CEF_INSTALL_DIR}"

    echo 'Removing downloaded tarball...'
    rm "$temp_file"
    rm -f "$temp_file"

    # Use copy_distribution_to_opt to copy files to their destination
    copy_distribution_to_opt "${CEF_INSTALL_DIR}"
    echo 'Operation completed!'
    }

    # Function to run the build command
  7. aleitner revised this gist Dec 15, 2023. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64
    NO_BUILD=false
    CEF_VERSION="119.4.7+g55e15c8+chromium_119.0.6045.199"
    CEF_URL="https://cef-builds.spotifycdn.com/cef_binary_${CEF_VERSION}_linux64.tar.bz2" # Define the URL where the CEF should be downloaded from
    CEF_COMMIT_HASH=`echo %{version} | cut -d '+' -f 2 | cut -c 2-`
    CEF_COMMIT_HASH=$(echo $CEF_VERSION | cut -d '+' -f 2 | cut -c 2-)

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    @@ -66,8 +66,8 @@ CEF_DIR="${CHROMIUM_DIR}/chromium/src/cef"
    CEF_INSTALL_DIR="/opt/cef"

    # Ensure the build and automate directories exist.
    mkdir -p ${BUILD_DIR}
    mkdir -p ${AUTOMATE_DIR}
    mkdir -p "${BUILD_DIR}"
    mkdir -p "${AUTOMATE_DIR}"

    # copy CEF to installation directory
    copy_distribution_to_opt() {
    @@ -199,10 +199,10 @@ sudo python3 -m pip install dataclasses importlib_metadata

    # Download the automate-git.py script into the automate directory if it doesn't exist.
    AUTOMATE_SCRIPT="${AUTOMATE_DIR}/automate-git.py"
    AUTOMATE_SCRIPT_URL="https://raw.githubusercontent.com/chromiumembedded/cef/${CEF_COMMIT_HASH}/tools/automate/automate-git.pyy"
    AUTOMATE_SCRIPT_URL="https://raw.githubusercontent.com/chromiumembedded/cef/${CEF_COMMIT_HASH}/tools/automate/automate-git.py"
    if [ ! -f "${AUTOMATE_SCRIPT}" ]; then
    echo "Downloading the automate-git.py script..."
    curl ${AUTOMATE_SCRIPT_URL} -o ${AUTOMATE_SCRIPT}
    curl "${AUTOMATE_SCRIPT_URL}" -o "${AUTOMATE_SCRIPT}"
    fi

    # Run the appropriate function based on the --no-build option
  8. aleitner revised this gist Dec 15, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,8 @@ MANUAL_BUILD=false
    BUILD_FLAG="--x64-build" # Set the default build flag to x64
    OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64
    NO_BUILD=false
    CEF_URL="" # Define the URL where the CEF should be downloaded from
    CEF_VERSION="119.4.7+g55e15c8+chromium_119.0.6045.199"
    CEF_URL="https://cef-builds.spotifycdn.com/cef_binary_${CEF_VERSION}_linux64.tar.bz2" # Define the URL where the CEF should be downloaded from
    CEF_COMMIT_HASH=`echo %{version} | cut -d '+' -f 2 | cut -c 2-`

    # Process command-line arguments
  9. aleitner revised this gist Dec 15, 2023. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,8 @@ BUILD_FLAG="--x64-build" # Set the default build flag to x64
    OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64
    NO_BUILD=false
    CEF_URL="" # Define the URL where the CEF should be downloaded from
    CEF_VERSION="119.4.7+g55e15c8+chromium_119.0.6045.199"
    CEF_COMMIT_HASH=`echo %{version} | cut -d '+' -f 2 | cut -c 2-`

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    @@ -67,9 +69,6 @@ CEF_INSTALL_DIR="/opt/cef"
    mkdir -p ${BUILD_DIR}
    mkdir -p ${AUTOMATE_DIR}

    # Define the release branch number.
    RELEASE_BRANCH="6045"

    # copy CEF to installation directory
    copy_distribution_to_opt() {
    local src_dir="$1"
    @@ -106,7 +105,7 @@ run_build() {
    echo "Running the automate build script..."
    python3 "${AUTOMATE_SCRIPT}" \
    --download-dir="${CHROMIUM_DIR}" \
    --branch="${RELEASE_BRANCH}" \
    --checkout="${CEF_COMMIT_HASH}" \
    --minimal-distrib \
    --force-clean \
    --force-clean-deps \
    @@ -125,7 +124,7 @@ run_manual_build() {
    echo "Running the automate script without building..."
    python3 "${AUTOMATE_SCRIPT}" \
    --download-dir="${CHROMIUM_DIR}" \
    --branch="${RELEASE_BRANCH}" \
    --checkout="${CEF_COMMIT_HASH}" \
    --no-distrib \
    --no-build \
    --force-clean \
    @@ -200,7 +199,7 @@ sudo python3 -m pip install dataclasses importlib_metadata

    # Download the automate-git.py script into the automate directory if it doesn't exist.
    AUTOMATE_SCRIPT="${AUTOMATE_DIR}/automate-git.py"
    AUTOMATE_SCRIPT_URL="https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py"
    AUTOMATE_SCRIPT_URL="https://raw.githubusercontent.com/chromiumembedded/cef/${CEF_COMMIT_HASH}/tools/automate/automate-git.pyy"
    if [ ! -f "${AUTOMATE_SCRIPT}" ]; then
    echo "Downloading the automate-git.py script..."
    curl ${AUTOMATE_SCRIPT_URL} -o ${AUTOMATE_SCRIPT}
  10. aleitner revised this gist Dec 15, 2023. 1 changed file with 35 additions and 24 deletions.
    59 changes: 35 additions & 24 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -3,21 +3,28 @@
    set -euo pipefail

    usage() {
    echo "Usage: $0 [--manual-build] [--x64-build|--arm64-build]"
    echo "Usage: $0 [--manual-build] [--x64-build|--arm64-build] [--no-build]"
    echo " --manual-build Run the build process manually without automatic tools."
    echo " --x64-build Perform an x64 build (default)."
    echo " --arm64-build Perform an ARM64 cross-compile build."
    echo " --no-build Skip the build and update CEF from a predefined URL."
    exit 1
    }

    # Initialize default values
    MANUAL_BUILD=false
    BUILD_FLAG="--x64-build" # Set the default build flag to x64
    OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64
    NO_BUILD=false
    CEF_URL="" # Define the URL where the CEF should be downloaded from

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    case "$1" in
    --no-build)
    NO_BUILD=true
    shift
    ;;
    --manual-build)
    MANUAL_BUILD=true
    shift
    @@ -54,6 +61,7 @@ BUILD_DIR="${HOME}/code"
    AUTOMATE_DIR="${BUILD_DIR}/automate"
    CHROMIUM_DIR="${BUILD_DIR}/chromium_git"
    CEF_DIR="${CHROMIUM_DIR}/chromium/src/cef"
    CEF_INSTALL_DIR="/opt/cef"

    # Ensure the build and automate directories exist.
    mkdir -p ${BUILD_DIR}
    @@ -62,35 +70,36 @@ mkdir -p ${AUTOMATE_DIR}
    # Define the release branch number.
    RELEASE_BRANCH="6045"

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    case "$1" in
    --manual-build)
    MANUAL_BUILD=true
    shift
    ;;
    -h|--help)
    usage
    ;;
    *)
    echo "Unknown argument: $1"
    usage
    ;;
    esac
    done

    # copy CEF to installation directory
    copy_distribution_to_opt() {
    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r "${1}"/* /opt/cef/
    local src_dir="$1"
    sudo rm -rf "${CEF_INSTALL_DIR:?}/"*
    sudo mkdir -p "${CEF_INSTALL_DIR}"
    sudo cp -r "${src_dir}"/* "${CEF_INSTALL_DIR}/"

    pushd /opt/cef
    pushd "${CEF_INSTALL_DIR}"
    for file in Resources/*; do
    ln -s "../${file}" Release/
    sudo ln -s "../${file}" Release/
    done
    popd
    }

    no_build() {
    local temp_file="/tmp/cef.tar.bz2"

    echo "Downloading from URL: $CEF_URL..."
    wget -O "$temp_file" "$CEF_URL"

    echo 'Extracting file...'
    sudo tar -xjf "$temp_file" --strip-components=1 -C "${CEF_INSTALL_DIR}"

    echo 'Removing downloaded tarball...'
    rm "$temp_file"

    # Use copy_distribution_to_opt to copy files to their destination
    copy_distribution_to_opt "${CEF_INSTALL_DIR}"
    echo 'Operation completed!'
    }

    # Function to run the build command
    run_build() {
    @@ -198,7 +207,9 @@ if [ ! -f "${AUTOMATE_SCRIPT}" ]; then
    fi

    # Run the appropriate function based on the --no-build option
    if [ "$MANUAL_BUILD" = true ]; then
    if [ "$NO_BUILD" = true ]; then
    no_build
    elif [ "$MANUAL_BUILD" = true ]; then
    run_manual_build
    else
    run_build
  11. aleitner revised this gist Dec 15, 2023. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ usage() {
    # Initialize default values
    MANUAL_BUILD=false
    BUILD_FLAG="--x64-build" # Set the default build flag to x64
    OUT_DIR="out/Release_GN_x64" # Set the default output dir to x64

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    @@ -23,10 +24,12 @@ while [[ $# -gt 0 ]]; do
    ;;
    --x64-build)
    BUILD_FLAG="--x64-build"
    OUT_DIR="out/Release_GN_x64"
    shift
    ;;
    --arm64-build)
    BUILD_FLAG="--arm64-build"
    OUT_DIR="out/Release_GN_arm64"
    shift
    ;;
    -h|--help)
    @@ -128,7 +131,7 @@ run_manual_build() {

    # Navigate to the src directory and build cefsimple
    cd "${CHROMIUM_DIR}/chromium/src"
    autoninja -C out/Release_GN_x64 cefsimple chrome_sandbox
    autoninja -C "${OUT_DIR}" cefsimple chrome_sandbox

    # Create a CEF binary distribution
    cd "${CEF_DIR}/tools"
  12. aleitner revised this gist Dec 15, 2023. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -163,9 +163,21 @@ export GN_DEFINES="is_official_build=true \
    ozone_platform_wayland=false \
    ozone_platform_drm=false"

    # Detect OS distribution and architecture
    OS_ID=""

    if command -v lsb_release >/dev/null; then
    OS_ID=$(lsb_release -si)
    elif [ -f "/etc/os-release" ]; then
    OS_ID=$(grep ^ID= /etc/os-release | cut -d'=' -f 2)
    else
    echo "Unable to detect OS distribution. Exiting..."
    exit 1
    fi

    # Install Ubuntu build dependencies using provided script.
    DEPS_SCRIPT="${BUILD_DIR}/install-build-deps.py"
    if [ ! -f "${DEPS_SCRIPT}" ]; then
    if [[ "$OS_ID" == "Ubuntu" ]] && [ ! -f "${DEPS_SCRIPT}" ]; then
    echo "Installing build dependencies..."
    curl 'https://chromium.googlesource.com/chromium/src/+/main/build/install-build-deps.py?format=TEXT' | base64 -d > "${DEPS_SCRIPT}"
    sudo python3 "${DEPS_SCRIPT}" --no-arm --no-chromeos-fonts --no-nacl
  13. aleitner revised this gist Dec 15, 2023. 1 changed file with 42 additions and 33 deletions.
    75 changes: 42 additions & 33 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,49 @@
    set -euo pipefail

    usage() {
    echo "Usage: $0 [--manual-build]"
    echo " --manual-build Run the build process manually without automatic tools."
    echo "Usage: $0 [--manual-build] [--x64-build|--arm64-build]"
    echo " --manual-build Run the build process manually without automatic tools."
    echo " --x64-build Perform an x64 build (default)."
    echo " --arm64-build Perform an ARM64 cross-compile build."
    exit 1
    }

    # Initialize default values
    MANUAL_BUILD=false
    BUILD_FLAG="--x64-build" # Set the default build flag to x64

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    case "$1" in
    --manual-build)
    MANUAL_BUILD=true
    shift
    ;;
    --x64-build)
    BUILD_FLAG="--x64-build"
    shift
    ;;
    --arm64-build)
    BUILD_FLAG="--arm64-build"
    shift
    ;;
    -h|--help)
    usage
    ;;
    *)
    echo "Unknown argument: $1"
    usage
    ;;
    esac
    done

    # Check if we are in an x64 environment for non-cross-compile builds
    ARCH=$(uname -m)
    if [[ "${BUILD_FLAG}" == "--x64-build" && "${ARCH}" != "x86_64" ]]; then
    echo "The default x64 build can only be run in an x64 environment."
    exit 1
    fi

    # Define the build directory and ensure it exists.
    BUILD_DIR="${HOME}/code"
    AUTOMATE_DIR="${BUILD_DIR}/automate"
    @@ -21,23 +59,6 @@ mkdir -p ${AUTOMATE_DIR}
    # Define the release branch number.
    RELEASE_BRANCH="6045"

    # Determine the correct build flag based on the architecture.
    ARCH=$(uname -m)
    BUILD_FLAG=""

    case "${ARCH}" in
    "x86_64")
    BUILD_FLAG="--x64-build"
    ;;
    "aarch64")
    BUILD_FLAG="--arm64-build"
    ;;
    *)
    echo "Unsupported architecture: ${ARCH}. Exiting..."
    exit 1
    ;;
    esac

    # Process command-line arguments
    while [[ $# -gt 0 ]]; do
    case "$1" in
    @@ -119,7 +140,7 @@ run_manual_build() {

    # is_debug: Indicates whether to perform a debug build. Set to false for a release build.
    # chrome_pgo_phase: Controls Profile-Guided Optimization. Set to 0 to disable.
    # use_sysroot: Determines whether the build uses the Chromium-provided sysroot or locally installed packages. Usually set to true to use Chromium's sysroot.
    # use_sysroot: Determines whether the build uses the Chromium-provided sysroot or locally installed packages. Usually set to true to use Chromium's sysroot. Must be set to false if the build target is cefclient
    # symbol_level: Sets the level of debug symbols. 1 is the minimum level for backtrace symbols.
    # is_cfi: Enables or disables Control Flow Integrity checks. Set to false to disable.
    # use_thin_lto: Enables or disables Thin Link Time Optimization. Set to false to disable.
    @@ -142,21 +163,9 @@ export GN_DEFINES="is_official_build=true \
    ozone_platform_wayland=false \
    ozone_platform_drm=false"

    # Detect OS distribution and architecture
    OS_ID=""

    if command -v lsb_release >/dev/null; then
    OS_ID=$(lsb_release -si)
    elif [ -f "/etc/os-release" ]; then
    OS_ID=$(grep ^ID= /etc/os-release | cut -d'=' -f 2)
    else
    echo "Unable to detect OS distribution. Exiting..."
    exit 1
    fi

    # Install Ubuntu build dependencies using provided script.
    DEPS_SCRIPT="${BUILD_DIR}/install-build-deps.py"
    if [[ "$OS_ID" == "Ubuntu" ]] && [ ! -f "${DEPS_SCRIPT}" ]; then
    if [ ! -f "${DEPS_SCRIPT}" ]; then
    echo "Installing build dependencies..."
    curl 'https://chromium.googlesource.com/chromium/src/+/main/build/install-build-deps.py?format=TEXT' | base64 -d > "${DEPS_SCRIPT}"
    sudo python3 "${DEPS_SCRIPT}" --no-arm --no-chromeos-fonts --no-nacl
  14. aleitner revised this gist Dec 5, 2023. 1 changed file with 30 additions and 18 deletions.
    48 changes: 30 additions & 18 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,12 @@
    #!/usr/bin/env bash

    set -e
    set -euo pipefail

    usage() {
    echo "Usage: $0 [--manual-build]"
    echo " --manual-build Run the build process manually without automatic tools."
    exit 1
    }

    # Define the build directory and ensure it exists.
    BUILD_DIR="${HOME}/code"
    @@ -33,19 +39,35 @@ case "${ARCH}" in
    esac

    # Process command-line arguments
    MANUAL_BUILD=false
    for arg in "$@"; do
    case $arg in
    while [[ $# -gt 0 ]]; do
    case "$1" in
    --manual-build)
    MANUAL_BUILD=true
    shift # Remove --manual-build from processing
    shift
    ;;
    -h|--help)
    usage
    ;;
    *)
    # Unknown option
    echo "Unknown argument: $1"
    usage
    ;;
    esac
    done

    copy_distribution_to_opt() {
    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r "${1}"/* /opt/cef/

    pushd /opt/cef
    for file in Resources/*; do
    ln -s "../${file}" Release/
    done
    popd
    }


    # Function to run the build command
    run_build() {
    echo "Running the automate build script..."
    @@ -62,12 +84,7 @@ run_build() {
    --distrib-subdir=libcef \
    ${BUILD_FLAG}

    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef/* /opt/cef/

    cd /opt/cef
    for file in Resources/*; do ln -s "../$file" Release/; done
    copy_distribution_to_opt "${CEF_DIR}/binary_distrib/libcef"
    }

    # Function to run the script to build manually
    @@ -97,12 +114,7 @@ run_manual_build() {
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --distrib-subdir=libcef ${BUILD_FLAG}

    # Copy distribution to /opt/cef
    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef_minimal/* /opt/cef/

    cd /opt/cef
    for file in Resources/*; do ln -s "../$file" Release/; done
    copy_distribution_to_opt "${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef_minimal"
    }

    # is_debug: Indicates whether to perform a debug build. Set to false for a release build.
  15. aleitner revised this gist Dec 5, 2023. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -126,9 +126,9 @@ export GN_DEFINES="is_official_build=true \
    use_ozone=true \
    ozone_auto_platforms=false \
    ozone_platform_headless=true \
    ozone_platform_x11 = false \
    ozone_platform_wayland = false \
    ozone_platform_drm = false"
    ozone_platform_x11=false \
    ozone_platform_wayland=false \
    ozone_platform_drm=false"

    # Detect OS distribution and architecture
    OS_ID=""
  16. aleitner revised this gist Dec 5, 2023. 1 changed file with 42 additions and 55 deletions.
    97 changes: 42 additions & 55 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,6 @@

    set -e

    ARCH=$(uname -m)

    # Define the build directory and ensure it exists.
    BUILD_DIR="${HOME}/code"
    AUTOMATE_DIR="${BUILD_DIR}/automate"
    @@ -17,10 +15,36 @@ mkdir -p ${AUTOMATE_DIR}
    # Define the release branch number.
    RELEASE_BRANCH="6045"

    # Variable to hold the build flag
    # Determine the correct build flag based on the architecture.
    ARCH=$(uname -m)
    BUILD_FLAG=""

    case "${ARCH}" in
    "x86_64")
    BUILD_FLAG="--x64-build"
    ;;
    "aarch64")
    BUILD_FLAG="--arm64-build"
    ;;
    *)
    echo "Unsupported architecture: ${ARCH}. Exiting..."
    exit 1
    ;;
    esac

    # Process command-line arguments
    MANUAL_BUILD=false
    for arg in "$@"; do
    case $arg in
    --manual-build)
    MANUAL_BUILD=true
    shift # Remove --manual-build from processing
    ;;
    *)
    # Unknown option
    ;;
    esac
    done

    # Function to run the build command
    run_build() {
    @@ -81,33 +105,6 @@ run_manual_build() {
    for file in Resources/*; do ln -s "../$file" Release/; done
    }

    # Process command-line arguments
    for arg in "$@"; do
    case $arg in
    --manual-build)
    MANUAL_BUILD=true
    shift # Remove --manual-build from processing
    ;;
    *)
    # Unknown option
    ;;
    esac
    done

    # Determine the correct build flag based on the architecture.
    case "${ARCH}" in
    "x86_64")
    BUILD_FLAG="--x64-build"
    ;;
    "aarch64")
    BUILD_FLAG="--arm64-build"
    ;;
    *)
    echo "Unsupported architecture: ${ARCH}. Exiting..."
    exit 1
    ;;
    esac

    # is_debug: Indicates whether to perform a debug build. Set to false for a release build.
    # chrome_pgo_phase: Controls Profile-Guided Optimization. Set to 0 to disable.
    # use_sysroot: Determines whether the build uses the Chromium-provided sysroot or locally installed packages. Usually set to true to use Chromium's sysroot.
    @@ -117,31 +114,21 @@ esac
    # use_vaapi: Determines whether to use the Video Acceleration API. Set to false to disable when building for headless environments.
    # use_allocator: Specifies which memory allocator to use. 'none' defers to the system's C library allocator.
    # ozone_platform_headless: Enables the headless Ozone platform which doesn't require display server dependencies. Set to true for headless builds.
    # ozone_platform_x11: Enables or disables the X11 Ozone platform. Set to false to disable X11 support.
    # ozone_platform_wayland: Enables or disables the Wayland Ozone platform. Set to false to disable Wayland support.
    # ozone_platform_cast: Enables or disables the Cast Ozone platform. Set to false if not required.
    # ozone_platform_drm: Enables or disables the DRM/KMS (Direct Rendering Manager/Kernel Mode Setting) Ozone platform. Set to false to disable in headless builds.
    # ozone_platform_flatland: Enables or disables the Flatland Ozone platform. Set to false if not applicable or not required.
    # ozone_platform_scenic: Enables or disables the Scenic Ozone platform. Set to false if not applicable or not required.
    GN_DEFINES="use_ozone=true \
    is_official_build=true \
    is_debug=false \
    chrome_pgo_phase=0 \
    use_sysroot=true \
    symbol_level=1 \
    is_cfi=false \
    use_thin_lto=false \
    use_vaapi=false \
    use_allocator=none \
    ozone_auto_platforms=false \
    ozone_platform=headless \
    ozone_platform_headless=true \
    ozone_platform_x11=false \
    ozone_platform_wayland=false \
    ozone_platform_cast=false \
    ozone_platform_drm=false \
    ozone_platform_flatland=false \
    ozone_platform_scenic=false"
    export GN_DEFINES="is_official_build=true \
    is_debug=false \
    chrome_pgo_phase=0 \
    use_sysroot=true \
    symbol_level=1 \
    is_cfi=false \
    use_thin_lto=false \
    use_vaapi=false \
    use_allocator=none \
    use_ozone=true \
    ozone_auto_platforms=false \
    ozone_platform_headless=true \
    ozone_platform_x11 = false \
    ozone_platform_wayland = false \
    ozone_platform_drm = false"

    # Detect OS distribution and architecture
    OS_ID=""
  17. aleitner revised this gist Dec 5, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -133,7 +133,8 @@ GN_DEFINES="use_ozone=true \
    use_thin_lto=false \
    use_vaapi=false \
    use_allocator=none \
    ozone_auto_platforms=false
    ozone_auto_platforms=false \
    ozone_platform=headless \
    ozone_platform_headless=true \
    ozone_platform_x11=false \
    ozone_platform_wayland=false \
  18. aleitner revised this gist Dec 4, 2023. 1 changed file with 29 additions and 14 deletions.
    43 changes: 29 additions & 14 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -108,24 +108,39 @@ case "${ARCH}" in
    ;;
    esac

    # is_debug: Indicates whether we are performing a debug build. Set to false for a release build.
    # is_debug: Indicates whether to perform a debug build. Set to false for a release build.
    # chrome_pgo_phase: Controls Profile-Guided Optimization. Set to 0 to disable.
    # use_sysroot: Determines whether the build uses the provided sysroot or locally installed packages. Set to false to use local packages.
    # symbol_level: Sets the level of debug symbols. 1 is the minimum level.
    # use_sysroot: Determines whether the build uses the Chromium-provided sysroot or locally installed packages. Usually set to true to use Chromium's sysroot.
    # symbol_level: Sets the level of debug symbols. 1 is the minimum level for backtrace symbols.
    # is_cfi: Enables or disables Control Flow Integrity checks. Set to false to disable.
    # use_thin_lto: Enables or disables Thin Link Time Optimization. Set to false to disable.
    # use_vaapi: Determines whether to use the Video Acceleration API. Set to false to disable.
    # use_vaapi: Determines whether to use the Video Acceleration API. Set to false to disable when building for headless environments.
    # use_allocator: Specifies which memory allocator to use. 'none' defers to the system's C library allocator.
    GN_DEFINES="use_ozone=true
    is_official_build=true
    is_debug=false
    chrome_pgo_phase=0
    use_sysroot=true
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
    use_vaapi=false
    use_allocator=none"
    # ozone_platform_headless: Enables the headless Ozone platform which doesn't require display server dependencies. Set to true for headless builds.
    # ozone_platform_x11: Enables or disables the X11 Ozone platform. Set to false to disable X11 support.
    # ozone_platform_wayland: Enables or disables the Wayland Ozone platform. Set to false to disable Wayland support.
    # ozone_platform_cast: Enables or disables the Cast Ozone platform. Set to false if not required.
    # ozone_platform_drm: Enables or disables the DRM/KMS (Direct Rendering Manager/Kernel Mode Setting) Ozone platform. Set to false to disable in headless builds.
    # ozone_platform_flatland: Enables or disables the Flatland Ozone platform. Set to false if not applicable or not required.
    # ozone_platform_scenic: Enables or disables the Scenic Ozone platform. Set to false if not applicable or not required.
    GN_DEFINES="use_ozone=true \
    is_official_build=true \
    is_debug=false \
    chrome_pgo_phase=0 \
    use_sysroot=true \
    symbol_level=1 \
    is_cfi=false \
    use_thin_lto=false \
    use_vaapi=false \
    use_allocator=none \
    ozone_auto_platforms=false
    ozone_platform_headless=true \
    ozone_platform_x11=false \
    ozone_platform_wayland=false \
    ozone_platform_cast=false \
    ozone_platform_drm=false \
    ozone_platform_flatland=false \
    ozone_platform_scenic=false"

    # Detect OS distribution and architecture
    OS_ID=""
  19. aleitner revised this gist Dec 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -120,7 +120,7 @@ GN_DEFINES="use_ozone=true
    is_official_build=true
    is_debug=false
    chrome_pgo_phase=0
    use_sysroot=false
    use_sysroot=true
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
  20. aleitner revised this gist Dec 4, 2023. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -120,11 +120,12 @@ GN_DEFINES="use_ozone=true
    is_official_build=true
    is_debug=false
    chrome_pgo_phase=0
    use_sysroot=true
    use_sysroot=false
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
    use_vaapi=false "
    use_vaapi=false
    use_allocator=none"

    # Detect OS distribution and architecture
    OS_ID=""
  21. aleitner revised this gist Dec 4, 2023. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -34,13 +34,16 @@ run_build() {
    --no-debug-build \
    --no-distrib-docs \
    --no-distrib-archive \
    --build-target=cefclient \
    --build-target="cefclient chrome_sandbox"\
    --distrib-subdir=libcef \
    ${BUILD_FLAG}

    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef/* /opt/cef/

    cd /opt/cef
    for file in Resources/*; do ln -s "../$file" Release/; done
    }

    # Function to run the script to build manually
    @@ -73,6 +76,9 @@ run_manual_build() {
    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef_minimal/* /opt/cef/

    cd /opt/cef
    for file in Resources/*; do ln -s "../$file" Release/; done
    }

    # Process command-line arguments
  22. aleitner revised this gist Dec 4, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -67,12 +67,12 @@ run_manual_build() {

    # Create a CEF binary distribution
    cd "${CEF_DIR}/tools"
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --distrib-subdir=libcef --distrib-subdir-suffix="" ${BUILD_FLAG}
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --distrib-subdir=libcef ${BUILD_FLAG}

    # Copy distribution to /opt/cef
    rm -rf /opt/cef
    mkdir -p /opt/cef
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef/* /opt/cef/
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef_minimal/* /opt/cef/
    }

    # Process command-line arguments
  23. aleitner revised this gist Dec 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -67,7 +67,7 @@ run_manual_build() {

    # Create a CEF binary distribution
    cd "${CEF_DIR}/tools"
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --x64-build --distrib-subdir=libcef
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --distrib-subdir=libcef --distrib-subdir-suffix="" ${BUILD_FLAG}

    # Copy distribution to /opt/cef
    rm -rf /opt/cef
  24. aleitner revised this gist Dec 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,7 @@ run_manual_build() {

    # Navigate to the src directory and build cefsimple
    cd "${CHROMIUM_DIR}/chromium/src"
    autoninja -C out/Release_GN_x64 cefclient
    autoninja -C out/Release_GN_x64 cefsimple chrome_sandbox

    # Create a CEF binary distribution
    cd "${CEF_DIR}/tools"
  25. aleitner revised this gist Dec 4, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -63,11 +63,11 @@ run_manual_build() {

    # Navigate to the src directory and build cefsimple
    cd "${CHROMIUM_DIR}/chromium/src"
    autoninja -C out/Release_GN_x64 cefsimple
    autoninja -C out/Release_GN_x64 cefclient

    # Create a CEF binary distribution
    cd "${CEF_DIR}/tools"
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --x64-build --output-dir=libcef
    ./make_distrib.sh --ninja-build --no-symbols --no-docs --no-archive --minimal --x64-build --distrib-subdir=libcef

    # Copy distribution to /opt/cef
    rm -rf /opt/cef
  26. aleitner revised this gist Dec 1, 2023. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -118,8 +118,7 @@ use_sysroot=true
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
    use_vaapi=false
    use_allocator=none"
    use_vaapi=false "

    # Detect OS distribution and architecture
    OS_ID=""
  27. aleitner revised this gist Dec 1, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ ARCH=$(uname -m)
    BUILD_DIR="${HOME}/code"
    AUTOMATE_DIR="${BUILD_DIR}/automate"
    CHROMIUM_DIR="${BUILD_DIR}/chromium_git"
    CEF_DIR="${CHROMIUM_DIR}/chromium/src/cef"

    # Ensure the build and automate directories exist.
    mkdir -p ${BUILD_DIR}
  28. aleitner revised this gist Dec 1, 2023. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -109,16 +109,16 @@ esac
    # use_thin_lto: Enables or disables Thin Link Time Optimization. Set to false to disable.
    # use_vaapi: Determines whether to use the Video Acceleration API. Set to false to disable.
    # use_allocator: Specifies which memory allocator to use. 'none' defers to the system's C library allocator.
    GN_DEFINES="use_ozone=true
    is_official_build=true
    is_debug=false
    chrome_pgo_phase=0
    use_sysroot=false
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
    use_vaapi=false
    use_allocator=none"
    GN_DEFINES="use_ozone=true
    is_official_build=true
    is_debug=false
    chrome_pgo_phase=0
    use_sysroot=true
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
    use_vaapi=false
    use_allocator=none"

    # Detect OS distribution and architecture
    OS_ID=""
  29. aleitner revised this gist Dec 1, 2023. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -109,15 +109,15 @@ esac
    # use_thin_lto: Enables or disables Thin Link Time Optimization. Set to false to disable.
    # use_vaapi: Determines whether to use the Video Acceleration API. Set to false to disable.
    # use_allocator: Specifies which memory allocator to use. 'none' defers to the system's C library allocator.
    GN_DEFINES="use_ozone=true \
    is_official_build=true \
    is_debug=false \
    chrome_pgo_phase=0 \
    use_sysroot=false \
    symbol_level=1 \
    is_cfi=false \
    use_thin_lto=false \
    use_vaapi=false \
    GN_DEFINES="use_ozone=true
    is_official_build=true
    is_debug=false
    chrome_pgo_phase=0
    use_sysroot=false
    symbol_level=1
    is_cfi=false
    use_thin_lto=false
    use_vaapi=false
    use_allocator=none"

    # Detect OS distribution and architecture
  30. aleitner revised this gist Dec 1, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -42,8 +42,8 @@ run_build() {
    cp -r ${CHROMIUM_DIR}/chromium/src/cef/binary_distrib/libcef/* /opt/cef/
    }

    # Function to run the script without building
    run_no_build() {
    # Function to run the script to build manually
    run_manual_build() {
    echo "Running the automate script without building..."
    python3 "${AUTOMATE_SCRIPT}" \
    --download-dir="${CHROMIUM_DIR}" \