Merge work branch (#77)

- style workflow
- include armv6 debian buster
- correct RPATH for fedora
- cleanup
This commit is contained in:
Paulchen-Panther 2023-10-18 22:12:38 +02:00 committed by GitHub
parent 09048bf4f4
commit 1de37ceeff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 248 additions and 370 deletions

View File

@ -1,40 +0,0 @@
#!/bin/bash
# detect CI
if [ "$HOME" != "" ]; then
# GitHub Actions
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
CI_BUILD_DIR="$GITHUB_WORKSPACE"
else
# for executing in non ci environment
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
fi
function installAndUpgrade()
{
arr=("$@")
for i in "${arr[@]}";
do
list_output=`brew list --formula | grep $i`
outdated_output=`brew outdated | grep $i`
if [[ ! -z "$list_output" ]]; then
if [[ ! -z "$outdated_output" ]]; then
echo "Outdated package: ${outdated_output}"
brew unlink ${outdated_output}
brew upgrade $i
brew link --overwrite $i
fi
else
brew install $i
fi
done
}
# install osx deps for hyperion compile
if [[ $CI_NAME == 'osx' || $CI_NAME == 'darwin' ]]; then
echo "Install dependencies"
brew update
dependencies=("qt5" "python" "libusb" "cmake" "doxygen")
installAndUpgrade "${dependencies[@]}"
fi

View File

@ -1,42 +1,29 @@
#!/bin/bash
# detect CI
if [ "$HOME" != "" ]; then
# GitHub Actions
echo "Github Actions detected"
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
CI_BUILD_DIR="$GITHUB_WORKSPACE"
else
# for executing in non ci environment
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
fi
# set environment variables if not exists
[ -z "${BUILD_TYPE}" ] && BUILD_TYPE="Debug"
[ -z "${TARGET_ARCH}" ] && TARGET_ARCH="linux/amd64"
[ -z "${PLATFORM}" ] && PLATFORM="x11"
# Determine cmake build type; tag builds are Release, else Debug (-dev appends to platform)
if [[ $BUILD_SOURCEBRANCH == *"refs/tags"* || $GITHUB_REF == *"refs/tags"* ]]; then
if [[ $GITHUB_REF == *"refs/tags"* ]]; then
BUILD_TYPE=Release
else
PLATFORM=${PLATFORM}-dev
fi
echo "Platform: ${PLATFORM}, build type: ${BUILD_TYPE}, CI_NAME: $CI_NAME, docker image: ${DOCKER_IMAGE}, docker type: ${DOCKER_TAG}"
echo "Compile Hyperion on '${RUNNER_OS}' with build type '${BUILD_TYPE}' and platform '${PLATFORM}'"
# Build the package on osx or linux
if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then
echo "Compile Hyperion on OSX or Darwin"
# compile prepare
# Build the package on MacOS, Windows or Linux
if [[ "$RUNNER_OS" == 'macOS' ]]; then
mkdir build || exit 1
cd build
cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ../ || exit 2
make -j $(sysctl -n hw.ncpu) package || exit 3
cd ${CI_BUILD_DIR} && source /${CI_BUILD_DIR}/test/testrunner.sh || exit 4
cd ${GITHUB_WORKSPACE} && source /${GITHUB_WORKSPACE}/test/testrunner.sh || exit 4
exit 0;
exit 1 || { echo "---> Hyperion compilation failed! Abort"; exit 5; }
elif [[ $CI_NAME == *"mingw64_nt"* || "$CI_NAME" == 'windows_nt' ]]; then
echo "Compile Hyperion on Windows"
# compile prepare
elif [[ $RUNNER_OS == "Windows" ]]; then
echo "Number of Cores $NUMBER_OF_PROCESSORS"
mkdir build || exit 1
cd build
@ -44,17 +31,17 @@ elif [[ $CI_NAME == *"mingw64_nt"* || "$CI_NAME" == 'windows_nt' ]]; then
cmake --build . --target package --config "Release" -- -nologo -v:m -maxcpucount || exit 3
exit 0;
exit 1 || { echo "---> Hyperion compilation failed! Abort"; exit 5; }
elif [[ "$CI_NAME" == 'linux' ]]; then
echo "Compile Hyperion with DOCKER_IMAGE = ${DOCKER_IMAGE}, DOCKER_TAG = ${DOCKER_TAG}, ARCHITECTURE = ${ARCHITECTURE} and friendly name DOCKER_NAME = ${DOCKER_NAME}"
elif [[ "$RUNNER_OS" == 'Linux' ]]; then
echo "Docker arguments used: DOCKER_IMAGE=${DOCKER_IMAGE}, DOCKER_TAG=${DOCKER_TAG}, TARGET_ARCH=${TARGET_ARCH}"
# set GitHub Container Registry url
REGISTRY_URL="ghcr.io/hyperion-project/${DOCKER_IMAGE}"
# take ownership of deploy dir
mkdir ${CI_BUILD_DIR}/deploy
mkdir ${GITHUB_WORKSPACE}/deploy
# run docker
docker run --rm --platform=${ARCHITECTURE} \
-v "${CI_BUILD_DIR}/deploy:/deploy" \
-v "${CI_BUILD_DIR}:/source:ro" \
docker run --rm --platform=${TARGET_ARCH} \
-v "${GITHUB_WORKSPACE}/deploy:/deploy" \
-v "${GITHUB_WORKSPACE}:/source:ro" \
$REGISTRY_URL:$DOCKER_TAG \
/bin/bash -c "mkdir hyperion && cp -r source/. /hyperion &&
cd /hyperion && mkdir build && cd build &&
@ -67,5 +54,5 @@ elif [[ "$CI_NAME" == 'linux' ]]; then
exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 5; }
# overwrite file owner to current user
sudo chown -fR $(stat -c "%U:%G" ${CI_BUILD_DIR}/deploy) ${CI_BUILD_DIR}/deploy
sudo chown -fR $(stat -c "%U:%G" ${GITHUB_WORKSPACE}/deploy) ${GITHUB_WORKSPACE}/deploy
fi

