Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add libfaust with llvm github action #862

Closed
wants to merge 3 commits into from
Closed
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
325 changes: 325 additions & 0 deletions .github/workflows/libfaust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
name: libfaust

# Controls when the action will run.
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

build-ubuntu:
strategy:
matrix:
include:
- name: ubuntu-x86_64
theContainer: docker://quay.io/pypa/manylinux2014_x86_64
os: ubuntu-20.04
cmake-options: >-
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_VERBOSE_MAKEFILE=ON
llvm-options: >-
-DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-linux-gnu"
-DLLVM_ENABLE_ZLIB=off
-DLLVM_OPTIMIZED_TABLEGEN=ON

runs-on: ${{ matrix.os }}
container:
image: ${{matrix.theContainer}}

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Restore libsndfile
id: cache-libsndfile-restore
uses: actions/cache/restore@v3
with:
path: libsndfile
key: cache-libsndfile-${{ matrix.name }}

- name: Clone libsndfile
if: steps.cache-libsndfile-restore.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: libsndfile/libsndfile
path: libsndfile

- name: Build libsndfile
if: steps.cache-libsndfile-restore.outputs.cache-hit != 'true'
run: |
cd libsndfile
cmake -Bbuild -G "Unix Makefiles" ${{matrix.cmake-options}} -DENABLE_EXTERNAL_LIBS=off -DBUILD_EXAMPLES=OFF
cmake --build build --config Release

- name: Cache libsndfile output
id: cache-libsndfile-save
uses: actions/cache/save@v3
with:
path: libsndfile
key: ${{ steps.cache-libsndfile-restore.outputs.cache-primary-key }}

- name: Restore LLVM
id: cache-llvm-restore
uses: actions/cache/restore@v3
with:
path: llvm-project
key: cache-llvm-${{ matrix.name }}

- name: Clone LLVM
if: steps.cache-llvm-restore.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: llvm/llvm-project
path: llvm-project
ref: f28c006a5895fc0e329fe15fead81e37457cb1d1

- name: Build LLVM
if: steps.cache-llvm-restore.outputs.cache-hit != 'true'
run: |
cd llvm-project/llvm
cmake -Bbuild -DCMAKE_INSTALL_PREFIX="./llvm" ${{matrix.cmake-options}} ${{matrix.llvm-options}}
cmake --build build --config Release

- name: Cache LLVM output
id: cache-llvm-save
uses: actions/cache/save@v3
with:
path: llvm-project
key: ${{ steps.cache-llvm-restore.outputs.cache-primary-key }}

- name: Build libfaust
run: |
cp -r libsndfile/include libsndfile/build/include
cd build
cmake -C ./backends/all.cmake . -Bbuild ${{matrix.cmake-options}} -DINCLUDE_DYNAMIC=ON -DINCLUDE_LLVM=ON -DUSE_LLVM_CONFIG=off -DINCLUDE_SNDFILE=ON -DSndFile_DIR=$SndFile_DIR -DCMAKE_PREFIX_PATH="$LLVM_DIR" -DCMAKE_MODULE_PATH="$SndFile_DIR/../cmake"
cmake --build build --config Release
env:
LLVM_DIR: ${{ github.workspace }}/llvm-project/llvm/build/lib/cmake/llvm
SndFile_DIR: ${{ github.workspace }}/libsndfile/build

- name: Make distribution
run: |
cd build/lib
rm -f libfaust.so libfaust.so.2
newest=$(ls -1 libfaust.so.* | tail -n1)
mv "$newest" libfaust.so
strip --strip-unneeded libfaust.so

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: libfaust-${{ matrix.name }}
path: build/lib
if-no-files-found: error

build-macos:
strategy:
matrix:
include:
- name: macos-x86_64
os: macos-11
cmake-options: >-
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_OSX_ARCHITECTURES="x86_64"
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
llvm-options: >-
-DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-apple-darwin19.6.0"
-DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_ENABLE_ZLIB=off
-DLLVM_OPTIMIZED_TABLEGEN=ON
-DCMAKE_INSTALL_PREFIX="./llvm"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Restore libsndfile
id: cache-libsndfile-restore
uses: actions/cache/restore@v3
with:
path: libsndfile
key: cache-libsndfile-${{ matrix.name }}

- name: Clone libsndfile
if: steps.cache-libsndfile-restore.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: libsndfile/libsndfile
path: libsndfile

- name: Install libsndfile MacOS dependencies
if: startsWith(matrix.os,'macos')
run: |
brew install automake autogen speex mpg123 lame flac libogg

- name: Build libsndfile
if: steps.cache-libsndfile-restore.outputs.cache-hit != 'true'
run: |
cd libsndfile
cmake -Bbuild -G "Unix Makefiles" ${{matrix.cmake-options}} -DENABLE_EXTERNAL_LIBS=off -DBUILD_EXAMPLES=OFF
cmake --build build --config Release

