Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 102 additions & 4 deletions .github/workflows/plugins_build_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:

env:
CSOUND_VERSION: 7.0.0-beta.18
FAUST_VERSION: 2.88.0
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/vcpkg-cache,readwrite"

jobs:
Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:
libsndfile1-dev libasound2-dev libportaudio2 libportmidi-dev \
libeigen3-dev libfluidsynth-dev libpng-dev \
libwebsockets-dev libuv1-dev libhdf5-dev \
ocl-icd-opencl-dev \
ocl-icd-opencl-dev libtinfo-dev \
flex bison

- name: Cache Csound install
Expand All @@ -94,16 +95,45 @@ jobs:
cmake --build "$RUNNER_TEMP/csound-build" --parallel "$(nproc)"
cmake --install "$RUNNER_TEMP/csound-build"

- name: Cache Faust
id: cache-faust
uses: actions/cache@v4
with:
path: ~/faust
key: faust-${{ runner.os }}-${{ runner.arch }}-${{ env.FAUST_VERSION }}

- name: Install Faust
if: steps.cache-faust.outputs.cache-hit != 'true'
run: |
mkdir -p "$HOME/faust"
curl -sL -o "$RUNNER_TEMP/libfaust.zip" \
"https://github.com/grame-cncm/faust/releases/download/$FAUST_VERSION/libfaust-ubuntu-x86_64.zip"
curl -sL -o "$RUNNER_TEMP/faust-src.tar.gz" \
"https://github.com/grame-cncm/faust/releases/download/$FAUST_VERSION/faust-$FAUST_VERSION.tar.gz"
unzip -q "$RUNNER_TEMP/libfaust.zip" -d "$HOME/faust"
tar xzf "$RUNNER_TEMP/faust-src.tar.gz" -C "$RUNNER_TEMP" \
"faust-$FAUST_VERSION/architecture" "faust-$FAUST_VERSION/libraries"
mv "$RUNNER_TEMP/faust-$FAUST_VERSION/architecture" "$HOME/faust/include"
mv "$RUNNER_TEMP/faust-$FAUST_VERSION/libraries" "$HOME/faust/stdlib"
rm -f "$RUNNER_TEMP/libfaust.zip" "$RUNNER_TEMP/faust-src.tar.gz"

- name: Configure plugin build
run: |
echo "CSOUND_INCLUDE_DIR_HINT=$HOME/csound-install/include/csound" >> "$GITHUB_ENV"
echo "CSOUND_LIBRARY_DIR_HINT=$HOME/csound-install/lib" >> "$GITHUB_ENV"
echo "FAUST_INCLUDE_DIR_HINT=$HOME/faust/include" >> "$GITHUB_ENV"
echo "FAUST_LIB_DIR_HINT=$HOME/faust/lib" >> "$GITHUB_ENV"
echo "FAUST_STDLIB_DIR_HINT=$HOME/faust/stdlib" >> "$GITHUB_ENV"

- name: Build plugins
run: |
cmake -S 7.x -B build -DCMAKE_BUILD_TYPE=Release \
-DFAUST_STATIC=ON \
-DCSOUND_INCLUDE_DIR_HINT="$CSOUND_INCLUDE_DIR_HINT" \
-DCSOUND_LIBRARY_DIR_HINT="$CSOUND_LIBRARY_DIR_HINT"
-DCSOUND_LIBRARY_DIR_HINT="$CSOUND_LIBRARY_DIR_HINT" \
-DFAUST_INCLUDE_DIR_HINT="$FAUST_INCLUDE_DIR_HINT" \
-DFAUST_LIB_DIR_HINT="$FAUST_LIB_DIR_HINT" \
-DFAUST_STDLIB_DIR_HINT="$FAUST_STDLIB_DIR_HINT"
cmake --build build --parallel "$(nproc)"