View File

@ -49,20 +49,27 @@ jobs:
fail-fast: false
matrix:
os: [
{ distribution: ubuntu, codename: focal, description: Ubuntu 20.04 (Focal Fossa), },
{ distribution: ubuntu, codename: jammy, description: Ubuntu 22.04 (Jammy Jellyfish), },
{ distribution: ubuntu, codename: lunar, description: Ubuntu 23.04 (Lunar Lobster), },
{ distribution: ubuntu, codename: mantic, description: Ubuntu 23.10 (Mantic Minotaur), },
{ distribution: debian, codename: buster, description: Debian 10.x (Buster), },
{ distribution: debian, codename: bullseye, description: Debian 11.x (Bullseye), },
{ distribution: debian, codename: bookworm, description: Debian 12.x (Bookworm), },
{ distribution: debian, codename: trixie, description: Debian 13.x (Trixie), }
{ distribution: ubuntu, codename: focal, description: Ubuntu 20.04 (Focal Fossa) },
{ distribution: ubuntu, codename: jammy, description: Ubuntu 22.04 (Jammy Jellyfish) },
{ distribution: ubuntu, codename: lunar, description: Ubuntu 23.04 (Lunar Lobster) },
{ distribution: ubuntu, codename: mantic, description: Ubuntu 23.10 (Mantic Minotaur) },
{ distribution: debian, codename: buster, description: Debian 10.x (Buster) },
{ distribution: debian, codename: bullseye, description: Debian 11.x (Bullseye) },
{ distribution: debian, codename: bookworm, description: Debian 12.x (Bookworm) },
{ distribution: debian, codename: trixie, description: Debian 13.x (Trixie) }
]
architecture: [
[ amd64, linux/amd64 ],
[ arm64, linux/arm64 ],
[ amd64, linux/amd64 ],
[ arm64, linux/arm64 ],
[ armhf, linux/arm/v7 ]
]
include:
- os: { distribution: debian, codename: bullseye, description: Debian 11.x (Bullseye) }
architecture: [ armel, linux/arm/v6 ]
- os: { distribution: debian, codename: bookworm, description: Debian 12.x (Bookworm) }
architecture: [ armel, linux/arm/v6 ]
- os: { distribution: debian, codename: trixie, description: Debian 13.x (Trixie) }
architecture: [ armel, linux/arm/v6 ]
steps:
- name: ⬇ Checkout