- name: Cache libsndfile output
id: cache-libsndfile-save
uses: actions/cache/save@v3
with:
path: libsndfile
key: ${{ steps.cache-libsndfile-restore.outputs.cache-primary-key }}

- name: Restore LLVM
id: cache-llvm-restore
uses: actions/cache/restore@v3
with:
path: llvm-project
key: cache-llvm-${{ matrix.name }}

- name: Clone LLVM
if: steps.cache-llvm-restore.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: llvm/llvm-project
path: llvm-project
ref: f28c006a5895fc0e329fe15fead81e37457cb1d1

- name: Build LLVM
if: steps.cache-llvm-restore.outputs.cache-hit != 'true'
run: |
cd llvm-project/llvm
cmake -Bbuild ${{matrix.cmake-options}} ${{matrix.llvm-options}}
cmake --build build --config Release

- name: Cache LLVM output
id: cache-llvm-save
uses: actions/cache/save@v3
with:
path: llvm-project
key: ${{ steps.cache-llvm-restore.outputs.cache-primary-key }}

- name: Build libfaust
run: |
cp -r libsndfile/include libsndfile/build/include
cd build
cmake -C ./backends/all.cmake . -Bbuild ${{matrix.cmake-options}} -DINCLUDE_DYNAMIC=ON -DINCLUDE_LLVM=ON -DUSE_LLVM_CONFIG=off -DINCLUDE_SNDFILE=ON -DSndFile_DIR=$SndFile_DIR -DCMAKE_PREFIX_PATH="$LLVM_DIR" -DCMAKE_MODULE_PATH="$SndFile_DIR/../cmake"
cmake --build build --config Release
env:
LLVM_DIR: ${{ github.workspace }}/llvm-project/llvm/build/lib/cmake/llvm
SndFile_DIR: ${{ github.workspace }}/libsndfile/build

