From 8d39028508f31b866b783d1b9c251e7eb587b960 Mon Sep 17 00:00:00 2001
From: falkTX <falktx@falktx.com>
Date: Tue, 2 Jan 2024 11:54:05 +0100
Subject: [PATCH] Add linux-x86_64-debug build for testing

Signed-off-by: falkTX <falktx@falktx.com>
---
 .github/workflows/build.yml              | 89 +++++++++++++++++++++++-
 Makefile                                 | 20 +++++-
 src/PawPaw                               |  2 +-
 utils/plugin-builder/validate-plugins.sh |  3 -
 4 files changed, 104 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8856634..0a87d82 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,9 +3,9 @@ name: build
 on: [push, pull_request]
 
 env:
-  CACHE_VERSION_LINUX: 13
-  CACHE_VERSION_MACOS: 13
-  CACHE_VERSION_WIN64: 13
+  CACHE_VERSION_LINUX: 15
+  CACHE_VERSION_MACOS: 15
+  CACHE_VERSION_WIN64: 15
   DEBIAN_FRONTEND: noninteractive
   PAWPAW_SKIP_LTO: 1
   PAWPAW_SKIP_TESTS: 1
@@ -70,9 +70,11 @@ jobs:
         run: |
           ./src/PawPaw/bootstrap-mod.sh linux-x86_64 && ./src/PawPaw/.cleanup.sh linux-x86_64
       - name: Build
+        if: steps.cache.outputs.cache-hit == 'true'
         run: |
           make
       - name: Validate plugins
+        if: steps.cache.outputs.cache-hit == 'true'
         run: |
           ./utils/plugin-builder/validate-plugins.sh
           # FIXME dirty carla leaves temp folders around
@@ -81,6 +83,7 @@ jobs:
         run: |
           echo "SHA8=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_ENV
       - name: Pack
+        if: steps.cache.outputs.cache-hit == 'true'
         run: |
           mkdir mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64
           mv build mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64/mod-app
@@ -102,6 +105,86 @@ jobs:
           files: |
             *.tar.xz
 
+  linux-x86_64-debug:
+    strategy:
+      matrix:
+        include:
+          - container: ubuntu:18.04
+    runs-on: ubuntu-latest
+    container:
+      image: ${{ matrix.container }}
+    env:
+      PAWPAW_DEBUG: 1
+    steps:
+      - name: Install git
+        run: |
+          apt-get update -qq && apt-get install -yqq --no-install-recommends ca-certificates git openssl
+          case "${{ matrix.container }}" in
+            "ubuntu:18.04")
+              apt-get install -yqq --no-install-recommends curl libpcre2-8-0
+              curl -sLO https://launchpad.net/~kxstudio-debian/+archive/ubuntu/toolchain/+files/git_2.34.1-1ubuntu1~bpo18.04.1~ppa1_amd64.deb
+              curl -sLO https://launchpad.net/~kxstudio-debian/+archive/ubuntu/toolchain/+files/git-man_2.34.1-1ubuntu1~bpo18.04.1~ppa1_all.deb
+              dpkg -i *.deb
+              rm *.deb
+            ;;
+            "ubuntu:20.04")
+              apt-get install -yqq --no-install-recommends curl
+              curl -sLO https://launchpad.net/~kxstudio-debian/+archive/ubuntu/toolchain/+files/git_2.34.1-1ubuntu1~bpo20.04.1~ppa1_amd64.deb
+              curl -sLO https://launchpad.net/~kxstudio-debian/+archive/ubuntu/toolchain/+files/git-man_2.34.1-1ubuntu1~bpo20.04.1~ppa1_all.deb
+              dpkg -i *.deb
+              rm *.deb
+            ;;
+          esac
+      - uses: actions/checkout@v3
+        with:
+          submodules: recursive
+      - name: Set up dependencies
+        run: |
+          ./src/PawPaw/.github/workflows/bootstrap-deps.sh linux-x86_64
+          if [ "${{ matrix.container }}" = "ubuntu:18.04" ]; then
+            freetypepkgname="libfreetype6-dev"
+          else
+            freetypepkgname="libfreetype-dev"
+          fi
+          apt-get install -yqq ${freetypepkgname} p7zip-full unzip wget xdg-user-dirs zip
+      - name: Set up cache
+        id: cache
+        uses: actions/cache@v3
+        with:
+          path: |
+            ~/PawPawBuilds
+          key: linux-x86_64-${{ env.PAWPAW_PACK_NAME }}-v${{ env.CACHE_VERSION_LINUX }}-debug
+      - name: Build dependencies
+        run: |
+          ./src/PawPaw/bootstrap-mod.sh linux-x86_64 && ./src/PawPaw/.cleanup.sh linux-x86_64
+      - name: Build
+        if: steps.cache.outputs.cache-hit == 'true'
+        run: |
+          make DEBUG=1
+      - name: Validate plugins
+        if: steps.cache.outputs.cache-hit == 'true'
+        run: |
+          # FIXME plugin crashes
+          # ./utils/plugin-builder/validate-plugins.sh
+          # FIXME dirty carla leaves temp folders around
+          rm -rf *.tmp
+      - name: Set sha8
+        run: |
+          echo "SHA8=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_ENV
+      - name: Pack
+        if: steps.cache.outputs.cache-hit == 'true'
+        run: |
+          mkdir mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64-debug
+          mv build mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64-debug/mod-app
+          cp utils/linux/mod-app.* mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64-debug/
+          tar chJf mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64-debug.tar.xz mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64-debug
+      - uses: actions/upload-artifact@v3
+        if: ${{ matrix.container == env.RELEASE_OS_LINUX }}
+        with:
+          name: mod-app-${{ github.event.pull_request.number || env.SHA8 }}-linux-x86_64-debug
+          path: |
+            *.tar.xz
+
   macos:
     strategy:
       matrix:
diff --git a/Makefile b/Makefile
index 038bffa..9244390 100644
--- a/Makefile
+++ b/Makefile
@@ -68,9 +68,13 @@ SPACE = $(BLANK) $(BLANK)
 # ---------------------------------------------------------------------------------------------------------------------
 # Set PawPaw environment, matching PawPaw/setup/env.sh
 
+ifeq ($(PAWPAW_DEBUG),1)
+PAWPAW_SUFFIX = -debug
+endif
+
 PAWPAW_DIR = $(HOME)/PawPawBuilds
-PAWPAW_BUILDDIR = $(PAWPAW_DIR)/builds/$(PAWPAW_TARGET)
-PAWPAW_PREFIX = $(PAWPAW_DIR)/targets/$(PAWPAW_TARGET)
+PAWPAW_BUILDDIR = $(PAWPAW_DIR)/builds/$(PAWPAW_TARGET)$(PAWPAW_SUFFIX)
+PAWPAW_PREFIX = $(PAWPAW_DIR)/targets/$(PAWPAW_TARGET)$(PAWPAW_SUFFIX)
 
 # ---------------------------------------------------------------------------------------------------------------------
 # List of files created by PawPaw bootstrap, to ensure we have run it at least once
@@ -170,8 +174,10 @@ PLUGINS += artyfx
 PLUGINS += bolliedelay
 PLUGINS += caps-lv2
 PLUGINS += carla-plugins
-# crashing linux https://github.com/moddevices/mod-app/actions/runs/7367984567/job/20054758659
+ifneq ($(LINUX)$(PAWPAW_DEBUG),true)
+# crashing linux https://github.com/moddevices/mod-app/actions/runs/7386470509/job/20093130067
 PLUGINS += chow-centaur
+endif
 PLUGINS += die-plugins
 PLUGINS += dpf-plugins
 PLUGINS += dragonfly-reverb
@@ -185,7 +191,10 @@ PLUGINS += mod-cv-plugins
 PLUGINS += mod-distortion
 PLUGINS += mod-mda-lv2
 PLUGINS += mod-midi-utilities
+ifneq ($(PAWPAW_DEBUG),1)
+# build issues https://github.com/moddevices/mod-app/actions/runs/7386470509/job/20093128972
 PLUGINS += mod-pitchshifter
+endif
 PLUGINS += mod-utilities
 PLUGINS += modmeter
 PLUGINS += modspectre
@@ -217,6 +226,11 @@ ifneq ($(PAWPAW_TARGET),macos-10.15)
 PLUGINS += fluidplug
 endif
 
+# TESTING
+ifeq ($(PAWPAW_DEBUG),1)
+PLUGINS = chow-centaur
+endif
+
 # conflict with lv2-dev
 # PLUGINS += lv2-examples
 
diff --git a/src/PawPaw b/src/PawPaw
index 7822bb0..94eb0a1 160000
--- a/src/PawPaw
+++ b/src/PawPaw
@@ -1 +1 @@
-Subproject commit 7822bb0ba1deb75b3010d6efab63a4f854174b56
+Subproject commit 94eb0a16fd40bebc1c36af245850d988f39e8e4b
diff --git a/utils/plugin-builder/validate-plugins.sh b/utils/plugin-builder/validate-plugins.sh
index e827aeb..1e6620d 100755
--- a/utils/plugin-builder/validate-plugins.sh
+++ b/utils/plugin-builder/validate-plugins.sh
@@ -57,8 +57,5 @@ PLUGINS=($(${EXE_WRAPPER} "${PAWPAW_PREFIX}/lib/carla/carla-discovery-native${AP
 for p in ${PLUGINS[@]}; do
     uri=$(echo ${p} | cut -d "${OS_SEP}" -f 2-)
     echo "Testing ${uri}..."
-    # FIXME skip plugins that fail to verify but where local builds are ok
-    if [ "${LINUX}" -eq 0 ] || [ "${uri}" != "https://github.com/jatinchowdhury18/KlonCentaur" ]; then
     ${EXE_WRAPPER} "${PAWPAW_PREFIX}/lib/carla/carla-bridge-native${APP_EXT}" lv2 "" "${uri}" 1>/dev/null
-    fi
 done