- name: Stage plugins
Expand All @@ -118,8 +148,11 @@ jobs:
build/src/py/*.so \
build/src/OpenCL/*.so \
build/src/stk/*.so package/
cp build/src/faustcsound/*.so package/
mkdir -p package/stk/rawwaves
cp 7.x/src/stk/rawwaves/*.raw package/stk/rawwaves/
mkdir -p package/faust
cp -R "$HOME/faust/stdlib/." package/faust/

- name: Upload plugins
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -192,6 +225,33 @@ jobs:
cmake --build "$RUNNER_TEMP/csound-build" --parallel "$(sysctl -n hw.ncpu)"
cmake --install "$RUNNER_TEMP/csound-build"

- name: Cache Faust
id: cache-faust
uses: actions/cache@v4
with:
path: ~/faust
key: faust-${{ runner.os }}-${{ runner.arch }}-${{ env.FAUST_VERSION }}

- name: Install Faust
if: steps.cache-faust.outputs.cache-hit != 'true'
run: |
if [ "$(uname -m)" = "arm64" ]; then
asset="Faust-$FAUST_VERSION-arm64.dmg"
else
asset="Faust-$FAUST_VERSION-x64.dmg"
fi
curl -sL -o "$RUNNER_TEMP/faust.dmg" \
"https://github.com/grame-cncm/faust/releases/download/$FAUST_VERSION/$asset"
mkdir -p "$HOME/faust" "$RUNNER_TEMP/faust_dmg"
hdiutil attach "$RUNNER_TEMP/faust.dmg" \
-mountpoint "$RUNNER_TEMP/faust_dmg" -nobrowse -quiet
root=$(dirname "$(find "$RUNNER_TEMP/faust_dmg" -maxdepth 2 -type d -name include | head -1)")
cp -R "$root/include" "$HOME/faust/include"
cp -R "$root/lib" "$HOME/faust/lib"
cp -R "$root/share/faust" "$HOME/faust/stdlib"
hdiutil detach "$RUNNER_TEMP/faust_dmg" -quiet
rm -f "$RUNNER_TEMP/faust.dmg"

- name: Configure plugin build
run: |
framework="$HOME/csound-install/Frameworks/CsoundLib64.framework"
Expand All @@ -202,14 +262,21 @@ jobs:
echo "CSOUND_INCLUDE_DIR_HINT=$headers" >> "$GITHUB_ENV"
echo "CSOUND_FRAMEWORK_DIR_HINT=$HOME/csound-install/Frameworks" >> "$GITHUB_ENV"
echo "CSOUND_LIBRARY_DIR_HINT=$HOME/csound-install/Frameworks" >> "$GITHUB_ENV"
echo "FAUST_INCLUDE_DIR_HINT=$HOME/faust/include" >> "$GITHUB_ENV"
echo "FAUST_LIB_DIR_HINT=$HOME/faust/lib" >> "$GITHUB_ENV"
echo "FAUST_STDLIB_DIR_HINT=$HOME/faust/stdlib" >> "$GITHUB_ENV"

- name: Build plugins
run: |
cmake -S 7.x -B build -DCMAKE_BUILD_TYPE=Release \
-DUSE_VCPKG=ON \
-DFAUST_STATIC=ON \
-DCSOUND_INCLUDE_DIR_HINT="$CSOUND_INCLUDE_DIR_HINT" \
-DCSOUND_FRAMEWORK_DIR_HINT="$CSOUND_FRAMEWORK_DIR_HINT" \
-DCSOUND_LIBRARY_DIR_HINT="$CSOUND_LIBRARY_DIR_HINT"
-DCSOUND_LIBRARY_DIR_HINT="$CSOUND_LIBRARY_DIR_HINT" \
-DFAUST_INCLUDE_DIR_HINT="$FAUST_INCLUDE_DIR_HINT" \
-DFAUST_LIB_DIR_HINT="$FAUST_LIB_DIR_HINT" \
-DFAUST_STDLIB_DIR_HINT="$FAUST_STDLIB_DIR_HINT"
cmake --build build --parallel "$(sysctl -n hw.ncpu)"

- name: Stage plugins
Expand All @@ -224,8 +291,11 @@ jobs:
build/src/py/*.dylib \
build/src/OpenCL/*.dylib \
build/src/stk/*.dylib package/
cp build/src/faustcsound/*.dylib package/
mkdir -p package/stk/rawwaves
cp 7.x/src/stk/rawwaves/*.raw package/stk/rawwaves/
mkdir -p package/faust
cp -R "$HOME/faust/stdlib/." package/faust/

- name: Upload plugins
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -294,6 +364,23 @@ jobs:
cmake --build csound-build --config Release --parallel
cmake --install csound-build --config Release

- name: Cache Faust
id: cache-faust
uses: actions/cache@v4
with:
path: ~/faust
key: faust-${{ runner.os }}-${{ runner.arch }}-${{ env.FAUST_VERSION }}

- name: Install Faust
if: steps.cache-faust.outputs.cache-hit != 'true'
run: |
$faustDir = Join-Path $env:USERPROFILE 'faust'
New-Item -ItemType Directory -Force -Path $faustDir | Out-Null
curl.exe -sL -o "$env:RUNNER_TEMP\faust.exe" `
"https://github.com/grame-cncm/faust/releases/download/$env:FAUST_VERSION/Faust-$env:FAUST_VERSION-win64.exe"
& 'C:\Program Files\7-Zip\7z.exe' x "$env:RUNNER_TEMP\faust.exe" "-o$faustDir" -y | Out-Null
Remove-Item "$env:RUNNER_TEMP\faust.exe"

- name: Configure plugin build
run: |
$install = Join-Path $env:RUNNER_TEMP 'csound-install'
Expand All @@ -305,13 +392,21 @@ jobs:
if (-not $lib) { throw "csound64.lib not found under $install" }
"CSOUND_INCLUDE_DIR_HINT=$($header.DirectoryName)" >> $env:GITHUB_ENV
"CSOUND_LIBRARY_DIR_HINT=$($lib.DirectoryName)" >> $env:GITHUB_ENV
$faustDir = Join-Path $env:USERPROFILE 'faust'
"FAUST_INCLUDE_DIR_HINT=$faustDir\include" >> $env:GITHUB_ENV
"FAUST_LIB_DIR_HINT=$faustDir\lib" >> $env:GITHUB_ENV
"FAUST_STDLIB_DIR_HINT=$faustDir\share\faust" >> $env:GITHUB_ENV

- name: Build plugins
run: |
cmake -S 7.x -B build -A x64 `
-DUSE_VCPKG=ON `
-DFAUST_STATIC=ON `
-DCSOUND_INCLUDE_DIR_HINT="$env:CSOUND_INCLUDE_DIR_HINT" `
-DCSOUND_LIBRARY_DIR_HINT="$env:CSOUND_LIBRARY_DIR_HINT"
-DCSOUND_LIBRARY_DIR_HINT="$env:CSOUND_LIBRARY_DIR_HINT" `
-DFAUST_INCLUDE_DIR_HINT="$env:FAUST_INCLUDE_DIR_HINT" `
-DFAUST_LIB_DIR_HINT="$env:FAUST_LIB_DIR_HINT" `
-DFAUST_STDLIB_DIR_HINT="$env:FAUST_STDLIB_DIR_HINT"
cmake --build build --config Release --parallel

- name: Stage plugins
Expand All @@ -328,6 +423,9 @@ jobs:
$rawwaves = Join-Path $package 'stk/rawwaves'
New-Item -ItemType Directory -Force -Path $rawwaves | Out-Null
Copy-Item '7.x\src\stk\rawwaves\*.raw' -Destination $rawwaves
$faustOut = Join-Path $package 'faust'
New-Item -ItemType Directory -Force -Path $faustOut | Out-Null
Copy-Item "$env:USERPROFILE\faust\share\faust\*" -Destination $faustOut -Recurse

- name: Upload plugins
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions 7.x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,4 @@ add_subdirectory(./src/p5glove)
add_subdirectory(./src/CUDA)
add_subdirectory(./src/OpenCL)
add_subdirectory(./src/stk)
add_subdirectory(./src/faustcsound)
109 changes: 78 additions & 31 deletions 7.x/cmake/Modules/FindFAUST.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Find Faust2
include(FindPackageHandleStandardArgs)

# When ON, link against the self-contained static library that bundles LLVM
# (libfaustwithllvm on Linux/macOS, libfaustwithllvm.lib on Windows). This
# produces a plugin with no runtime dependency on libfaust.
option(FAUST_STATIC "Link against a static libfaust that bundles LLVM" OFF)

find_path(FAUST_INCLUDE_DIR faust/dsp/llvm-dsp.h
HINTS
C:/Program Files/Faust/include/
Expand All @@ -10,49 +15,91 @@ find_path(FAUST_INCLUDE_DIR faust/dsp/llvm-dsp.h
"${FAUST_INCLUDE_DIR_HINT}"
)

find_library(FAUST_LIBRARY
NAMES
libfaust.so
libfaust.dylib
faust.dll
faust
libfaust
if(FAUST_STATIC)
find_library(FAUST_LIBRARY
NAMES
libfaustwithllvm.lib
libfaustwithllvm.a
faustwithllvm
HINTS
"${FAUST_LIB_DIR_HINT}"
)
else()
find_library(FAUST_LIBRARY
NAMES
libfaust.so
libfaust.dylib
faust.dll
faust
libfaust
HINTS
"${FAUST_LIB_DIR_HINT}"
)
endif()

# Locate the Faust standard library (containing stdfaust.lib). It is shipped
# as share/faust in the binary packages and as libraries/ in the source tree.
find_path(FAUST_STDLIB_DIR stdfaust.lib
HINTS
"${FAUST_LIB_DIR_HINT}"
"${FAUST_STDLIB_DIR_HINT}"
"${FAUST_LIB_DIR_HINT}/../share/faust"
"${FAUST_INCLUDE_DIR_HINT}/../share/faust"
"${FAUST_LIB_DIR_HINT}/../libraries"
"${FAUST_INCLUDE_DIR_HINT}/../libraries"
"${FAUST_INCLUDE_DIR_HINT}/../share/faust"
)

find_package_handle_standard_args(FAUST FAUST_INCLUDE_DIR FAUST_LIBRARY)

if(FAUST_FOUND)
set(FAUST_LIBRARIES ${FAUST_LIBRARY})
set(FAUST_INCLUDE_DIRS ${FAUST_INCLUDE_DIR})

if("${FAUST_LIBRARY}" MATCHES ".*\\.a")
# This is a static build of faust, hence
# we have to add all the LLVM flags...
if(FAUST_STATIC)
# libfaustwithllvm bundles LLVM, so only platform libraries are needed.
if(WIN32)
set(FAUST_LIBRARIES ${FAUST_LIBRARY}
ws2_32 crypt32 dbghelp ole32 shell32 psapi bcrypt
version uuid user32 advapi32 ntdll)
elseif(APPLE)
set(FAUST_LIBRARIES ${FAUST_LIBRARY} z)
else()
set(_faust_syslibs dl pthread z)
find_library(FAUST_TINFO_LIBRARY NAMES tinfo ncurses)
if(FAUST_TINFO_LIBRARY)
list(APPEND _faust_syslibs ${FAUST_TINFO_LIBRARY})
endif()
set(FAUST_LIBRARIES ${FAUST_LIBRARY} ${_faust_syslibs})
endif()
else()
set(FAUST_LIBRARIES ${FAUST_LIBRARY})

find_program(LLVM_CONFIG llvm-config
HINTS
/usr/bin
/usr/local/bin
/usr/local/opt/llvm/bin
)
if("${FAUST_LIBRARY}" MATCHES ".*\\.a")
# This is a static build of faust without LLVM, hence
# we have to add all the LLVM flags...

if(NOT LLVM_CONFIG)
message(WARNING "Using a static Faust library requires LLVM tooling to be present in the path.")
UNSET(FAUST_FOUND)
else()
exec_program(${LLVM_CONFIG} ARGS --includedir OUTPUT_VARIABLE LLVM_DIR)
exec_program(${LLVM_CONFIG} ARGS --libs OUTPUT_VARIABLE LLVM_LIBS)
exec_program(${LLVM_CONFIG} ARGS --version OUTPUT_VARIABLE LLVM_VERSION)
exec_program(${LLVM_CONFIG} ARGS --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS)
find_program(LLVM_CONFIG llvm-config
HINTS
/usr/bin
/usr/local/bin
/usr/local/opt/llvm/bin
)

set(LLVM_VERSION LLVM_${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})
if(NOT LLVM_CONFIG)
message(WARNING "Using a static Faust library requires LLVM tooling to be present in the path.")
UNSET(FAUST_FOUND)
else()
exec_program(${LLVM_CONFIG} ARGS --includedir OUTPUT_VARIABLE LLVM_DIR)
exec_program(${LLVM_CONFIG} ARGS --libs OUTPUT_VARIABLE LLVM_LIBS)
exec_program(${LLVM_CONFIG} ARGS --version OUTPUT_VARIABLE LLVM_VERSION)
exec_program(${LLVM_CONFIG} ARGS --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS)

find_package(OpenSSL REQUIRED)
set(FAUST_LIBRARIES ${FAUST_LIBRARIES} dl ${OPENSSL_LIBRARIES} ncurses z ${LLVM_LDFLAGS} ${LLVM_LIBS} )
endif()
endif()
set(LLVM_VERSION LLVM_${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})

find_package(OpenSSL REQUIRED)
set(FAUST_LIBRARIES ${FAUST_LIBRARIES} dl ${OPENSSL_LIBRARIES} ncurses z ${LLVM_LDFLAGS} ${LLVM_LIBS} )
endif()
endif()
endif()
else()
set(FAUST_LIBRARIES)
set(FAUST_INCLUDE_DIRS)
Expand Down
57 changes: 57 additions & 0 deletions 7.x/src/faustcsound/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Build faustcsound opcodes
option(BUILD_FAUST_OPCODES "Build the Faust opcodes" ON)

find_package(FAUST)
check_deps(BUILD_FAUST_OPCODES FAUST_FOUND)

if(BUILD_FAUST_OPCODES AND FAUST_FOUND)
message(STATUS "Faust library: ${FAUST_LIBRARY}")

make_plugin(faustcsound faustgen.cpp)

target_include_directories(faustcsound PRIVATE
${CSOUND_INCLUDE_DIRS}
${FAUST_INCLUDE_DIR})
target_compile_definitions(faustcsound PRIVATE "-DFAUSTFLOAT=cs_float")

if(PTHREAD_LIBRARY)
target_compile_definitions(faustcsound PRIVATE "-DHAVE_PTHREAD")
endif()

target_link_libraries(faustcsound
${FAUST_LIBRARIES}
${PTHREAD_LIBRARY}
${CMAKE_DL_LIBS})

if(APPLE)
set_target_properties(faustcsound PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
)
endif()

if(FAUST_STATIC)
# libfaustwithllvm bundles LLVM; without this the plugin would export
# the hundreds of thousands of LLVM/Faust symbols from the archive.
if(APPLE)
set_target_properties(faustcsound PROPERTIES LINK_FLAGS
"-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/faustcsound.exports")
elseif(UNIX)
set_target_properties(faustcsound PROPERTIES LINK_FLAGS
"-Wl,--exclude-libs,ALL")
endif()
endif()

# Install the Faust standard library next to the plugin and point the
# plugin at it, so programs using import("stdfaust.lib") work without a
# separate Faust installation.
if(FAUST_STDLIB_DIR)
message(STATUS "Faust standard library: ${FAUST_STDLIB_DIR}")
install(DIRECTORY "${FAUST_STDLIB_DIR}/"
DESTINATION "${PLUGIN_INSTALL_DIR}/faust")
target_compile_definitions(faustcsound PRIVATE
"DEFAULT_FAUST_LIB_PATH=\"${PLUGIN_INSTALL_DIR}/faust\"")
else()
message(WARNING "Faust standard library (stdfaust.lib) not found; "
"set FAUST_STDLIB_DIR_HINT to enable import(\"stdfaust.lib\")")
endif()
endif()
Loading
Loading