- name: Make distribution
run: |
ls -r build/lib/*
mkdir libfaust
cp build/lib/libfaust.2.dylib libfaust/libfaust.2.dylib
cp -v -r build/lib/*.a libfaust

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: libfaust-${{ matrix.name }}
path: libfaust
if-no-files-found: error

build-windows:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: win-x86_64
os: windows-2022
cmake-options: >-
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_VERBOSE_MAKEFILE=ON
llvm-options: >-
-Thost=x64
-DLLVM_USE_CRT_DEBUG=MDd
-DLLVM_USE_CRT_RELEASE=MD
-DLLVM_BUILD_TESTS=Off
-DCMAKE_INSTALL_PREFIX="./llvm"
-DLLVM_ENABLE_ZLIB=off
-DLLVM_OPTIMIZED_TABLEGEN=ON
-DLLVM_TARGETS_TO_BUILD="X86;ARM"

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Restore libsndfile
id: cache-libsndfile-restore
uses: actions/cache/restore@v3
with:
path: libsndfile
key: cache-libsndfile-${{ matrix.name }}

- name: Clone libsndfile
if: steps.cache-libsndfile-restore.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: libsndfile/libsndfile
path: libsndfile

- name: Build libsndfile
if: steps.cache-libsndfile-restore.outputs.cache-hit != 'true'
run: |
cd libsndfile
cmake -Bbuild ${{matrix.cmake-options}} -DENABLE_EXTERNAL_LIBS=off -DBUILD_EXAMPLES=OFF
cmake --build build --config Release

- name: Cache libsndfile output
id: cache-libsndfile-save
uses: actions/cache/save@v3
with:
path: libsndfile
key: ${{ steps.cache-libsndfile-restore.outputs.cache-primary-key }}

- name: Restore LLVM
id: cache-llvm-restore
uses: actions/cache/restore@v3
with:
path: llvm-project
key: cache-llvm-${{ matrix.name }}

- name: Clone LLVM
if: steps.cache-llvm-restore.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: llvm/llvm-project
path: llvm-project
ref: f28c006a5895fc0e329fe15fead81e37457cb1d1

- name: Build LLVM
if: steps.cache-llvm-restore.outputs.cache-hit != 'true'
run: |
cd llvm-project/llvm
cmake -Bbuild ${{matrix.llvm-options}}
cmake --build build --config Release

- name: Cache LLVM output
id: cache-llvm-save
uses: actions/cache/save@v3
with:
path: llvm-project
key: ${{ steps.cache-llvm-restore.outputs.cache-primary-key }}

- name: Build libfaust
run: |
cp -r libsndfile/include libsndfile/build/include
cd build
cmake -C ./backends/all.cmake . -Bbuild ${{matrix.cmake-options}} -DINCLUDE_DYNAMIC=ON -DINCLUDE_LLVM=ON -DUSE_LLVM_CONFIG=off -DINCLUDE_SNDFILE=ON -DSndFile_DIR=%SndFile_DIR% -DCMAKE_PREFIX_PATH="%LLVM_DIR%" -DCMAKE_MODULE_PATH="%SndFile_DIR%/../cmake"
cmake --build build --config Release
env:
LLVM_DIR: ${{ github.workspace }}/llvm-project/llvm/build/lib/cmake/llvm
SndFile_DIR: ${{ github.workspace }}/libsndfile/build

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: libfaust-${{ matrix.name }}
path: build/lib/Release
if-no-files-found: error
24 changes: 20 additions & 4 deletions build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ option ( INCLUDE_HTTP "Include Faust HTTPD library" on )
option ( INCLUDE_ITP "Include Faust Machine library" off )
option ( INCLUDE_EMCC "Include emcc targets" on )
option ( INCLUDE_WASM_GLUE "Include wasm glue targets" on )
option ( INCLUDE_SNDFILE "Include Sndfile library" off )
option ( MSVC_STATIC "Use static runtimes with MSVC" off)
option ( SELF_CONTAINED_LIBRARY "Don't search system architecture files." off)

Expand Down Expand Up @@ -100,9 +101,15 @@ if (NOT MSVC)
set_property(SOURCE ${TMP}/llvm_dsp_aux.cpp ${TMP}/llvm_dynamic_dsp_aux.cpp APPEND_STRING PROPERTY COMPILE_FLAGS "-fno-rtti ${LLVM_DEFINITIONS}")
set_property(SOURCE ${TMP}/llvm_dsp_aux.cpp ${TMP}/llvm_dynamic_dsp_aux.cpp APPEND_STRING PROPERTY CMAKE_CXX_FLAGS "-fno-rtti ${LLVM_DEFINITIONS}")
endif()

if (INCLUDE_SNDFILE)
find_package(SndFile REQUIRED)
set (FAUST_LIBS ${FAUST_LIBS} SndFile::sndfile)
endif()

set (FAUST_LIBS ${FAUST_LIBS} ${LLVM_LD_FLAGS} ${LLVM_LIBS})

set (FAUST_DEFINITIONS ${FAUST_DEFINITIONS} -DLLVM_VERSION="${LLVM_PACKAGE_VERSION}")
set (FAUST_DEFINITIONS ${FAUST_DEFINITIONS} -DLLVM_VERSION="${LLVM_PACKAGE_VERSION}" -DLLVM_BUILD_UNIVERSAL)

if("${LLVM_PACKAGE_VERSION}" VERSION_GREATER_EQUAL 10)
set (CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -166,7 +173,10 @@ endif()
if (INCLUDE_EXECUTABLE)
add_executable(faust ${SRC} ${HH})
target_compile_definitions (faust PRIVATE ${FAUST_DEFINITIONS})
target_include_directories (faust PRIVATE ${FAUST_INC} ${LLVM_INC})
if(INCLUDE_LLVM)
target_link_directories(faust PRIVATE "${LLVM_INCLUDE_DIRS}/../lib")
endif()
target_include_directories (faust PRIVATE ${FAUST_INC} ${LLVM_INCLUDE_DIRS})
target_link_libraries (faust PRIVATE ${FAUST_LIBS})
scan_backends (faust COMPILER)
set_target_properties(faust PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BINDIR})
Expand All @@ -178,7 +188,10 @@ endif()
if (INCLUDE_STATIC)
add_library(staticlib STATIC ${SRC} ${HH})
target_compile_definitions (staticlib PRIVATE ${FAUST_DEFINITIONS})
target_include_directories (staticlib PRIVATE ${FAUST_INC} ${LLVM_INC})
if(INCLUDE_LLVM)
target_link_directories(staticlib PRIVATE "${LLVM_INCLUDE_DIRS}/../lib")
endif()
target_include_directories (staticlib PRIVATE ${FAUST_INC} ${LLVM_INCLUDE_DIRS})
target_link_libraries (staticlib PRIVATE ${FAUST_LIBS})
set_target_properties(staticlib PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR}
Expand Down Expand Up @@ -214,7 +227,10 @@ endif()
if (INCLUDE_DYNAMIC)
add_library(dynamiclib SHARED ${SRC} ${HH})
target_compile_definitions (dynamiclib PRIVATE ${FAUST_DEFINITIONS})
target_include_directories (dynamiclib PRIVATE ${FAUST_INC} ${LLVM_INC})
if(INCLUDE_LLVM)
target_link_directories(dynamiclib PRIVATE "${LLVM_INCLUDE_DIRS}/../lib")
endif()
target_include_directories (dynamiclib PRIVATE ${FAUST_INC} ${LLVM_INCLUDE_DIRS})
# set (FAUST_LIBS /usr/local/lib/libmir.a ${FAUST_LIBS})
target_link_libraries (dynamiclib PRIVATE ${FAUST_LIBS})
if (WIN32 OR MSYS)
Expand Down
Loading