Skip to content

Commit

Permalink
New build.sh script for the HyperHDR build process (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev authored Jul 16, 2024
1 parent 082a80a commit 10be570
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 86 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
USE_CACHE: ${{ vars.USE_CACHE && vars.USE_CACHE || true }}
RESET_CACHE: ${{ vars.RESET_CACHE && vars.RESET_CACHE || false }}
USE_CODEQL: ${{ vars.USE_CODEQL && vars.USE_CODEQL || false }}
BUILD_ARCHIVES: ${{ startsWith(github.event.ref, 'refs/tags') && 1 || 0 }}
BUILD_ARCHIVES: ${{ startsWith(github.event.ref, 'refs/tags') && true || false }}

jobs:

Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Check default version
if: matrix.linuxVersion != 'bullseye'
run: |
echo "USE_STANDARD_INSTALLER_NAME=ON" >> $GITHUB_ENV
echo "USE_STANDARD_INSTALLER_NAME=true" >> $GITHUB_ENV
- name: Build packages
env:
Expand All @@ -104,7 +104,7 @@ jobs:
RESET_CACHE: ${{ env.RESET_CACHE }}
shell: bash
run: |
./.ci/ci_build.sh
./build.sh
# Upload artifacts (only on tagged commit)
- name: Upload artifacts
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
USE_CCACHE: ${{ env.USE_CACHE }}
RESET_CACHE: ${{ env.RESET_CACHE }}
shell: bash
run: ./.ci/ci_build.sh
run: ./build.sh

# Upload artifacts (only on tagged commit)
- name: Upload artifacts
Expand Down Expand Up @@ -280,7 +280,7 @@ jobs:
USE_CCACHE: ${{ env.USE_CACHE }}
shell: bash
run: |
./.ci/ci_build.sh
./build.sh
# Upload artifacts (only on tagged commit)
- name: Upload artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-to-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ jobs:
PLATFORM: ${{ matrix.platform }}
USE_CCACHE: ${{ env.USE_CACHE }}
RESET_CACHE: ${{ env.RESET_CACHE }}
USE_STANDARD_INSTALLER_NAME: 'ON'
USE_STANDARD_INSTALLER_NAME: true
shell: bash
run: |
./.ci/ci_build.sh
./build.sh
# deploy the package
- name: Get destination path
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.swp
/*.user
/build*
.DS_Store
CMakeFiles/
__/
Expand All @@ -18,6 +17,9 @@ CMakeCache.txt
.directory
*.pyc
compile_commands.json
.ccache/
deploy/
build/

# Autogenerated by flatbuffers
include/flatbuffers/parser/hyperhdr_reply_generated.h
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ if (UNIX AND NOT APPLE)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../lib/external")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif ()

Expand Down
95 changes: 81 additions & 14 deletions .ci/ci_build.sh → build.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,103 @@
#!/bin/bash

print_manual()
{
EscChar="\033"
ColorReset="${EscChar}[m"
RedColor="${EscChar}[31;1m"
GreenColor="${EscChar}[32;1m"
YellowColor="${EscChar}[33;1m"
YellowColor2="${EscChar}[33m"
BlueColor="${EscChar}[34;1m"
CyanColor="${EscChar}[36;1m"

printf "\n${GreenColor}Required environmental options:${ColorReset}"
printf "\n${YellowColor}PLATFORM${ColorReset} - one of the supported targets: osx|windows|linux|rpi"
printf "\n${YellowColor}DOCKER_TAG${ColorReset} | ${YellowColor}DOCKER_IMAGE${ColorReset} - both are required only for linux|rpi platforms:"

printf "\n Debian => ${YellowColor2}bullseye${ColorReset} | ${YellowColor2}x86_64${ColorReset}"
printf "\n Debian => ${YellowColor2}bullseye${ColorReset} | ${YellowColor2}arm-32bit-armv6l${ColorReset}"
printf "\n Debian => ${YellowColor2}bullseye${ColorReset} | ${YellowColor2}arm-64bit-aarch64${ColorReset}"
printf "\n Debian => ${YellowColor2}bookworm${ColorReset} | ${YellowColor2}x86_64${ColorReset}"
printf "\n Debian => ${YellowColor2}bookworm${ColorReset} | ${YellowColor2}arm-32bit-armv6l${ColorReset}"
printf "\n Debian => ${YellowColor2}bookworm${ColorReset} | ${YellowColor2}arm-64bit-aarch64${ColorReset}"
printf "\n Ubuntu => ${YellowColor2}jammy${ColorReset} | ${YellowColor2}x86_64${ColorReset}"
printf "\n Ubuntu => ${YellowColor2}noble${ColorReset} | ${YellowColor2}x86_64${ColorReset}"
printf "\n Fedora => ${YellowColor2}Fedora_40${ColorReset} | ${YellowColor2}x86_64${ColorReset}"
printf "\n ArchLinux => ${YellowColor2}ArchLinux${ColorReset} | ${YellowColor2}x86_64${ColorReset}"

printf "\n\n${GreenColor}Optional environmental options:${ColorReset}"
printf "\n${CyanColor}BUILD_TYPE${ColorReset} - Release|Debug, default is Release version"
printf "\n${CyanColor}BUILD_ARCHIVES${ColorReset} - false|true, cpack will build ZIP package"
printf "\n${CyanColor}USE_STANDARD_INSTALLER_NAME${ColorReset} - false|true, use standard Linux package naming"
printf "\n${CyanColor}USE_CCACHE${ColorReset} - false|true, use ccache if available"
printf "\n${CyanColor}RESET_CACHE${ColorReset} - false|true, reset ccache storage"
printf "\n\n${GreenColor}Example of usage:${ColorReset}\n${YellowColor}PLATFORM=linux DOCKER_TAG=bullseye DOCKER_IMAGE=arm-64bit-aarch64 ./build.sh${ColorReset}"
printf "\nInstallers from Docker builds will be ready in the ${RedColor}deploy${ColorReset} folder"
printf "\n\n"
exit 0
}

if [[ "$PLATFORM" == "" || ( ("$PLATFORM" == "linux" || "$PLATFORM" == "rpi") && ( "$DOCKER_IMAGE" = "" || "$DOCKER_TAG" = "" ) ) ]]; then
print_manual
fi

# detect CI
if [ "$SYSTEM_COLLECTIONID" != "" ]; then
# Azure Pipelines
echo "Azure detected"
CI_NAME="$(echo "$AGENT_OS" | tr '[:upper:]' '[:lower:]')"
CI_BUILD_DIR="$BUILD_SOURCESDIRECTORY"
CI_TYPE="azure"
elif [ "$HOME" != "" ]; then
elif [ "$GITHUB_ACTIONS" != "" ]; then
# GitHub Actions
echo "Github Actions detected"
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
CI_BUILD_DIR="$GITHUB_WORKSPACE"
CI_TYPE="github_action"
else
# for executing in non ci environment
echo "Local system build detected"
CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
CI_TYPE="other"
CI_BUILD_DIR="$PWD"
fi

# set environment variables if not exists
[ -z "${BUILD_TYPE}" ] && BUILD_TYPE="Release"
[ -z "${USE_STANDARD_INSTALLER_NAME}" ] && USE_STANDARD_INSTALLER_NAME=false
[ -z "${USE_CCACHE}" ] && USE_CCACHE=true
[ -z "${RESET_CACHE}" ] && RESET_CACHE=false
[ -z "${BUILD_ARCHIVES}" ] && BUILD_ARCHIVES=true


printf "\nPLATFORM = %s" ${PLATFORM}
printf "\nDOCKER_TAG = %s" ${DOCKER_TAG}
printf "\nDOCKER_IMAGE = %s" ${DOCKER_IMAGE}
printf "\nBUILD_TYPE = %s" ${BUILD_TYPE}
printf "\nBUILD_ARCHIVES = %s" ${BUILD_ARCHIVES}
printf "\nUSE_STANDARD_INSTALLER_NAME = %s" ${USE_STANDARD_INSTALLER_NAME}
printf "\nUSE_CCACHE = %s" ${USE_CCACHE}
printf "\nRESET_CACHE = %s" ${RESET_CACHE}
printf "\n"

if [ ${BUILD_ARCHIVES} = true ]; then
echo "Build the package archive"
IS_ARCHIVE_SKIPPED=" -DDO_NOT_BUILD_ARCHIVES=OFF"
ARCHIVE_OPTION=" -DBUILD_ARCHIVES=ON"
else
echo "Do not build the package archive"
IS_ARCHIVE_SKIPPED=" -DDO_NOT_BUILD_ARCHIVES=ON"
ARCHIVE_OPTION=" -DBUILD_ARCHIVES=OFF"
fi

# set environment variables if not exists (debug)
[ -z "${BUILD_TYPE}" ] && BUILD_TYPE="Release"

[ -z "${USE_STANDARD_INSTALLER_NAME}" ] && USE_STANDARD_INSTALLER_NAME="OFF"
if [ ${USE_STANDARD_INSTALLER_NAME} = true ]; then
echo "Use standard naming"
ARCHIVE_OPTION=" ${ARCHIVE_OPTION} -DUSE_STANDARD_INSTALLER_NAME=ON"
else
echo "Do not use standard naming"
ARCHIVE_OPTION=" ${ARCHIVE_OPTION} -DUSE_STANDARD_INSTALLER_NAME=OFF"
fi

echo "Platform: ${PLATFORM}, build type: ${BUILD_TYPE}, CI_NAME: $CI_NAME, docker image: ${DOCKER_IMAGE}, docker type: ${DOCKER_TAG}, is archive enabled: ${IS_ARCHIVE_SKIPPED}, use ccache: ${USE_CCACHE}, reset ccache: ${RESET_CACHE}"
echo "Platform: ${PLATFORM}, build type: ${BUILD_TYPE}, CI_NAME: $CI_NAME, docker image: ${DOCKER_IMAGE}, docker type: ${DOCKER_TAG}, archive options: ${ARCHIVE_OPTION}, use ccache: ${USE_CCACHE}, reset ccache: ${RESET_CACHE}"

# clear ccache if neccesery
if [ ${RESET_CACHE} = true ]; then
Expand Down Expand Up @@ -77,10 +142,10 @@ elif [[ $CI_NAME == *"mingw64_nt"* || "$CI_NAME" == 'windows_nt' ]]; then

if [ ${USE_CCACHE} = true ]; then
echo "Using ccache"
BUILD_OPTION="${IS_ARCHIVE_SKIPPED}"
BUILD_OPTION="${ARCHIVE_OPTION}"
else
echo "Not using ccache"
BUILD_OPTION="-DUSE_CCACHE_CACHING=OFF ${IS_ARCHIVE_SKIPPED}"
BUILD_OPTION="-DUSE_CCACHE_CACHING=OFF ${ARCHIVE_OPTION}"
fi

if [[ $CI_TYPE == "github_action" ]]; then
Expand Down Expand Up @@ -115,12 +180,12 @@ elif [[ "$CI_NAME" == 'linux' ]]; then

if [ ${USE_CCACHE} = true ]; then
echo "Using ccache"
BUILD_OPTION="${IS_ARCHIVE_SKIPPED}"
BUILD_OPTION="${ARCHIVE_OPTION}"
cache_env="export CCACHE_DIR=/.ccache && ccache -z"
ls -a .ccache
else
echo "Not using ccache"
BUILD_OPTION="-DUSE_CCACHE_CACHING=OFF ${IS_ARCHIVE_SKIPPED}"
BUILD_OPTION="-DUSE_CCACHE_CACHING=OFF ${ARCHIVE_OPTION}"
cache_env="true"
fi

Expand All @@ -129,9 +194,11 @@ elif [[ "$CI_NAME" == 'linux' ]]; then
if [[ "$DOCKER_TAG" == "ArchLinux" ]]; then
echo "Arch Linux detected"
cp cmake/linux/arch/* .
executeCommand="makepkg"
chmod -R a+rw ${CI_BUILD_DIR}/deploy
versionFile=`cat version`
executeCommand="echo \"GLIBC version: \$(ldd --version | head -1 | sed 's/[^0-9]*\([.0-9]*\)$/\1/')\""
executeCommand=${executeCommand}" && sed -i \"s/{GLIBC_VERSION}/\$(ldd --version | head -1 | sed 's/[^0-9]*\([.0-9]*\)$/\1/')/\" PKGBUILD && makepkg"
echo ${executeCommand}
sed -i "s/{VERSION}/${versionFile}/" PKGBUILD
if [ ${USE_CCACHE} = true ]; then
sed -i "s/{BUILD_OPTION}/${BUILD_OPTION} -DUSE_PRECOMPILED_HEADERS=OFF/" PKGBUILD
Expand All @@ -150,7 +217,7 @@ elif [[ "$CI_NAME" == 'linux' ]]; then
-v "${CI_BUILD_DIR}/deploy:/deploy" \
-v "${CI_BUILD_DIR}:/source:ro" \
$REGISTRY_URL:$DOCKER_TAG \
/bin/bash -c "${cache_env} && cd / && mkdir -p hyperhdr && cp -r source/. /hyperhdr &&
/bin/bash -c "${cache_env} && cd / && mkdir -p hyperhdr && cp -rf /source/. /hyperhdr &&
cd /hyperhdr && mkdir build && (${executeCommand}) &&
(cp /hyperhdr/build/bin/h* /deploy/ 2>/dev/null || : ) &&
(cp /hyperhdr/build/Hyper* /deploy/ 2>/dev/null || : ) &&
Expand Down
66 changes: 52 additions & 14 deletions cmake/installers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,27 @@ macro(DeployUnix TARGET)
install(FILES ${webserver-resources-path} DESTINATION "share/hyperhdr/lib" COMPONENT "HyperHDR" )
endif()

# Copy SMARTX11 lib
if (TARGET smartX11)
install(CODE [[ file(INSTALL FILES $<TARGET_FILE:smartX11> DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR")
# Copy SMART-X11 lib
if (TARGET smart-x11)
install(CODE [[ file(INSTALL FILES $<TARGET_FILE:smart-x11> DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR")
endif()

# Copy SMARTPIPEWIRE lib
if (TARGET smartPipewire)
install(CODE [[ file(INSTALL FILES $<TARGET_FILE:smartPipewire> DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR")
# Copy SMART-PIPEWIRE lib
if (TARGET smart-pipewire)
install(CODE [[ file(INSTALL FILES $<TARGET_FILE:smart-pipewire> DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR")
endif()

# Copy UTILS-IMAGE lib
if (TARGET utils-image)
install(CODE [[ file(INSTALL FILES $<TARGET_FILE:utils-image> DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR")
endif()

# Copy UTILS-XZ lib
if (TARGET utils-image)
install(CODE [[ file(INSTALL FILES $<TARGET_FILE:utils-xz> DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib" TYPE SHARED_LIBRARY) ]] COMPONENT "HyperHDR")
endif()


#OpenSSL
find_package(OpenSSL)
if(OPENSSL_FOUND)
Expand Down Expand Up @@ -329,7 +340,7 @@ macro(DeployUnix TARGET)
endif()

# Create a qt.conf file in 'share/hyperhdr/bin' to override hard-coded search paths in Qt plugins
file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/\n")
file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=../lib/plugins/\n")
install(
FILES "${CMAKE_BINARY_DIR}/qt.conf"
DESTINATION "share/hyperhdr/bin"
Expand Down Expand Up @@ -400,6 +411,20 @@ macro(DeployUnix TARGET)
"libblkid"
"libbrotlicommon"
"libbrotlidec"
"libffi"
"libgio-2"
"libgmodule-2"
"libgobject-2"
"libidn2"
"libnghttp"
"libsystemd"
"libpsl"
"libunistring"
"libssh"
"libselinux"
"libevent-2"
"libldap"
"libutils"
)

#message(STATUS "Collecting Dependencies for target file: ${TARGET_FILE}")
Expand Down Expand Up @@ -429,7 +454,7 @@ macro(DeployUnix TARGET)
endforeach()
endif()

# Copy Qt plugins to 'share/hyperhdr/lib'
# Copy Qt plugins to 'share/hyperhdr/lib/plugins'
foreach(PLUGIN "tls")
#message(WARNING "Collecting Dependencies for QT plugin folder: ${PLUGIN}")
if(EXISTS ${QT_PLUGINS_DIR}/${PLUGIN})
Expand All @@ -443,7 +468,7 @@ macro(DeployUnix TARGET)
list(APPEND DEPENDENCIES ${QT_DEPENDENCIES})

file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib/${PLUGIN}"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib/plugins/${PLUGIN}"
TYPE SHARED_LIBRARY
FILES ${file}
)
Expand Down Expand Up @@ -471,17 +496,30 @@ macro(DeployUnix TARGET)
gp_append_unique(PREREQUISITE_LIBS ${resolved_file})
get_filename_component(file_canonical ${resolved_file} REALPATH)
gp_append_unique(PREREQUISITE_LIBS ${file_canonical})
#message(STATUS "Basic check added: ${resolved_file}")
#message("Basic check added: ${resolved_file} (${resolved})")
endif()
endforeach()

# Copy dependencies to 'share/hyperhdr/lib'
# Copy dependencies to 'share/hyperhdr/lib/external'
foreach(PREREQUISITE_LIB ${PREREQUISITE_LIBS})
message("Installing: " ${PREREQUISITE_LIB})
set(FILE_TO_INSTALL ${PREREQUISITE_LIB})
string(FIND ${PREREQUISITE_LIB} "libproxy" libproxyindex)
string(FIND ${PREREQUISITE_LIB} "libpxbackend" libpxbackendindex)
if((NOT IS_SYMLINK ${PREREQUISITE_LIB}) AND (${libproxyindex} GREATER -1 OR ${libpxbackendindex} GREATER -1))
get_filename_component(pathingFilename ${PREREQUISITE_LIB} NAME)
set(FILE_TO_INSTALL "${CMAKE_BINARY_DIR}/${pathingFilename}")
message("Patching RPATH: ${FILE_TO_INSTALL}")
file(COPY_FILE ${PREREQUISITE_LIB} ${FILE_TO_INSTALL} )
execute_process (
COMMAND bash -c "chrpath -d ${FILE_TO_INSTALL}"
OUTPUT_VARIABLE outputResult
)
endif()
message("Installing: " ${FILE_TO_INSTALL})
file(
INSTALL
FILES ${PREREQUISITE_LIB}
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib"
FILES ${FILE_TO_INSTALL}
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/hyperhdr/lib/external"
TYPE SHARED_LIBRARY
)
endforeach()
Expand Down
Loading

0 comments on commit 10be570

Please sign in to comment.