diff --git a/.github/workflows/TODO.md b/.github/workflows/TODO.md deleted file mode 100644 index 40bb7ee805..0000000000 --- a/.github/workflows/TODO.md +++ /dev/null @@ -1,7 +0,0 @@ -# Improvements: - -- I believe a ton of time (1minute on each) can be shaved off the linux builds by caching the apt dependencies - https://stackoverflow.com/a/59277514 - - however, there are a lot so, need to make some scripts to make this not a huge pain -- As the above is done, the linux build script can probably be refactored a bit, theres a bit of disabled paths, some naming, nothing major. -- Release to AUR on a tag -- Are we ready to do an osx build? diff --git a/.github/workflows/linux-workflow.yml b/.github/workflows/linux-workflow.yml index a1bb6e3dc9..d4b206b0f7 100644 --- a/.github/workflows/linux-workflow.yml +++ b/.github/workflows/linux-workflow.yml @@ -18,23 +18,9 @@ jobs: matrix: os: [ubuntu-20.04] platform: [x86, x64] - compiler: [gcc] - compiler-version: [8] experimental: [false] - include: - - os: ubuntu-20.04 - platform: x86 - compiler: gcc - compiler-version: 7 - experimental: false - # TODO - I'm not very confident about the clang build, it might not be compiling with 32bits? :shrug: - - os: ubuntu-20.04 - platform: x86 - compiler: clang - compiler-version: 10 - experimental: false - name: ${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.compiler-version }} + name: ${{ matrix.os }}-${{ matrix.platform }} runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} # Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them. @@ -54,17 +40,6 @@ jobs: with: submodules: true - - name: Prepare Artifact Git Info - run: | - echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}" - echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")" - if [ ${{ github.event_name == 'pull_request' }}> ]; then - echo "##[set-output name=file-name-metadata;]pr-${{ github.event.pull_request.base.number }}" - else - echo "##[set-output name=file-name-metadata;]commit-$(git rev-parse --short "$GITHUB_SHA")" - fi - id: git-vars - # -- SETUP CCACHE - https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/ - name: Prepare ccache timestamp id: ccache_cache_timestamp @@ -81,22 +56,19 @@ jobs: restore-keys: | ${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-ccache- - # TODO - i'd like to refactor this out into separate steps if possible. - # but for now, lets just replicate the Travis-CI build - - name: Build PCSX2 + - name: Install Packages env: - VERSION: ${{ matrix.compiler-version }} PLATFORM: ${{ matrix.platform }} - COMPILER: ${{ matrix.compiler }} # TODO - give the file executable permissions and commit it run: | chmod +x .github/workflows/scripts/build-linux.sh - ./.github/workflows/scripts/build-linux.sh before_install - ./.github/workflows/scripts/build-linux.sh script + ./.github/workflows/scripts/build-linux.sh install_packages - # TODO - Any value in producing a linux artifact? - # - name: Upload artifact - # uses: actions/upload-artifact@v2 - # with: - # name: PCSX2-${{ matrix.platform }}-${{ steps.git-vars.outputs.file-name-metadata }} - # path: bin + - name: Build PCSX2 + env: + PLATFORM: ${{ matrix.platform }} + # TODO - give the file executable permissions and commit it + run: | + chmod +x .github/workflows/scripts/build-linux.sh + ./.github/workflows/scripts/build-linux.sh generate_cmake + ./.github/workflows/scripts/build-linux.sh compile diff --git a/.github/workflows/scripts/build-linux.sh b/.github/workflows/scripts/build-linux.sh index 7065b758eb..8f85331e54 100644 --- a/.github/workflows/scripts/build-linux.sh +++ b/.github/workflows/scripts/build-linux.sh @@ -1,214 +1,123 @@ -#!/bin/sh +#!/bin/bash -set -ex +# Packages - Build Environment +declare -a BUILD_PACKAGES=( + "cmake" + "ccache" + "g++-10-multilib" +) -linux_x86_before_install() { - if [ "${COMPILER}" = "clang" ]; then - export CC=clang - export CXX=clang++ - else - export CC=gcc - export CXX=g++ +# Packages - PCSX2 +declare -a PCSX2_PACKAGES=( + "libaio-dev" + "libasound2-dev" + "libcairo2-dev" + "libegl1-mesa-dev" + "libgdk-pixbuf2.0-dev" + "libgirepository-1.0-1" + "libgl1-mesa-dev" + "libglib2.0-dev" + "libglu1-mesa-dev" + "libgtk-3-dev" + "libgtk2.0-dev" + "libharfbuzz-dev" + "liblzma-dev" + "libpango1.0-dev" + "libpcap0.8-dev" + "libsdl2-dev" + "libsoundtouch-dev" + "libwxgtk3.0-gtk3-dev" + "libx11-xcb-dev" + "libxext-dev" + "libxft-dev" + "libxml2-dev" + "portaudio19-dev" + "zlib1g-dev" +) + +# - https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md +install_packages() { + ARCH="" + echo "${PLATFORM}" + if [ "${PLATFORM}" == "x86" ]; then + ARCH=":i386" + sudo dpkg --add-architecture i386 fi - # Build worker is 64-bit only by default it seems. - sudo dpkg --add-architecture i386 - - # Compilers - if [ "${CXX}" = "clang++" ]; then - COMPILER_PACKAGE="g++-${VERSION}-multilib" - fi - if [ "${CXX}" = "g++" ]; then - COMPILER_PACKAGE="g++-${VERSION}-multilib" - fi - - - # The 64-bit versions of the first 7 dependencies are part of the initial - # build image. libgtk2.0-dev:i386 and libsdl2-dev:i386 require the 32-bit - # versions of the dependencies, and the 2 versions conflict. So those - # dependencies must be explicitly installed. - # Sometimes it complains about Python so we install that too. - - # TODO - i suspect there are unneeded dependencies here sudo apt-get -qq update - sudo apt-get -y install \ - cmake \ - ccache \ - libwxgtk3.0-gtk3-dev:i386 \ - libgtk-3-dev:i386 \ - libaio-dev:i386 \ - libasound2-dev:i386 \ - liblzma-dev:i386 \ - libsdl2-dev:i386 \ - libsoundtouch-dev:i386 \ - libxml2-dev:i386 \ - libpcap0.8-dev:i386 \ - libx11-xcb-dev:i386 \ - gir1.2-freedesktop:i386 \ - gir1.2-gdkpixbuf-2.0:i386 \ - gir1.2-glib-2.0:i386 \ - libcairo2-dev:i386 \ - libegl1-mesa-dev:i386 \ - libgdk-pixbuf2.0-dev:i386 \ - libgirepository-1.0-1:i386 \ - libglib2.0-dev:i386 \ - libgl1-mesa-dev:i386 \ - libglu1-mesa-dev:i386 \ - libgtk2.0-dev:i386 \ - libharfbuzz-dev:i386 \ - libpango1.0-dev:i386 \ - libxext-dev:i386 \ - libxft-dev:i386 \ - portaudio19-dev:i386 \ - zlib1g-dev:i386 \ - ${COMPILER_PACKAGE} + # TODO - needed? sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + + # Install packages needed for building + BUILD_PACKAGE_STR="" + for i in "${BUILD_PACKAGES[@]}"; do + BUILD_PACKAGE_STR="${BUILD_PACKAGE_STR} ${i}" + done + echo "Will install the following packages for building - ${BUILD_PACKAGE_STR}" + sudo apt remove gcc-9 g++-9 + sudo apt-get -y install ${BUILD_PACKAGE_STR} + + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 + + # Install packages needed by pcsx2 + PCSX2_PACKAGES_STR="" + for i in "${PCSX2_PACKAGES[@]}"; do + PCSX2_PACKAGES_STR="${PCSX2_PACKAGES_STR} ${i}${ARCH}" + done + echo "Will install the following packages for pcsx2 - ${PCSX2_PACKAGES_STR}" + sudo apt-get -y install ${PCSX2_PACKAGES_STR} } -linux_x86_script() { - mkdir build - cd build - - if [ "${COMPILER}" = "clang" ]; then - export CC=clang - export CXX=clang++ - else - export CC=gcc - export CXX=g++ +generate_cmake() { + export CC=gcc + export CXX=g++ + ADDITIONAL_CMAKE_ARGS="" + if [ "${PLATFORM}" = "x86" ]; then + ADDITIONAL_CMAKE_ARGS="-D CMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake" fi + echo "Additional CMake Args - ${ADDITIONAL_CMAKE_ARGS}" - # Prevents warning spam - if [ "${CXX}" = "clang++" ]; then - export CCACHE_CPP2=yes - export CC=${CC} CXX=${CXX} - else - export CC=${CC}-${VERSION} - export CXX=${CXX}-${VERSION} - fi + # Generate CMake into ./build + cmake \ + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -D CMAKE_BUILD_TYPE=Release \ + -D BUILD_REPLAY_LOADERS=TRUE \ + -D CMAKE_BUILD_PO=FALSE \ + -D GTK3_API=TRUE ${ADDITIONAL_CMAKE_ARGS} \ + -B build +} +compile() { export CCACHE_BASEDIR=${GITHUB_WORKSPACE} export CCACHE_DIR=${GITHUB_WORKSPACE}/.ccache export CCACHE_COMPRESS="true" export CCACHE_COMPRESSLEVEL="6" export CCACHE_MAXSIZE="400M" - ccache -p - ccache -z - - cmake \ - -D CMAKE_C_COMPILER_LAUNCHER=ccache \ - -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -D CMAKE_TOOLCHAIN_FILE=cmake/linux-compiler-i386-multilib.cmake \ - -D CMAKE_BUILD_TYPE=Release \ - -D BUILD_REPLAY_LOADERS=TRUE \ - -D CMAKE_BUILD_PO=FALSE \ - -D GTK3_API=TRUE \ - .. - - make -j2 install - - ccache -s -} - - -linux_x64_before_install() { - echo ${COMPILER} - if [ "${COMPILER}" = "clang" ]; then - echo "Clang!" - export CC=clang - export CXX=clang++ - else - echo "GCC!" - export CC=gcc - export CXX=g++ - fi - - # Compilers - if [ "${CXX}" = "g++" ]; then - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - COMPILER_PACKAGE="g++-${VERSION}" - fi - - sudo apt-get -qq update - - # libgl1-mesa-dev, liblzma-dev, libxext-dev, zlib1g-dev already installed on - # build worker, I put these here in case the build image changes. - sudo apt-get -y install \ - cmake \ - ccache \ - libwxgtk3.0-gtk3-dev \ - libgtk-3-dev \ - libaio-dev \ - libasound2-dev \ - liblzma-dev \ - libsdl2-dev \ - libsoundtouch-dev \ - libxml2-dev \ - libpcap0.8-dev \ - libx11-xcb-dev \ - gir1.2-freedesktop \ - gir1.2-gdkpixbuf-2.0 \ - gir1.2-glib-2.0 \ - libcairo2-dev \ - libegl1-mesa-dev \ - libgdk-pixbuf2.0-dev \ - libgirepository-1.0-1 \ - libglib2.0-dev \ - libgl1-mesa-dev \ - libglu1-mesa-dev \ - libgtk2.0-dev \ - libharfbuzz-dev \ - libpango1.0-dev \ - libxext-dev \ - libxft-dev \ - portaudio19-dev \ - zlib1g-dev \ - ${COMPILER_PACKAGE} -} - - -linux_x64_script() { - mkdir build cd build - - if [ "${COMPILER}" = "clang" ]; then - export CC=clang - export CXX=clang++ - else - export CC=gcc - export CXX=g++ - fi - - export CCACHE_BASEDIR=${GITHUB_WORKSPACE} - export CCACHE_DIR=${GITHUB_WORKSPACE}/.ccache - export CCACHE_COMPRESS="true" - export CCACHE_COMPRESSLEVEL="6" - export CCACHE_MAXSIZE="400M" - - export CC=${CC}-${VERSION} CXX=${CXX}-${VERSION} - + # Prepare the Cache ccache -p ccache -z - - cmake \ - -D CMAKE_C_COMPILER_LAUNCHER=ccache \ - -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -D CMAKE_BUILD_TYPE=Devel \ - -D BUILD_REPLAY_LOADERS=TRUE \ - -D CMAKE_BUILD_PO=FALSE \ - -D GTK3_API=TRUE \ - .. - - make -j2 install - + # Build + make -j10 install + # Save the Cache ccache -s } -# Just in case I do manual testing and accidentally insert "rm -rf /" -case "${1}" in -before_install|script) - linux_${PLATFORM}_${1} +case $1 in +install_packages) + "$@" + exit ;; -*) - echo "Unknown command" && false +generate_cmake) + "$@" + exit + ;; +compile) + "$@" + exit ;; esac diff --git a/.github/workflows/windows-workflow.yml b/.github/workflows/windows-workflow.yml index 0b624e9ce3..e9cb034451 100644 --- a/.github/workflows/windows-workflow.yml +++ b/.github/workflows/windows-workflow.yml @@ -33,7 +33,6 @@ jobs: # GITHUB_CONTEXT: ${{ toJson(github) }} # run: | # echo "$GITHUB_CONTEXT" - # echo ${{ github.event.pull_request.title }} - name: Checkout Repository & Submodules uses: actions/checkout@v2 @@ -45,8 +44,8 @@ jobs: run: | echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}" echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")" - if [ ${{ github.event_name == 'pull_request' }}> ]; then - echo "##[set-output name=file-name-metadata;]pr-${{ github.event.pull_request.base.number }}" + if [ ${{ github.event_name == 'pull_request' }} ]; then + echo "##[set-output name=file-name-metadata;]pr-${{ github.event.pull_request.number }}" else echo "##[set-output name=file-name-metadata;]commit-$(git rev-parse --short "$GITHUB_SHA")" fi