Commit aa26bd51 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Add build script

parent 8771aa91
Pipeline #149633 passed with stages
in 460 minutes and 39 seconds
......@@ -23,142 +23,37 @@ build-docker:
- docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:latest ${CI_PROJECT_DIR}
- docker push $CONTAINER_IMAGE:latest
build-bromite-arm:
.build-bromite:
image: $CONTAINER_IMAGE
stage: build-arm
tags:
- build-browser
artifacts:
name: "$CI_JOB_NAME"
paths:
- apks/*
after_script:
- $CI_PROJECT_DIR/build.sh -c
build-bromite-arm:
stage: build-arm
extends: .build-bromite
script:
- cd ${CHROMIUM_DIR}
- if [ ! -f .gclient ] ; then echo ">> [$(date)] Init project" ; fetch --nohooks android ; fi
- mkdir -p ${CI_PROJECT_DIR}/apks
- cd src
- git reset --hard && git clean -xfdf
- if [ -n ${CHROMIUM_VERSION} ] ; then CHROMIUM_VERSION=$(head -n 1 ${CI_PROJECT_DIR}/CHANGELOG.md | sed 's/# \(.*\)/\1/') ; export CHROMIUM_VERSION ; fi
- echo ">> [$(date)] Use Chromium v${CHROMIUM_VERSION}"
- git fetch --tags
- git checkout tags/${CHROMIUM_VERSION}
- echo ">> [$(date)] Install dependencies"
- build/install-build-deps-android.sh
- gclient sync --with_branch_heads --with_tags
- echo ">> [$(date)] Apply Bromite and /e/ patches"
- mv ${CI_PROJECT_DIR}/build/patches/e/* ${CI_PROJECT_DIR}/build/patches/
- PATCHES_LIST=$(cat ${CI_PROJECT_DIR}/build/bromite_patches_list.txt ${CI_PROJECT_DIR}/build/e_patches_list.txt)
- for file in $PATCHES_LIST; do echo " -> Apply $file"; git apply ${CI_PROJECT_DIR}/build/patches/$file; echo " "; done
- gclient runhooks
- echo ">> [$(date)] Build for arm"
- gn gen --args="$(cat ${CI_PROJECT_DIR}/build/GN_ARGS) target_cpu=\"arm\" " out/${CI_JOB_ID}_arm
- autoninja -C out/${CI_JOB_ID}_arm chrome_public_apk system_webview_apk
- cp out/${CI_JOB_ID}_arm/apks/ChromePublic.apk ${CI_PROJECT_DIR}/apks/ChromePublic_arm.apk
- cp out/${CI_JOB_ID}_arm/apks/SystemWebView.apk ${CI_PROJECT_DIR}/apks/SystemWebView_arm.apk
- echo ">> [$(date)] Clean"
- git reset --hard && git clean -xfdf
- $CI_PROJECT_DIR/build.sh -a arm
build-bromite-arm64:
image: $CONTAINER_IMAGE
stage: build-arm64
tags:
- build-browser
artifacts:
name: "$CI_JOB_NAME"
paths:
- apks/*
extends: .build-bromite
script:
- cd ${CHROMIUM_DIR}
- if [ ! -f .gclient ] ; then echo ">> [$(date)] Init project" ; fetch --nohooks android ; fi
- mkdir -p ${CI_PROJECT_DIR}/apks
- cd src
- git reset --hard && git clean -xfdf
- if [ -n ${CHROMIUM_VERSION} ] ; then CHROMIUM_VERSION=$(head -n 1 ${CI_PROJECT_DIR}/CHANGELOG.md | sed 's/# \(.*\)/\1/') ; export CHROMIUM_VERSION ; fi
- echo ">> [$(date)] Use Chromium v${CHROMIUM_VERSION}"
- git fetch --tags
- git checkout tags/${CHROMIUM_VERSION}
- echo ">> [$(date)] Install dependencies"
- build/install-build-deps-android.sh
- gclient sync --with_branch_heads --with_tags
- echo ">> [$(date)] Apply Bromite and /e/ patches"
- mv ${CI_PROJECT_DIR}/build/patches/e/* ${CI_PROJECT_DIR}/build/patches/
- PATCHES_LIST=$(cat ${CI_PROJECT_DIR}/build/bromite_patches_list.txt ${CI_PROJECT_DIR}/build/e_patches_list.txt)
- for file in $PATCHES_LIST; do echo " -> Apply $file"; git apply -v ${CI_PROJECT_DIR}/build/patches/$file; echo " "; done
- gclient runhooks
- echo ">> [$(date)] Build for arm64"
- gn gen --args="$(cat ${CI_PROJECT_DIR}/build/GN_ARGS) target_cpu=\"arm64\" " out/${CI_JOB_ID}_arm64
- autoninja -C out/${CI_JOB_ID}_arm64 chrome_public_apk system_webview_apk
- cp out/${CI_JOB_ID}_arm64/apks/ChromePublic.apk ${CI_PROJECT_DIR}/apks/ChromePublic_arm64.apk
- cp out/${CI_JOB_ID}_arm64/apks/SystemWebView.apk ${CI_PROJECT_DIR}/apks/SystemWebView_arm64.apk
- echo ">> [$(date)] Clean"
- git reset --hard && git clean -xfdf
- $CI_PROJECT_DIR/build.sh -a arm64
build-bromite-x86:
image: $CONTAINER_IMAGE
stage: build-x86
tags:
- build-browser
artifacts:
name: "$CI_JOB_NAME"
paths:
- apks/*
extends: .build-bromite
script:
- cd ${CHROMIUM_DIR}
- if [ ! -f .gclient ] ; then echo ">> [$(date)] Init project" ; fetch --nohooks android ; fi
- mkdir -p ${CI_PROJECT_DIR}/apks
- cd src
- git reset --hard && git clean -xfdf
- if [ -n ${CHROMIUM_VERSION} ] ; then CHROMIUM_VERSION=$(head -n 1 ${CI_PROJECT_DIR}/CHANGELOG.md | sed 's/# \(.*\)/\1/') ; export CHROMIUM_VERSION ; fi
- echo ">> [$(date)] Use Chromium v${CHROMIUM_VERSION}"
- git fetch --tags
- git checkout tags/${CHROMIUM_VERSION}
- echo ">> [$(date)] Install dependencies"
- build/install-build-deps-android.sh
- gclient sync --with_branch_heads --with_tags
- echo ">> [$(date)] Apply Bromite and /e/ patches"
- mv ${CI_PROJECT_DIR}/build/patches/e/* ${CI_PROJECT_DIR}/build/patches/
- PATCHES_LIST=$(cat ${CI_PROJECT_DIR}/build/bromite_patches_list.txt ${CI_PROJECT_DIR}/build/e_patches_list.txt)
- for file in $PATCHES_LIST; do echo " -> Apply $file"; git apply -v ${CI_PROJECT_DIR}/build/patches/$file; echo " "; done
- gclient runhooks
- echo ">> [$(date)] Build for x86"
- gn gen --args="$(cat ${CI_PROJECT_DIR}/build/GN_ARGS) target_cpu=\"x86\" " out/${CI_JOB_ID}_x86
- autoninja -C out/${CI_JOB_ID}_x86 chrome_public_apk system_webview_apk
- cp out/${CI_JOB_ID}_x86/apks/ChromePublic.apk ${CI_PROJECT_DIR}/apks/ChromePublic_x86.apk
- cp out/${CI_JOB_ID}_x86/apks/SystemWebView.apk ${CI_PROJECT_DIR}/apks/SystemWebView_x86.apk
- echo ">> [$(date)] Clean"
- git reset --hard && git clean -xfdf
- $CI_PROJECT_DIR/build.sh -a x86
build-bromite-x64:
image: $CONTAINER_IMAGE
stage: build-x64
tags:
- build-browser
artifacts:
name: "$CI_JOB_NAME"
paths:
- apks/*
extends: .build-bromite
script:
- cd ${CHROMIUM_DIR}
- if [ ! -f .gclient ] ; then echo ">> [$(date)] Init project" ; fetch --nohooks android ; fi
- mkdir -p ${CI_PROJECT_DIR}/apks
- cd src
- git reset --hard && git clean -xfdf
- if [ -n ${CHROMIUM_VERSION} ] ; then CHROMIUM_VERSION=$(head -n 1 ${CI_PROJECT_DIR}/CHANGELOG.md | sed 's/# \(.*\)/\1/') ; export CHROMIUM_VERSION ; fi
- echo ">> [$(date)] Use Chromium v${CHROMIUM_VERSION}"
- git fetch --tags
- git checkout tags/${CHROMIUM_VERSION}
- echo ">> [$(date)] Install dependencies"
- build/install-build-deps-android.sh
- gclient sync --with_branch_heads --with_tags
- echo ">> [$(date)] Apply Bromite and /e/ patches"
- mv ${CI_PROJECT_DIR}/build/patches/e/* ${CI_PROJECT_DIR}/build/patches/
- PATCHES_LIST=$(cat ${CI_PROJECT_DIR}/build/bromite_patches_list.txt ${CI_PROJECT_DIR}/build/e_patches_list.txt)
- for file in $PATCHES_LIST; do echo " -> Apply $file"; git apply -v ${CI_PROJECT_DIR}/build/patches/$file; echo " "; done
- gclient runhooks
- echo ">> [$(date)] Build for x64"
- gn gen --args="$(cat ${CI_PROJECT_DIR}/build/GN_ARGS) target_cpu=\"x64\" " out/${CI_JOB_ID}_x64
- autoninja -C out/${CI_JOB_ID}_x64 chrome_public_apk system_webview_apk
- cp out/${CI_JOB_ID}_x64/apks/ChromePublic.apk ${CI_PROJECT_DIR}/apks/ChromePublic_x64.apk
- cp out/${CI_JOB_ID}_x64/apks/SystemWebView.apk ${CI_PROJECT_DIR}/apks/SystemWebView_x64.apk
- echo ">> [$(date)] Clean"
- git reset --hard && git clean -xfdf
- $CI_PROJECT_DIR/build.sh -a x64
#!/bin/bash -e
CHROMIUM_DIR="${CHROMIUM_DIR:-/srv/chromium}"
ROOT_DIR=$(dirname "$(readlink -f "$0")")
BUILDID="${CI_JOB_ID:-$(date +%s)}"
ARCH=arm
function usage() {
cat << EOT
usage $0 [-hac]
OPTIONS
-h show this usage
-a target build archictecture (default: arm)
-c clean chromium repository
EOT
}
function init() {
cd "${CHROMIUM_DIR}"
if [ ! -f .gclient ]; then
echo ">> [$(date)] Init project"
fetch --nohooks android
fi
mkdir -p "${ROOT_DIR}/apks"
clean
cd "${CHROMIUM_DIR}/src"
}
function checkout() {
if [ -z "${CHROMIUM_VERSION}" ] ; then
CHROMIUM_VERSION=$(head -n 1 "${ROOT_DIR}/CHANGELOG.md" | sed 's/# \(.*\)/\1/')
export CHROMIUM_VERSION
fi
echo ">> [$(date)] Use Chromium v${CHROMIUM_VERSION}"
git fetch --tags
git checkout "tags/${CHROMIUM_VERSION}"
}
function clean() {
if [ -d "${CHROMIUM_DIR}/src" ]; then
cd "${CHROMIUM_DIR}/src"
git reset --hard && git clean -xfdf
fi
}
function setup() {
echo ">> [$(date)] Install dependencies"
build/install-build-deps-android.sh
gclient sync --with_branch_heads --with_tags
}
function patch() {
echo ">> [$(date)] Apply Bromite and /e/ patches"
mv "${ROOT_DIR}"/build/patches/e/* "${ROOT_DIR}"/build/patches/
PATCHES_LIST=$(cat "${ROOT_DIR}/build/bromite_patches_list.txt" "${ROOT_DIR}/build/e_patches_list.txt")
for file in $PATCHES_LIST; do
echo " -> Apply $file"
git apply "${ROOT_DIR}/build/patches/$file"
echo " "
done
gclient runhooks
}
function build() {
local out="out/${BUILDID}_${ARCH}"
echo ">> [$(date)] Build for ${ARCH}"
gn gen --args="$(cat "${ROOT_DIR}"/build/GN_ARGS) target_cpu=\"${ARCH}\" " "$out"
autoninja -C "$out" chrome_public_apk system_webview_apk
cp "$out/apks/ChromePublic.apk" "${ROOT_DIR}/apks/ChromePublic_$ARCH.apk"
cp "$out/apks/SystemWebView.apk" "${ROOT_DIR}/apks/SystemWebView_$ARCH.apk"
}
while getopts "ha:c" option; do
case $option in
a)
ARCH="$OPTARG"
;;
c)
clean
exit 0
;;
\?)
echo "wrong option."
usage
exit 1
;;
h)
usage
exit 0
;;
esac
done
shift $((OPTIND - 1))
init
checkout
setup
patch
build
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment