Skip to content

Commit

Permalink
add cmake CI for github
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesneimog committed Jun 21, 2024
1 parent f93ecca commit 322d2d7
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 5 deletions.
201 changes: 201 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: Cmake
on:
workflow_dispatch:
push:
branches: ["pd.cmake"]
pull_request:
branches: ["pd.cmake"]
env:
LIBNAME: else
LIBVERSION: 1.0
jobs:
macos-universal-build:
runs-on: macos-latest
strategy:
matrix:
arch: [amd64, arm64] # NEED ADD MAC OS INTEL
precision: [32, 64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install PureData and Deps x86_64 Mac
if: ${{ matrix.arch == 'amd64' }}
run: |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
sudo rm '/usr/local/bin/idle3'
sudo rm '/usr/local/bin/idle3.12'
sudo rm '/usr/local/bin/pydoc3'
sudo rm '/usr/local/bin/pydoc3.12'
sudo rm '/usr/local/bin/python3'
sudo rm '/usr/local/bin/python3-config'
sudo rm '/usr/local/bin/python3.12'
sudo rm '/usr/local/bin/python3.12-config'
sudo rm /usr/local/bin/2to3
sudo rm /usr/local/bin/2to3-3.12
arch -x86_64 /usr/local/bin/brew install pd
arch -x86_64 /usr/local/bin/brew install glib --overwrite
- name: Install PureData and Deps arm64 Mac
if: ${{ matrix.arch == 'arm64' }}
run: |
brew install pd
- name: Build Object for Arm
if: ${{ matrix.arch == 'arm64' }}
run: |
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/homebrew/include/"
export LDFLAGS="-L/opt/homebrew/lib"
cmake . -B build -DCMAKE_OSX_ARCHITECTURES=arm64 -DPD_FLOATSIZE=${{ matrix.precision }} -DPDLIBDIR=./
cmake --build build -j $(sysctl -n hw.logicalcpu)
sudo make install -C build
- name: Build Object for x86_64
if: ${{ matrix.arch == 'amd64' }}
run: |
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/local/include/"
export LDFLAGS="-L/usr/local/lib"
cmake . -B build -DPD_FLOATSIZE=${{ matrix.precision }} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DPDLIBDIR=./
cmake --build build -j $(sysctl -n hw.logicalcpu)
sudo make install -C build
- name: Upload Object
uses: actions/upload-artifact@v4
with:
name: ${{env.LIBNAME}}-macos-${{matrix.arch}}-${{matrix.precision}}
path: ${{env.LIBNAME}}
windows-build:
runs-on: windows-latest
strategy:
matrix:
# TODO: msvc needs vcpkg support
compiler: [mingw] # , msvc ] # CHANGE: Choose between a compiler, you don't need boths
arch: [amd64]
precision: [32, 64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
# ──────────────────────────────────────
- if: matrix.compiler == 'msvc'
name: Set up Visual Studio Build Tools
uses: microsoft/setup-msbuild@v2
# TODO: Add vcpkg support
# ──────────────────────────────────────
- if: matrix.compiler == 'mingw'
name: Set up Msys2
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
install: make mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-cmake mingw-w64-x86_64-glib2
update: false
# ──────────────────────────────────────
- name: Install winget
uses: Cyberboss/install-winget@v1
- name: Install PureData Float 32
if: matrix.precision == '32'
run: |
winget install -e --id MillerPuckette.PureData --accept-source-agreements
- name: Install PureData Float 64
if: matrix.precision == '64'
run: |
winget install -e --id MillerPuckette.Pd64 --accept-source-agreements
- name: Configure and build Visual Studio
if: matrix.compiler == 'msvc'
run: |
cmake . -B build -DPD_FLOATSIZE=${{ matrix.precision }}
cmake --build build
- name: Configure and build Mingw
shell: msys2 {0}
if: matrix.compiler == 'mingw'
run: |
cmake . -B build -DPD_FLOATSIZE=${{ matrix.precision }} -DPDLIBDIR=./
cmake --build build -j 4
cmake --install build
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{env.LIBNAME}}-f${{ matrix.precision }}-windows-${{ matrix.compiler }}
path: ${{env.LIBNAME}}
linux-build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, aarch64, arm]
precision: [32, 64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: PureData Sources
run: |
sudo apt update
sudo add-apt-repository ppa:pure-data/pure-data -y
sudo apt install puredata -y
sudo apt install fftw3-dev -y
# Add here dynamic libraries that you use (ex. fftw3, gsl, ...).
# search for the name in https://packages.ubuntu.com/search
- name: Install aarch64 gcc
if: matrix.arch == 'aarch64'
run: |
sudo apt install gcc-aarch64-linux-gnu -y
sudo apt install g++-aarch64-linux-gnu -y
- name: Install arm gcc
if: matrix.arch == 'arm'
run: |
sudo apt install gcc-arm-linux-gnueabihf -y
sudo apt install g++-arm-linux-gnueabihf -y
- name: Build Object
if: matrix.arch == 'amd64'
run: |
cmake . -B build -DPD_FLOATSIZE=${{ matrix.precision }} -DPDLIBDIR=./
cmake --build build -- -j$(nproc)
sudo make install -C build
- name: Build Object
if: matrix.arch == 'aarch64'
run: |
cmake . -B build -DPD_FLOATSIZE=${{ matrix.precision }} -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DPDLIBDIR=./
cmake --build build -- -j$(nproc)
sudo make install -C build
- name: Build Object
if: matrix.arch == 'arm'
run: |
cmake . -B build -DPD_FLOATSIZE=${{ matrix.precision }} -DCMAKE_SYSTEM_PROCESSOR=arm -DPDLIBDIR=./
cmake --build build -- -j$(nproc)
sudo make install -C build
- name: Upload Object
uses: actions/upload-artifact@v4
with:
name: ${{ env.LIBNAME }}-linux-${{matrix.arch}}-${{matrix.precision}}
path: ${{env.LIBNAME}}
package-artifacts:
needs: [macos-universal-build, windows-build, linux-build]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: '${{ env.LIBNAME }}-*'
path: artifacts
merge-multiple: true
- name: Clear tmp files
run: rm -f artifacts/*.pdb
# ──────────────────────────────────────
- name: Install Deken
continue-on-error: true
run: |
mkdir -p ${PWD}/package
docker run --rm --user $(id -u) \
--volume ${PWD}/artifacts:/artifacts \
--volume ${PWD}/package:/package \
registry.git.iem.at/pd/deken \
deken package /artifacts --output-dir /package -v ${{env.LIBVERSION}} -n ${{env.LIBNAME}}
- name: Clear Artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.LIBNAME }}-*
- name: Upload Deken
uses: actions/upload-artifact@v4
with:
name: ${{ env.LIBNAME }}-${{env.LIBVERSION}}
path: "./package/"
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pd_add_external(var Code_source/Compiled/control/var.c)
# ╭──────────────────────────────────────╮
# │ SIGNAL │
# ╰──────────────────────────────────────╯

pd_add_external(above~ Code_source/Compiled/audio/above~.c)
pd_add_external(add~ Code_source/Compiled/audio/add~.c)
pd_add_external(allpass.2nd~ Code_source/Compiled/audio/allpass.2nd~.c)
Expand Down Expand Up @@ -336,7 +335,7 @@ pd_add_external(tabplayer~ "Code_source/Compiled/audio/tabplayer~.c;${bufmagic}"
# │ RANDBUF │
# ╰──────────────────────────────────────╯
list(APPEND randbuf "Code_source/shared/random.c")
list(APPEND randbuf ${MAGIC_CODE})
list(APPEND randbuf "Code_source/shared/buffer.c")

pd_add_external(gendyn~ "Code_source/Compiled/audio/gendyn~.c;${randbuf}")

Expand Down Expand Up @@ -410,8 +409,6 @@ pd_add_external(plaits~ "${PLAITS_SRC}")
list(APPEND SFONT_SRC "Code_source/Compiled/audio/sfont~/sfont~.c")
list(APPEND SFONT_SRC "Code_source/shared/elsefile.c")

pd_add_external(sfont~ "${SFONT_SRC}" TARGET sfont_tilde)

# ─────────── SFONT LIBRARIES ─────────
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS OFF)
Expand Down Expand Up @@ -443,7 +440,8 @@ set(enable-systemd OFF)

add_subdirectory(Resources/fluidsynth)
set_target_properties(libfluidsynth PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(sfont_tilde libfluidsynth)
pd_add_external(sfont~ "${SFONT_SRC}" TARGET sfont_tilde)
target_link_libraries(sfont_tilde PRIVATE libfluidsynth)

# ╭──────────────────────────────────────╮
# │ CIRCUIT │
Expand Down Expand Up @@ -474,6 +472,7 @@ target_include_directories(
${CIRCUIT_ROOT}/Libraries/libsamplerate
${CIRCUIT_ROOT}/Libraries/SuiteSparse_config
${CIRCUIT_ROOT}/Source)
target_compile_features(circuit_tilde PRIVATE cxx_std_17)

# ╭──────────────────────────────────────╮
# │ EXTRA FILES │
Expand All @@ -493,3 +492,13 @@ pd_add_datafile(
else
"${Control_Abs};${Audio_Abs};${Extra_Abs};${Tcl_Extra};${Scope3D};${Help_Files};${Extra_Files};${README};${Lua_Files}"
)

# ╭──────────────────────────────────────╮
# │ Dynamic Libraries │
# ╰──────────────────────────────────────╯
if(WIN32)
target_link_libraries(osc.format PRIVATE ws2_32)
target_link_libraries(osc.parse PRIVATE ws2_32)
endif()

add_definitions(-DHAVE_STRUCT_TIMESPEC)

0 comments on commit 322d2d7

Please sign in to comment.