View File

@ -1,4 +1,4 @@
name: Clean artifacts
name: 🧹 Clean artifacts
# Run cleanup workflow at the end of every day
on:

View File

@ -1,4 +1,4 @@
name: "CodeQL"
name: 📊 CodeQL
on:
push:

View File

@ -13,7 +13,7 @@ jobs:
update_submodule:
name: 🔁 Update Submodule rpi_ws281x (Nightly build only)
if: ${{ github.repository == 'hyperion-project' && inputs.nightly }}
if: ${{ !startsWith(github.repository, 'hyperion-project') }}
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout
@ -55,7 +55,7 @@ jobs:
check:
name: 🔀 Compare local <-> nightly (Nightly build only)
needs: [update_submodule]
if: ${{ github.repository == 'hyperion-project' && inputs.nightly }}
if: ${{ !startsWith(github.repository, 'hyperion-project') }}
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout

View File

@ -1,208 +0,0 @@
name: Hyperion CI Build
on:
push:
branches:
- '**'
tags:
- '*'
jobs:
##################
##### Linux ######
##################
Linux:
name: 🐧 ${{ matrix.dockerName }}
runs-on: ubuntu-latest
strategy:
matrix:
dockerImage: [ x86_64, armv6l, armv7l, aarch64 ]
include:
- dockerImage: x86_64
dockerName: Debian Buster (x86_64)
platform: x11
- dockerImage: armv6l
dockerName: Debian Buster (Raspberry Pi v1 & ZERO)
platform: rpi
- dockerImage: armv7l
dockerName: Debian Buster (Raspberry Pi 2 & 3)
platform: rpi
- dockerImage: aarch64
dockerName: Debian Buster (Generic AARCH64)
platform: amlogic
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 👷 Build
env:
DOCKER_IMAGE: ${{ matrix.dockerImage }}
DOCKER_TAG: buster
DOCKER_NAME: ${{ matrix.dockerName }}
PLATFORM: ${{ matrix.platform }}
shell: bash
run: ./.ci/ci_build.sh
- name: 📦 Upload
if: startsWith(github.event.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
path: deploy/Hyperion-*
###################
###### macOS ######
###################
macOS:
name: 🍏 macOS
runs-on: macos-latest
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 🔧 Prepare
shell: bash
run: |
echo '::group::Install dependencies'
./.ci/ci_install.sh
echo '::endgroup::'
- name: 👷 Build
env:
PLATFORM: osx
shell: bash
run: ./.ci/ci_build.sh
- name: 📦 Upload
if: startsWith(github.event.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
path: build/Hyperion-*
#####################
###### Windows ######
#####################
windows:
name: 🪟 Windows
runs-on: windows-2022
env:
VCINSTALLDIR: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
QT_VERSION: 5.15.2
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 💾 Cache/Restore
uses: actions/cache@v3
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
key: ${{ runner.os }}-chocolatey
- name: 📥 Install OpenSSL, DirectX SDK, libjpeg-turbo
shell: powershell
run: |
choco install --no-progress openssl --version=1.1.1.2100 -y
choco install --no-progress directx-sdk -y
Invoke-WebRequest https://netcologne.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6-vc64.exe -OutFile libjpeg-turbo.exe -UserAgent NativeHost
.\libjpeg-turbo /S
- name: 📥 Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{env.QT_VERSION}}
target: 'desktop'
arch: 'win64_msvc2019_64'
cache: 'true'
cache-key-prefix: 'cache-qt-windows'
- name: 🛠️ Setup
shell: cmd
run: call "${{env.VCINSTALLDIR}}\Auxiliary\Build\vcvars64.bat"
- name: 👷 Build
env:
PLATFORM: windows
shell: bash
run: |
echo '::group::Build packages'
./.ci/ci_build.sh
echo '::endgroup::'
- name: 📦 Upload
if: startsWith(github.event.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
path: build/Hyperion-*
retention-days: 1
#####################################
###### Publish GitHub Releases ######
#####################################
github_publish:
name: 🚀 Publish GitHub Releases
if: startsWith(github.event.ref, 'refs/tags')
needs: [Linux, macOS, windows]
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
- name: 🔧 Prepare
run: |
echo '::group::Generate environment variables from .version and tag'
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "VERSION=$(tr -d '\n' < .version)" >> $GITHUB_ENV
echo '::endgroup::'
- name: 💾 Artifact download
uses: actions/download-artifact@v3.0.2
with:
path: artifacts
- name: 📦 Upload
uses: softprops/action-gh-release@v1
with:
name: Hyperion ${{ env.VERSION }}
tag_name: ${{ env.TAG }}
files: "artifacts/**"
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
###################################
###### APT reusable workflow ######
###################################
apt_build:
name: APT Build
if: startsWith(github.event.ref, 'refs/tags')
needs: [Linux, macOS, windows]
uses: ./.github/workflows/apt.yml
secrets: inherit
with:
nightly: false
publish: true
###################################
###### DNF reusable workflow ######
###################################
dnf_build:
name: DNF Build
if: startsWith(github.event.ref, 'refs/tags')
needs: [Linux, macOS, windows]
uses: ./.github/workflows/dnf.yml
secrets: inherit
with:
nightly: false
publish: true

View File

@ -1,13 +1,25 @@
name: Hyperion PR Build
name: Hyperion CI/PR Builds
run-name: |
${{ github.event_name == 'pull_request' && '📦 Generate artifacts for PR' || '' }}
${{ github.event_name == 'pull_request' && github.event.pull_request.number || '' }}
${{ github.event_name == 'pull_request' && '-' || '' }}
${{ github.event_name == 'push' && '🌱 Push Build -' || '' }}
${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.event.head_commit.message }}
on:
push:
branches:
- '**'
tags:
- '*'
pull_request:
branches:
- master
- 'master'
# Cancel running actions when a new action on the same PR is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
@ -22,10 +34,10 @@ jobs:
fail-fast: false
matrix:
os: [
{ description: Debian Buster (x86_64), platform: x11, architecture: linux/amd64 },
{ description: Debian Buster (Raspberry Pi v1 & ZERO), platform: rpi, architecture: linux/arm/v7 },
{ description: Debian Buster (Raspberry Pi 2 & 3), platform: rpi, architecture: linux/arm/v7 },
{ description: Debian Buster (Generic AARCH64), platform: amlogic, architecture: linux/arm64 }
{ description: Debian Buster (x86_64), platform: x11, architecture: [ amd64, linux/amd64 ] },
{ description: Debian Buster (Raspberry Pi v1 & ZERO), platform: rpi, architecture: [ armv6, linux/arm/v5 ] },
{ description: Debian Buster (Raspberry Pi 2/3/4), platform: rpi, architecture: [ armv7, linux/arm/v7 ] },
{ description: Debian Buster (Generic AARCH64), platform: amlogic, architecture: [ aarch64, linux/arm64 ] }
]
include:
- distribution: debian
@ -37,7 +49,8 @@ jobs:
with:
submodules: recursive
- name: 🔧 Prepare
- name: 🔧 Prepare PR
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo '::group::Append PR number to version'
@ -46,31 +59,27 @@ jobs:
echo '::endgroup::'
- name: 🛠️ Setup QEMU
if: ${{ matrix.os.architecture[0] != 'amd64' }}
uses: docker/setup-qemu-action@v3
- name: 👷 Build
shell: bash
run: |
echo '::group::Build Hyperion'
./.github/scripts/build.sh
echo '::endgroup::'
env:
DOCKER_IMAGE: ${{ matrix.distribution }}
DOCKER_TAG: ${{ matrix.codename }}
DOCKER_NAME: ${{ matrix.os.description }}
PLATFORM: ${{ matrix.os.platform }}
ARCHITECTURE: ${{ matrix.os.architecture }}
shell: bash
run: |
echo '::group::Build packages'
./.ci/ci_build.sh
echo '::endgroup::'
echo '::group::Collecting deployable artifacts'
mkdir -p ${{ matrix.dockerImage }}
mv deploy/*.tar.gz ${{ matrix.dockerImage }}
echo '::endgroup::'
TARGET_ARCH: ${{ matrix.os.architecture[1] }}
- name: 📦 Upload
if: ${{ startsWith(github.event.ref, 'refs/tags') || github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.dockerImage }}
path: ${{ matrix.dockerImage }}
name: ${{ github.event_name == 'pull_request' && matrix.os.architecture[0] || 'artifact' }}
path: ${{ github.event_name == 'pull_request' && 'deploy/*.tar.gz' || 'deploy/Hyperion-*' }}
######################
###### macOS #########
@ -85,7 +94,8 @@ jobs:
with:
submodules: recursive
- name: 🔧 Prepare
- name: 🔧 Prepare PR
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo '::group::Append PR number to version'
@ -93,29 +103,27 @@ jobs:
echo -n "+PR${{ github.event.pull_request.number }}" >> .version
echo '::endgroup::'
echo '::group::Install dependencies'
./.ci/ci_install.sh
echo '::endgroup::'
- name: 👷 Build
env:
PLATFORM: osx
shell: bash
run: |
echo '::group::Build packages'
./.ci/ci_build.sh
echo '::group::Update/Install dependencies'
brew update || true
brew install --overwrite qt5 libusb
brew link --overwrite --force qt5
echo '::endgroup::'
echo '::group::Collecting deployable artifacts'
mkdir -p macOS
mv build/*.dmg macOS
echo '::group::Build packages'
./.github/scripts/build.sh
echo '::endgroup::'
env:
PLATFORM: osx
- name: 📦 Upload
if: ${{ startsWith(github.event.ref, 'refs/tags') || github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: macOS
path: macOS
name: ${{ github.event_name == 'pull_request' && 'macOS' || 'artifact' }}
path: 'build/Hyperion-*'
######################
###### Windows #######
@ -133,7 +141,8 @@ jobs:
with:
submodules: recursive
- name: 🔧 Prepare
- name: 🔧 Prepare PR
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo '::group::Append PR number to version'
@ -169,21 +178,80 @@ jobs:
run: call "${{env.VCINSTALLDIR}}\Auxiliary\Build\vcvars64.bat"
- name: 👷 Build
env:
PLATFORM: windows
shell: bash
run: |
echo '::group::Build packages'
./.ci/ci_build.sh
echo '::endgroup::'
echo '::group::Collecting deployable artifacts'
mkdir -p windows
mv build/*.exe windows
./.github/scripts/build.sh
echo '::endgroup::'
env:
PLATFORM: windows
- name: 📦 Upload
if: ${{ startsWith(github.event.ref, 'refs/tags') || github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: windows
path: windows
name: ${{ github.event_name == 'pull_request' && 'windows' || 'artifact' }}
path: ${{ github.event_name == 'pull_request' && 'build/*.exe' || 'build/Hyperion-*' }}
#####################################
###### Publish GitHub Releases ######
#####################################
github_publish:
name: 🚀 Publish GitHub Releases
if: startsWith(github.event.ref, 'refs/tags')
needs: [Linux, macOS, windows]
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout
uses: actions/checkout@v4
- name: 🔧 Prepare
run: |
echo '::group::Generate environment variables from .version and tag'
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "VERSION=$(tr -d '\n' < .version)" >> $GITHUB_ENV
echo '::endgroup::'
- name: 💾 Artifact download
uses: actions/download-artifact@v3.0.2
with:
path: artifacts
- name: 📦 Upload
uses: softprops/action-gh-release@v1
with:
name: Hyperion ${{ env.VERSION }}
tag_name: ${{ env.TAG }}
files: "artifacts/**"
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
###################################
###### APT reusable workflow ######
###################################
apt_build:
name: APT Build
if: startsWith(github.event.ref, 'refs/tags')
needs: [Linux, macOS, windows]
uses: ./.github/workflows/apt.yml
secrets: inherit
with:
nightly: false
publish: true
###################################
###### DNF reusable workflow ######
###################################
dnf_build:
name: DNF Build
if: startsWith(github.event.ref, 'refs/tags')
needs: [Linux, macOS, windows]
uses: ./.github/workflows/dnf.yml
secrets: inherit
with:
nightly: false
publish: true

View File

@ -1,4 +1,5 @@
name: Release Actions
name: 🚀 Release Actions
run-name: 🚀 Let HyperBian create
on:
release:

View File

@ -489,7 +489,7 @@ if (ENABLE_DEPLOY_DEPENDENCIES AND UNIX AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--disable-new-dtags")
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN/../lib")
SET(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif ()

View File

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash
DOCKER="docker"
# Git repo url of Hyperion
@ -7,10 +7,9 @@ GIT_REPO_URL="https://github.com/hyperion-project/hyperion.ng.git"
REGISTRY_URL="ghcr.io/hyperion-project"
# cmake build type
BUILD_TYPE="Release"
# the docker image at GitHub Container Registry
BUILD_IMAGE="x86_64"
# the docker tag at GitHub Container Registry
BUILD_TAG="bullseye"
DISTRIBUTION="debian"
CODENAME="bullseye"
ARCHITECTURE="amd64"
# build packages (.deb .zip ...)
BUILD_PACKAGES=true
# packages string inserted to cmake cmd
@ -18,9 +17,9 @@ PACKAGES=""
# platform string inserted to cmake cmd
BUILD_PLATFORM=""
#Run build using GitHub code files
BUILD_LOCAL=0
BUILD_LOCAL=false
#Build from scratch
BUILD_INCREMENTAL=0
BUILD_INCREMENTAL=false
#Verbose output
_VERBOSE=0
#Additional args
@ -37,11 +36,7 @@ cd `dirname ${BASE_PATH}` > /dev/null
BASE_PATH=`pwd`;
popd > /dev/null
BASE_PATH=`pwd`;function log () {
if [[ $_V -eq 1 ]]; then
echo "$@"
fi
}
BASE_PATH=`pwd`;
set +e
${DOCKER} ps >/dev/null 2>&1
@ -62,7 +57,7 @@ function printHelp {
echo "########################################################
## A script to compile Hyperion inside a docker container
## Requires installed Docker: https://www.docker.com/
## Without arguments it will compile Hyperion for Debian Bullseye (x86_64) and uses Hyperion code from GitHub repository.
## Without arguments it will compile Hyperion for ${DISTRIBUTION}:${CODENAME}, ${ARCHITECTURE} architecture and uses Hyperion code from GitHub repository.
## For all images and tags currently available, see https://github.com/orgs/hyperion-project/packages
##
## Homepage: https://www.hyperion-project.org
@ -71,8 +66,8 @@ echo "########################################################
# These are possible arguments to modify the script behaviour with their default values
#
# docker-compile.sh -h, --help # Show this help message
# docker-compile.sh -i, --image # The docker image, e.g., x86_64, armv6l, armv7l, aarch64
# docker-compile.sh -t, --tag # The docker tag, e.g., buster, bullseye, bookworm
# docker-compile.sh -n, --name # The distribution's codename, e.g., buster, bullseye, bookworm, jammy, trixie, lunar, mantic; Note: for Fedora it is the version number
# docker-compile.sh -a, --architecture # The output architecture, e.g., amd64, arm64, arm/v7
# docker-compile.sh -b, --type # Release or Debug build
# docker-compile.sh -p, --packages # If true, build packages with CPack
# docker-compile.sh -l, --local # Run build using local code files
@ -80,7 +75,7 @@ echo "########################################################
# docker-compile.sh -f, --platform # cmake PLATFORM parameter, e.g. x11, amlogic-dev
# docker-compile.sh -v, --verbose # Run the script in verbose mode
# docker-compile.sh -- args # Additonal cmake arguments, e.g., -DHYPERION_LIGHT=ON
# More informations to docker tags at: https://github.com/Hyperion-Project/hyperion.docker-ci"
# More informations to docker containers available at: https://github.com/Hyperion-Project/hyperion.docker-ci"
}
function log () {
@ -89,20 +84,32 @@ function log () {
fi
}
function check_distribution () {
url=${REGISTRY_URL}/$1:${CODENAME}
log "Check for distribution at: $url"
if $($DOCKER buildx imagetools inspect "$url" 2>&1 | grep -q $2) ; then
rc=0
else
rc=1
fi
return $rc
}
echo "Compile Hyperion using a Docker container"
options=$(getopt -l "image:,tag:,type:,packages:,platform:,local,incremental,verbose,help" -o "i:t:b:p:f:lcvh" -a -- "$@")
options=$(getopt -l "architecture:,name:,type:,packages:,platform:,local,incremental,verbose,help" -o "a:n:b:p:f:lcvh" -a -- "$@")
eval set -- "$options"
while true
do
case $1 in
-i|--image)
-a|--architecture)
shift
BUILD_IMAGE=$1
ARCHITECTURE=`echo $1 | tr '[:upper:]' '[:lower:]'`
;;
-t|--tag)
-n|--name)
shift
BUILD_TAG=$1
CODENAME=`echo $1 | tr '[:upper:]' '[:lower:]'`
;;
-b|--type)
shift
@ -117,10 +124,10 @@ do
BUILD_PLATFORM=$1
;;
-l|--local)
BUILD_LOCAL=1
BUILD_LOCAL=true
;;
-c|--incremental)
BUILD_INCREMENTAL=1
-i|--incremental)
BUILD_INCREMENTAL=true
;;
-v|--verbose)
_VERBOSE=1
@ -148,7 +155,61 @@ if [[ ! -z ${BUILD_PLATFORM} ]]; then
PLATFORM="-DPLATFORM=${BUILD_PLATFORM}"
fi
echo "---> Initialize with IMAGE:TAG=${BUILD_IMAGE}:${BUILD_TAG}, BUILD_TYPE=${BUILD_TYPE}, BUILD_PACKAGES=${BUILD_PACKAGES}, PLATFORM=${BUILD_PLATFORM}, BUILD_LOCAL=${BUILD_LOCAL}, BUILD_INCREMENTAL=${BUILD_INCREMENTAL}"
PLATFORM_ARCHITECTURE="linux/"${ARCHITECTURE}
echo "---> Evaluate distribution for codename:${CODENAME} on platform architecture ${PLATFORM_ARCHITECTURE}"
DISTRIBUTION="debian"
if ! check_distribution ${DISTRIBUTION} ${PLATFORM_ARCHITECTURE} ; then
DISTRIBUTION="ubuntu"
if ! check_distribution ${DISTRIBUTION} ${PLATFORM_ARCHITECTURE} ; then
DISTRIBUTION="fedora"
if ! check_distribution ${DISTRIBUTION} ${PLATFORM_ARCHITECTURE} ; then
echo "No docker image found for a distribution with codename: ${CODENAME} on platform architecture ${PLATFORM_ARCHITECTURE}"
exit 1
fi
fi
fi
echo "---> Build with -> Distribution: ${DISTRIBUTION}, Codename: ${CODENAME}, Architecture: ${ARCHITECTURE}, Type: ${BUILD_TYPE}, Platform: ${BUILD_PLATFORM}, Build Packages: ${BUILD_PACKAGES}, Build local: ${BUILD_LOCAL}, Build incremental: ${BUILD_INCREMENTAL}"
# Determine the current architecture
CURRENT_ARCHITECTURE=`uname -m`
#Test if multiarchitecture setup, i.e. user-space is 32bit
if [ ${CURRENT_ARCHITECTURE} == "aarch64" ]; then
CURRENT_ARCHITECTURE="arm64"
USER_ARCHITECTURE=$CURRENT_ARCHITECTURE
IS_V7L=`cat /proc/$$/maps |grep -m1 -c v7l`
if [ $IS_V7L -ne 0 ]; then
USER_ARCHITECTURE="arm/v7"
else
IS_V6L=`cat /proc/$$/maps |grep -m1 -c v6l`
if [ $IS_V6L -ne 0 ]; then
USER_ARCHITECTURE="arm/v6"
fi
fi
if [ $ARCHITECTURE != $USER_ARCHITECTURE ]; then
log "Identified user space current architecture: $USER_ARCHITECTURE"
CURRENT_ARCHITECTURE=$USER_ARCHITECTURE
fi
else
CURRENT_ARCHITECTURE=${CURRENT_ARCHITECTURE//x86_/amd}
fi
log "Identified kernel current architecture: $CURRENT_ARCHITECTURE"
if [ $ARCHITECTURE != $CURRENT_ARCHITECTURE ]; then
echo "---> Build is not for the same architecturem, install emulation environment for ${PLATFORM_ARCHITECTURE}"
$DOCKER run --privileged --rm tonistiigi/binfmt --install "${PLATFORM_ARCHITECTURE}"
DOCKERRC=${?}
if [ ${DOCKERRC} == 0 ]; then
echo "---> Emulation environment installed sucessfully"
echo "---> You can uninstall it via following command: "docker run --privileged --rm tonistiigi/binfmt --uninstall ${PLATFORM_ARCHITECTURE}""
else
echo "---> Failed to install emulation environment"
exit 1
fi
fi
log "---> BASE_PATH = ${BASE_PATH}"
CODE_PATH=${BASE_PATH};
@ -163,9 +224,11 @@ git clone --recursive --depth 1 -q ${GIT_REPO_URL} ${CODE_PATH} || { echo "--->
fi
log "---> CODE_PATH = ${CODE_PATH}"
BUILD_DIR="build-${BUILD_IMAGE}-${BUILD_TAG}"
ARCHITECTURE_PATH=${ARCHITECTURE//\//_}
BUILD_DIR="build-${CODENAME}-${ARCHITECTURE_PATH}"
BUILD_PATH="${CODE_PATH}/${BUILD_DIR}"
DEPLOY_DIR="deploy/${BUILD_IMAGE}/${BUILD_TAG}"
DEPLOY_DIR="deploy/${CODENAME}/${ARCHITECTURE}"
DEPLOY_PATH="${CODE_PATH}/${DEPLOY_DIR}"
log "---> BUILD_DIR = ${BUILD_DIR}"
@ -178,7 +241,7 @@ sudo rm -fr "${DEPLOY_PATH}" >/dev/null 2>&1
mkdir -p "${DEPLOY_PATH}" >/dev/null 2>&1
#Remove previous build area, if no incremental build
if [ ${BUILD_INCREMENTAL} != 1 ]; then
if [ ${BUILD_INCREMENTAL} != true ]; then
sudo rm -fr "${BUILD_PATH}" >/dev/null 2>&1
fi
mkdir -p "${BUILD_PATH}" >/dev/null 2>&1
@ -194,10 +257,10 @@ echo "---> Compiling Hyperion from source code at ${CODE_PATH}"
# execute inside container all commands on bash
echo "---> Startup docker..."
$DOCKER run --rm \
$DOCKER run --rm --platform=${PLATFORM_ARCHITECTURE}\
-v "${DEPLOY_PATH}:/deploy" \
-v "${CODE_PATH}/:/source:rw" \
${REGISTRY_URL}/${BUILD_IMAGE}:${BUILD_TAG} \
${REGISTRY_URL}/${DISTRIBUTION}:${CODENAME} \
/bin/bash -c "mkdir -p /source/${BUILD_DIR} && cd /source/${BUILD_DIR} &&
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${PLATFORM} ${BUILD_ARGS} .. || exit 2 &&
make -j $(nproc) ${PACKAGES} || exit 3 || : &&
@ -210,7 +273,7 @@ DOCKERRC=${?}
sudo chown -fR $(stat -c "%U:%G" ${BASE_PATH}) ${BUILD_PATH}
if [ ${DOCKERRC} == 0 ]; then
if [ ${BUILD_LOCAL} == 1 ]; then
if [ ${BUILD_LOCAL} == true ]; then
echo "---> Find compiled binaries in: ${BUILD_PATH}/bin"
fi