diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml new file mode 100644 index 0000000..80fe6c2 --- /dev/null +++ b/.github/workflows/build_and_release.yml @@ -0,0 +1,117 @@ +name: Build and Release Performous + +# Controls when the workflow will run +on: + # Triggers the workflow on merges to master, release branches, + # all PRs, and release tags + push: + branches: + - master + - '[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+' + tags: + - '[0-9]+\.[0-9]+\.[0-9]+' + - '[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+' + + # On anything pull request related + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Note: entire jobs or sections can be disabled by adding +# if: ${{ false }} to the definition column +jobs: + # Determine version + determine_version: + name: Determine the version to be used + runs-on: ubuntu-latest + outputs: + latest_tag_version: ${{ steps.versioning.outputs.latest_tag_version }} + latest_full_tag_version: ${{ steps.versioning.outputs.latest_full_tag_version }} + version_major: ${{ steps.versioning.outputs.version_major }} + version_minor: ${{ steps.versioning.outputs.version_minor }} + version_patch: ${{ steps.versioning.outputs.version_patch }} + version_tweak: ${{ steps.versioning.outputs.version_tweak }} + complete_version: ${{ steps.versioning.outputs.complete_version }} + steps: + - name: Determine the complete version + id: versioning + run: | + # Always check the tags on master since it will have the latest. + # Tags will trigger their own workflow and version names + git clone --recursive ${{ github.server_url }}/${{ github.repository }} performous_composer + cd performous_composer + LATEST_TAG_VERSION=$(git describe --tags --abbrev=0 || echo 1.0.0) + LATEST_FULL_TAG_VERSION=$(git describe --tags || echo 1.0.0) + echo "latest_tag_version=$(git describe --tags --abbrev=0 || echo 1.0.0)" >> $GITHUB_OUTPUT + echo "latest_full_tag_version=$(git describe --tags || echo 1.0.0)" >> $GITHUB_OUTPUT + echo "version_major=$(cut -d '.' -f 1 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT + echo "version_minor=$(cut -d '.' -f 2 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT + echo "version_patch=$(cut -d '.' -f 3 <<< $(git describe --tags --abbrev=0 || echo 1.0.0))" >> $GITHUB_OUTPUT + echo "version_tweak=0" >> $GITHUB_OUTPUT + echo "complete_version=$(if [ $GITHUB_REF_TYPE = 'tag' ]; then echo $GITHUB_REF_NAME; elif [ $GITHUB_REF_TYPE = 'branch' ] && [ $GITHUB_REF_NAME = 'master' ]; then echo $LATEST_FULL_TAG_VERSION-beta; elif [ $GITHUB_REF_TYPE = 'branch' ] && [ $GITHUB_REF_NAME != 'master' ]; then echo $LATEST_TAG_VERSION-${{github.event.pull_request.number}}-${GITHUB_SHA::7}-alpha; fi)" >> $GITHUB_OUTPUT + + # Set up a release that packages will be published to. + create_release: + name: Create a release + runs-on: ubuntu-latest + # Make sure the output variable for this step is set so it + # can be consumed by later build steps + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create the Main release + id: create_release + if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: Performous ${{ github.ref_name }} + draft: true + prerelease: false + + # Pull in the Linux build workflow + Linux_Packages: + name: Build the Linux packages + uses: ./.github/workflows/linux.yml + with: + package_complete_version: ${{ needs.determine_version.outputs.complete_version }} + release_upload_url: ${{ needs.create_release.outputs.upload_url }} + needs: + - determine_version + - create_release + + # Pull in the AppImage build workflow + #AppImage_Package: + # name: Build the AppImage package + # uses: ./.github/workflows/appimage.yml + # with: + # package_complete_version: ${{ needs.determine_version.outputs.complete_version }} + # release_upload_url: ${{ needs.create_release.outputs.upload_url }} + # needs: + # - determine_version + # - create_release + + # Pull in the MacOS build workflow + #MacOS_Package: + # name: Build the MacOS package + # uses: ./.github/workflows/macos.yml + # with: + # package_complete_version: ${{ needs.determine_version.outputs.complete_version }} + # release_upload_url: ${{ needs.create_release.outputs.upload_url }} + # needs: + # - determine_version + # - create_release + + # Pull in the Windows build workflow + #Windows_Packages: + # name: Build the Windows packages + # uses: ./.github/workflows/windows.yml + # with: + # package_complete_version: ${{ needs.determine_version.outputs.complete_version }} + # release_upload_url: ${{ needs.create_release.outputs.upload_url }} + # needs: + # - determine_version + # - create_release diff --git a/.github/workflows/comment_on_pr.yml b/.github/workflows/comment_on_pr.yml new file mode 100644 index 0000000..83335b6 --- /dev/null +++ b/.github/workflows/comment_on_pr.yml @@ -0,0 +1,65 @@ +name: Comment on pull request + +on: + # Only run when the other workflow is completed since + # the build workflow only publishes artifacts after it has completed + workflow_run: + workflows: [ 'Build and Release Performous' ] + types: [completed] + +jobs: + pr_comment: + name: Add packages to PRs + if: github.event.workflow_run.event == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Get the PR number + run: | + # Query the issue search API to get the PR associated with it + PR_RAW=$(curl 'https://api.github.com/search/issues?q=${{ github.event.workflow_run.head_commit.id }}') + # Get the event number from the search results, which will + # be the PR number + PR_NUM=$(echo $PR_RAW | jq '.items[].number') + echo "PR_NUM=${PR_NUM}" >> ${GITHUB_ENV} + + - name: Comment on PR + uses: actions/github-script@v5 + with: + # This snippet is public-domain, taken from + # https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml + # and modified to allow comments on external PRs + script: | + async function upsertComment(owner, repo, issue_number, purpose, body) { + const {data: comments} = await github.rest.issues.listComments( + {owner, repo, issue_number}); + const marker = ``; + body = marker + "\n" + body; + const existing = comments.filter((c) => c.body.includes(marker)); + if (existing.length > 0) { + const last = existing[existing.length - 1]; + core.info(`Updating comment ${last.id}`); + await github.rest.issues.updateComment({ + owner, repo, + body, + comment_id: last.id, + }); + } else { + core.info(`Creating a comment in issue / PR ${issue_number}`); + await github.rest.issues.createComment({issue_number, body, owner, repo}); + } + } + const {owner, repo} = context.repo; + const run_id = '${{github.event.workflow_run.id}}'; + const artifacts = await github.paginate( + github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id}); + if (!artifacts.length) { + return core.error(`No artifacts found`); + } + let body = `Download the artifacts for this pull request:\n`; + for (const art of artifacts) { + body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`; + } + body += ` \n\nThis service is provided by [nightly.link](https://github.com/oprypin/nightly.link). These artifacts will expire in 90 days and will not be available for download after that time.`; + core.info("Review thread message body:", body); + await upsertComment(owner, repo, ${{ env.PR_NUM }}, + "nightly-link", body); diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..035cd1f --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,191 @@ +name: Build Linux Packages + +on: + # Run on a schedule to get monthly updates + schedule: + - cron: "0 0 28 * *" + + # Run when called from other workflows + workflow_call: + inputs: + package_complete_version: + description: 'The output of the complete_version of the "determine_version" job from the build_and_release.yml workflow' + required: true + type: string + release_upload_url: + description: 'The output of the "create_release" job from the build_and_release.yml workflow' + required: true + type: string + +env: + REGISTRY: ghcr.io + REPO_NAME: ${{ github.repository_owner }} + +jobs: + # Decide if we need to build the containers on this run + determine_docker_version: + name: Determine whether to build the containers or not + runs-on: ubuntu-latest + outputs: + build_docker_containers: ${{ steps.version.outputs.build_docker_containers }} + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Determine version + id: version + run: | + # Only run the container builds when something in the docker folder or + # this workflow has changed from master, or if it was cron triggered + GIT_OUTPUT="$(git log -n 2 --stat)" + if [ $(echo ${GIT_OUTPUT} | grep -c docker/) -gt 0 ] || [ $(echo ${GIT_OUTPUT} | grep -c .github/workflows/linux.yml) -gt 0 ] || [ '${{ github.event_name }}' = 'schedule' ]; then + echo "build_docker_containers=true" >> $GITHUB_OUTPUT + else + echo "build_docker_containers=false" >> $GITHUB_OUTPUT + fi + + build_packages: + name: Build the Linux packages + runs-on: ubuntu-latest + needs: + - determine_docker_version + strategy: + matrix: + include: + - os: ubuntu + version: 20.04 + - os: ubuntu + version: 22.04 + - os: debian + version: 10 + - os: debian + version: 11 + - os: fedora + version: 34 + - os: fedora + version: 35 + ## FFMPEG5 causes issues + ## See https://github.com/performous/composer/issues/45 + #- os: fedora + # version: 36 + steps: + - name: Container name + run: | + # Figure out the container name we'll use for the build + BUILD_CONTAINER=${{ env.REGISTRY }}/${{ env.REPO_NAME }}/composer-deps:${{ matrix.os }}-${{ matrix.version }} + echo "CONTAINER_NAME=${BUILD_CONTAINER}" >> $GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to the container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REPO_NAME }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build ${{ matrix.os }} ${{ matrix.version }} Container + if: ${{ needs.determine_docker_version.outputs.build_docker_containers == 'true' }} + uses: docker/build-push-action@v3 + with: + context: docker/ + file: ./docker/Dockerfile.${{ matrix.os }} + load: true + tags: ${{ env.CONTAINER_NAME }} + build-args: OS_VERSION=${{ matrix.version }} + + - name: Build package + # Don't build the packages if triggered by cron because it will not + # have the correct inputs required to construct the package names correctly. + # The cron schedule is really for making sure the docker containers are + # up-to-date anyway. + if: ${{ github.event_name != 'schedule' }} + run: | + # Set the correct version in cmake + PACKAGE_VERSION=${{ inputs.package_complete_version }} + EXTRA_CMAKE_ARGS="-DPERFORMOUS_VERSION=${PACKAGE_VERSION}" + + # Decide if we should build a 'Release' package or a 'RelWithDebInfo' (default) + # For some reason, building with 'RelWithDebInfo' (default) doesn't work + # specifically on PRs, so we'll just build Releases for everything for now + #if [ '${{ github.event_name }}' != 'pull_request' ]; then + RELEASE_TYPE="-R" + #fi + + # Only pull the container if it wasn't built locally + if [ '${{ needs.determine_docker_version.outputs.build_docker_containers }}' = 'false' ]; then + docker pull ${{ env.CONTAINER_NAME }} + fi + + # Run the build inside the docker containers using the + # build script that was pulled inside during the build + docker run --rm -v $(pwd):/github_actions_build/ ${{ env.CONTAINER_NAME }} ./build_composer.sh -g -D /github_actions_build/ -E ${EXTRA_CMAKE_ARGS} ${RELEASE_TYPE} + # Do some mangling to make a unique name based on the OS + # This is needed so we don't overwite in the release each time. + # We should probably investigate what cmake can do for package output + # to make this cleaner in the future + WORK_DIR=$(pwd) + PACKAGE_PATH=$(ls ${WORK_DIR}/build/Composer*64.*) + PACKAGE_NAME=$(basename ${PACKAGE_PATH}) + PACKAGE_SUFFIX=$(echo ${PACKAGE_NAME} | sed 's/^.*\(.\{4\}\)/\1/') + NEW_PACKAGE_NAME="${WORK_DIR}/Composer-${PACKAGE_VERSION}-${{ matrix.os }}_${{ matrix.version }}${PACKAGE_SUFFIX}" + MASTER_NEW_PACKAGE_NAME="${WORK_DIR}/Composer-latest-${{ matrix.os }}_${{ matrix.version }}${PACKAGE_SUFFIX}" + cp ${PACKAGE_PATH} ${MASTER_NEW_PACKAGE_NAME} + cp ${PACKAGE_PATH} ${NEW_PACKAGE_NAME} + ARTIFACT_NAME=$(basename ${NEW_PACKAGE_NAME}) + MASTER_ARTIFACT_NAME=$(basename ${MASTER_NEW_PACKAGE_NAME}) + echo "ARTIFACT_PATH=${NEW_PACKAGE_NAME}" >> ${GITHUB_ENV} + echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> ${GITHUB_ENV} + echo "MASTER_ARTIFACT_PATH=${MASTER_NEW_PACKAGE_NAME}" >> ${GITHUB_ENV} + echo "MASTER_ARTIFACT_NAME=${MASTER_ARTIFACT_NAME}" >> ${GITHUB_ENV} + + #- name: Run unit tests + # if: ${{ github.event_name != 'schedule' }} + # run: | + # # Run the containers with the script for each testing suite + # docker run --rm -v $(pwd):/github_actions_build/ ${{ env.CONTAINER_NAME }} ./run_tests.sh + + # Upload artifacts during pull-requests + - name: Upload artifact + uses: actions/upload-artifact@v3 + if: ${{ github.event_name == 'pull_request' }} + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_PATH }} + + # Upload artifacts on master + - name: Upload artifact with unified name + if: ${{ github.ref == 'refs/heads/master' }} + uses: actions/upload-artifact@v3 + with: + name: ${{ env.MASTER_ARTIFACT_NAME }} + path: ${{ env.MASTER_ARTIFACT_PATH }} + + # Upload artifacts to releases only during Release events + - name: Upload artifacts to tagged release + id: upload_assets + if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ inputs.release_upload_url }} + asset_path: ${{ env.ARTIFACT_PATH }} + asset_name: ${{ env.ARTIFACT_NAME }} + asset_content_type: application/octet-stream + + - name: Push container + uses: docker/build-push-action@v3 + # Containers can't be pushed during PRs because of the way permissions + # are delegated to secrets.GITHUB_TOKEN + if: ${{ needs.determine_docker_version.outputs.build_docker_containers == 'true' && github.event_name != 'pull_request' }} + with: + context: docker/ + file: ./docker/Dockerfile.${{ matrix.os }} + push: true + tags: ${{ env.CONTAINER_NAME }} + build-args: OS_VERSION=${{ matrix.version }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 87b8cdb..99c71db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,4 +29,3 @@ set(CMAKE_AUTOMOC ON) # Sources add_subdirectory(src) - diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian new file mode 100644 index 0000000..6b5d8db --- /dev/null +++ b/docker/Dockerfile.debian @@ -0,0 +1,37 @@ +ARG OS_VERSION +## Use the official Debian Image from Dockerhub +FROM docker.io/library/debian:${OS_VERSION} + +## Copy OS_VERSION into ENV so we can use it in scripts too +ARG OS_VERSION +ENV OS_VERSION=${OS_VERSION} + +## Set up environment variables so the tzdata install doesn't +## hang on asking for user input for configuration +ARG DEBIAN_FRONTEND="noninteractive" +ARG TZ="America/New_York" + +## Install the deps and create the build directory +RUN if [ ${OS_VERSION} -eq 10 ]; then \ + apt-get update && \ + apt-get install -y wget gpg && \ + wget -nc https://apt.kitware.com/keys/kitware-archive-latest.asc && \ + apt-key add kitware-archive-latest.asc && \ + echo 'deb https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null; fi && \ + apt-get update &&\ + apt-get install -y --no-install-recommends git cmake build-essential \ + gettext help2man libopenblas-dev libfftw3-dev libicu-dev libepoxy-dev \ + libsdl2-dev libfreetype6-dev libpango1.0-dev librsvg2-dev libxml++2.6-dev \ + libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev \ + portaudio19-dev libglm-dev libboost-filesystem-dev \ + libboost-iostreams-dev libboost-locale-dev libboost-system-dev \ + libboost-program-options-dev libssl-dev libcpprest-dev \ + libportmidi-dev libopencv-dev libaubio-dev nlohmann-json3-dev \ + libfmt-dev ca-certificates file qtbase5-dev qtmultimedia5-dev && \ + apt-get clean && \ + mkdir /root/performous + +## Copy in the build script to make things easy +COPY build_composer.sh /root/performous/build_composer.sh + +WORKDIR /root/performous diff --git a/docker/Dockerfile.fedora b/docker/Dockerfile.fedora new file mode 100644 index 0000000..a979c34 --- /dev/null +++ b/docker/Dockerfile.fedora @@ -0,0 +1,20 @@ +ARG OS_VERSION +## Use the official Fedora Image from Dockerhub +FROM docker.io/library/fedora:${OS_VERSION} + +## Install the deps and create the working directory +## Enable the RPM Fusion Free Repo +RUN dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm &&\ + dnf install -y git cmake gcc-c++ gettext cairo-devel librsvg2-devel libsigc++20-devel \ + glibmm24-devel libxml++-devel boost-devel SDL2-devel libepoxy-devel ffmpeg-devel \ + portaudio-devel help2man redhat-lsb opencv-devel portmidi-devel libjpeg-turbo-devel \ + pango-devel jsoncpp-devel glm-devel openblas-devel fftw-devel cpprest-devel \ + aubio-devel json-devel rpm-build fmt-devel qt5-qtbase-devel \ + qt5-qtmultimedia-devel && \ + dnf clean all && \ + mkdir /root/performous + +## Copy in the build script to make things easy +COPY build_composer.sh /root/performous/build_composer.sh + +WORKDIR /root/performous diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu new file mode 100644 index 0000000..fad7289 --- /dev/null +++ b/docker/Dockerfile.ubuntu @@ -0,0 +1,27 @@ +ARG OS_VERSION +## Use the official Ubuntu Image from Dockerhub +FROM docker.io/library/ubuntu:${OS_VERSION} + +## Set up environment variables so the tzdata install doesn't +## hang on asking for user input for configuration +ARG DEBIAN_FRONTEND="noninteractive" +ARG TZ="America/New_York" + +## Install the deps and create the build directory +RUN apt-get update && \ + apt-get install -y --no-install-recommends git cmake build-essential \ + gettext help2man libopenblas-dev libfftw3-dev libicu-dev libepoxy-dev \ + libsdl2-dev libfreetype6-dev libpango1.0-dev librsvg2-dev libxml++2.6-dev \ + libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev \ + portaudio19-dev libglm-dev libboost-filesystem-dev nlohmann-json3-dev\ + libboost-iostreams-dev libboost-locale-dev libboost-system-dev \ + libboost-program-options-dev libssl-dev libcpprest-dev \ + libportmidi-dev libopencv-dev libaubio-dev libfmt-dev qtbase5-dev \ + qtmultimedia5-dev ca-certificates file && \ + apt-get clean && \ + mkdir /root/performous + +## Copy in the build script to make things easy +COPY build_composer.sh /root/performous/build_composer.sh + +WORKDIR /root/performous diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..1581bd3 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,48 @@ +This folder contains Dockerfiles which will install all dependencies needed to build [Performous](https://github.com/performous/performous/wiki/Building-and-installing-from-source). + +These containers are to be used as `base images` to provide higher-level builds and packages and to produce artifacts for downstream consumption. These containers **do not** provide a running version of `Performous` or contain the project source in any usable form. + +These containers are built automatically during our CI/CD workflow, and are used to support Linux Distros that are no available by default from Github Actions. + +## Building containers +The build is a pretty standard `docker build`, just make sure you explicitly call out a `Dockerfile` with `-f Dockerfile.` and supply the correct distro version as a `build-arg`: +```sh +docker build -t performous-docker-build:ubuntu20.04 -f Dockerfile.ubuntu --build-arg OS_VERSION=20.04 . +``` + +Currently supported distros are: +- Ubuntu (20.04, 22.04) +- Fedora (34, 35, 36) +- Debian (10, 11) + +## Running the containers +Once the `base-image` has been built, the container can be run interactively to build `Performous`: +```sh +docker run -it performous-docker-build:ubuntu20.04 +``` + +From there, you can [follow the build instructions](https://github.com/performous/performous/wiki/Building-and-installing-from-source#downloading-and-installing-the-sources) to build performous. + + +`build_performous.sh` is included in the containers for testing builds and creating OS packages. +``` +Usage: ./build_performous.sh -a (build with all build systems) + +Optional Arguments: + -b : Build the specified git branch, tag, or sha + -p : Build the specified Github Pull Request number + -g : Generate Packages + -r : Git repository to pull from + -R : Perform a 'Release' Cmake Build (Default is 'RelWithDebInfo') + -h : Show this help message +``` + +To build a pull request using just cmake: +``` +docker run performous-docker-build:ubuntu20.04 ./build_performous.sh -c -p 626 +``` + +One-Liner to generate packages and copy them to `/tmp` on the running system: +``` +mkdir /tmp/performous-packages && docker run --rm --mount type=bind,source=/tmp/performous-packages,target=/performous/packages performous-docker-build:ubuntu20.04 /bin/bash -c './build_performous.sh -c -R -g && cp performous/build/*.deb /performous/packages' +``` diff --git a/docker/build_composer.sh b/docker/build_composer.sh new file mode 100755 index 0000000..752542b --- /dev/null +++ b/docker/build_composer.sh @@ -0,0 +1,102 @@ +#!/bin/bash -ex +## Pull in /etc/os-release so we can see what we're running on +. /etc/os-release + +## Default Vars +GIT_REPOSITORY='https://github.com/performous/composer.git' + +## Function to print the help message +usage() { + set +x + echo "" + echo "Usage: ${0}" + echo "" + echo "Optional Arguments:" + echo " -b : Build the specified git branch, tag, or sha" + echo " -D : Disable cloning the repo from git and build in the specified directory" + echo " -E <'Extra Cmake Args'>: A quoted list of extra arguments to pass directly to cmake" + echo " -g : Generate Packages" + echo " -p : Build the specified Github Pull Request number" + echo " -r : Git repository to pull from" + echo " -R : Perform a 'Release' Cmake Build (Default is 'RelWithDebInfo')" + echo " -h : Show this help message" + exit 1 +} + +## Set up getopts +while getopts "b:D:E:gp:r:Rh" OPTION; do + case ${OPTION} in + "b") + GIT_BRANCH=${OPTARG};; + "D") + BUILD_DIRECTORY=${OPTARG};; + "E") + EXTRA_CMAKE_ARGS=${OPTARG};; + "g") + GENERATE_PACKAGES=true;; + "p") + PULL_REQUEST=${OPTARG};; + "r") + GIT_REPOSITORY=${OPTARG};; + "R") + RELEASE_BUILD=true;; + "h") + HELP=true;; + esac +done + +if [ ${HELP} ]; then + usage +fi + +## All the git stuff +if [ -z ${BUILD_DIRECTORY} ]; then + git clone ${GIT_REPOSITORY} performous_composer + cd performous_composer + if [ ${PULL_REQUEST} ]; then + git fetch origin pull/${PULL_REQUEST}/head:pr + git checkout pr + elif [ ${GIT_BRANCH} ]; then + git checkout ${GIT_BRANCH} + fi + git submodule update --init --recursive +else + cd ${BUILD_DIRECTORY} +fi + +## Set up some special cmake flags for fedora +if [ "${ID}" == "fedora" ]; then + EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DUSE_BOOST_REGEX=1" +fi + +## Set more cmake flags for Debian 10 +# Debian Buster has system Aubio 0.4.5, this is not enough +# because performous requires a minimum version of 0.4.9. +if ([ "${ID}" = "debian" ] && [ "${VERSION_ID}" = "10" ]); then + EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DSELF_BUILT_AUBIO=ALWAYS -DSELF_BUILT_JSON=ALWAYS" +fi + +if [ "${RELEASE_BUILD}" ]; then + EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release" +fi + +## Figure out what type of packages we need to generate +case ${ID} in + 'fedora') + PACKAGE_TYPE='RPM';; + 'ubuntu'|'debian') + PACKAGE_TYPE='DEB';; + *) + PACKAGE_TYPE='TGZ';; +esac + +## Build with cmake +mkdir build +cd build +cmake ${EXTRA_CMAKE_ARGS} -DENABLE_WEBSERVER=ON -DCMAKE_VERBOSE_MAKEFILE=1 -DENABLE_WEBCAM=ON .. +CPU_CORES=$(nproc --all) +make -j${CPU_CORES} +if [ ${GENERATE_PACKAGES} ]; then + cpack -G ${PACKAGE_TYPE} +fi +cd .. diff --git a/platform/packaging.cmake b/platform/packaging.cmake index 402d1bf..877f245 100644 --- a/platform/packaging.cmake +++ b/platform/packaging.cmake @@ -14,6 +14,10 @@ set(CPACK_PACKAGE_EXECUTABLES composer) set(CPACK_SOURCE_GENERATOR "TBZ2") set(CPACK_GENERATOR "TBZ2") +# Debian specific settings +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_PACKAGE_SECTION "Games") + if("${CMAKE_BUILD_TYPE}" MATCHES "Release") set(CPACK_STRIP_FILES TRUE) endif("${CMAKE_BUILD_TYPE}" MATCHES "Release") @@ -48,29 +52,6 @@ if(UNIX) set(CPACK_PACKAGE_ARCHITECTURE amd64) endif("${CPACK_PACKAGE_ARCHITECTURE}" MATCHES "x86_64") - # Set the dependencies based on the distro version - - # Ubuntu - if("${LSB_DISTRIB}" MATCHES "Ubuntu10.04") - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4, libqtgui4, libqt4-xml, phonon, libavformat52|libavformat-extra-52") - endif("${LSB_DISTRIB}" MATCHES "Ubuntu10.04") - - if("${LSB_DISTRIB}" MATCHES "Ubuntu10.10") - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4, libqtgui4, libqt4-xml, phonon, libavformat52|libavformat-extra-52") - endif("${LSB_DISTRIB}" MATCHES "Ubuntu10.10") - - # Debian - if("${LSB_DISTRIB}" MATCHES "Debian5.*") - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4, libqtgui4, libqt4-xml, phonon, libavformat52|libavformat-extra-52") - endif("${LSB_DISTRIB}" MATCHES "Debian5.*") - - if("${LSB_DISTRIB}" MATCHES "Debiantesting") - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4, libqtgui4, libqt4-xml, phonon, libavformat52|libavformat-extra-52") - endif("${LSB_DISTRIB}" MATCHES "Debiantesting") - - if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) - message("WARNING: ${LSB_DISTRIB} not supported yet.\nPlease set deps in packaging.cmake before packaging.") - endif(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) string(TOLOWER "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${LSB_DISTRIB}_${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_FILE_NAME) endif("${LSB_DISTRIB}" MATCHES "Ubuntu|Debian") # For Fedora-based distros we want to create RPM packages. @@ -106,4 +87,3 @@ if(UNIX) endif(UNIX) include(CPack) -