Skip to content

Commit

Permalink
Use a makefile (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
DBraun committed Apr 2, 2024
1 parent 9330e1f commit 73aad75
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 130 deletions.
55 changes: 25 additions & 30 deletions .github/workflows/fauck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: FaucK

env:
FAUCK_VERSION: 0.0.3
CMAKE_OSX_DEPLOYMENT_TARGET: 12.0

on:
# Allows you to run this workflow manually from the Actions tab
Expand All @@ -24,18 +23,22 @@ jobs:
os: ubuntu-20.04
LIBFAUST_DIR: thirdparty/libfaust/ubuntu-x86_64/Release
CMAKE_OSX_ARCHITECTURES: "x86_64"
os-simple: linux
- name: macos-x86_64
os: macos-12
LIBFAUST_DIR: thirdparty/libfaust/darwin-x64/Release
CMAKE_OSX_ARCHITECTURES: "x86_64"
os-simple: mac
- name: macos-arm64
os: macos-12
LIBFAUST_DIR: thirdparty/libfaust/darwin-arm64/Release
CMAKE_OSX_ARCHITECTURES: "arm64"
os-simple: mac
- name: win64
os: windows-2022
LIBFAUST_DIR: thirdparty/libfaust/win64/Release
CMAKE_OSX_ARCHITECTURES: "x86_64"
os-simple: win

runs-on: ${{ matrix.os }}

Expand All @@ -44,6 +47,15 @@ jobs:
with:
submodules: true

- name: Install dependencies Windows
if: startsWith(matrix.os, 'windows')
shell: cmd
run: |
cd thirdparty
call download_libsndfile.bat
cd libfaust
call download_libfaust.bat
- name: Install dependencies ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: |
Expand Down Expand Up @@ -78,39 +90,22 @@ jobs:
run: |
brew install autoconf autogen automake flac libogg libtool libvorbis opus mpg123 pkg-config
- name: Install dependencies Windows
if: startsWith(matrix.os, 'windows')
run: |
cd thirdparty
curl -OL https://github.com/libsndfile/libsndfile/releases/download/1.2.0/libsndfile-1.2.0-win64.zip
7z x libsndfile-1.2.0-win64.zip -y
rm libsndfile-1.2.0-win64.zip
- name: Download Libfaust Windows
if: startsWith(matrix.os, 'windows')
- name: Build FaucK Release (Windows)
if: ${{ startsWith( matrix.name, 'win') }}
shell: cmd
run: |
cd thirdparty/libfaust
call download_libfaust.bat
- name: Download Libfaust macOS/Linux
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
run: |
cd thirdparty/libfaust && sh download_libfaust.sh
- name: Build Libsndfile
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
run: |
cd thirdparty/libsndfile
cmake -Bbuild -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_OSX_ARCHITECTURES=${{ matrix.CMAKE_OSX_ARCHITECTURES }} -DCMAKE_OSX_DEPLOYMENT_TARGET=$CMAKE_OSX_DEPLOYMENT_TARGET -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="./install"
cmake --build build --config Release
cmake --build build --target install
make ${{ matrix.os-simple }}
env:
CMAKE_OSX_ARCHITECTURES: ${{ matrix.CMAKE_OSX_ARCHITECTURES }}
LIBFAUST_DIR: ${{ matrix.LIBFAUST_DIR }}

- name: Build FaucK Release
- name: Build FaucK Release (macOS/Linux)
if: ${{ ! startsWith( matrix.name, 'win') }}
run: |
cmake -Bbuild -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_OSX_ARCHITECTURES=${{ matrix.CMAKE_OSX_ARCHITECTURES }} -DCMAKE_OSX_DEPLOYMENT_TARGET=$CMAKE_OSX_DEPLOYMENT_TARGET -DLIBFAUST_DIR=${{ github.workspace }}/${{ matrix.LIBFAUST_DIR }}
cmake --build build --config Release
cmake --build build --config Release --target install
make ${{ matrix.os-simple }}
env:
CMAKE_OSX_ARCHITECTURES: ${{ matrix.CMAKE_OSX_ARCHITECTURES }}
LIBFAUST_DIR: ${{ matrix.LIBFAUST_DIR }}

- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_STORE
build
build-release
build-debug
*.exe
49 changes: 41 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.13.0 FATAL_ERROR)

set(ROOT ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)

if (DEFINED ENV{FAUCK_VERSION})
set (VERSION $ENV{FAUCK_VERSION})
else()
Expand Down Expand Up @@ -29,7 +31,6 @@ set(ALL_FILES
${Sources}
)


#######################################
# faust libraries

Expand Down Expand Up @@ -69,7 +70,10 @@ install ( TARGETS FaucK
ARCHIVE DESTINATION ${PACKDIR}/${DST}
)

set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(${PROJECT_NAME} PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

add_compile_options(-fPIC)

if(APPLE)
Expand All @@ -93,7 +97,8 @@ install(
else()
set_target_properties (${PROJECT_NAME} PROPERTIES
SUFFIX ".chug"
OUTPUT_NAME Faust)
OUTPUT_NAME Faust
)
install(
DIRECTORY ${FAUST_LIBRARIES_DIR}
DESTINATION ${PACKDIR}/${DST}
Expand Down Expand Up @@ -179,16 +184,44 @@ target_include_directories(FaucK PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cheaders/include>
$<INSTALL_INTERFACE:FaucK> )

if (WIN32)
if (MSVC)
####################################
# install sndfile
install (
FILES ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libsndfile-1.2.0-win64/bin/sndfile.dll DESTINATION ${PACKDIR}/${DST}
)
endif()

if (APPLE)
install (
CODE "execute_process (COMMAND codesign --sign - --deep --force ${PACKDIR}/${DST}/Faust.chug)"
# Custom install command to copy the directory
if(MSVC)
set(SOURCE_FILE "${PACKDIR}/${DST}/Faust.chug")
set(DEST_DIR $ENV{USERPROFILE}/Documents/ChucK/chugins)
STRING(REGEX REPLACE "\\\\" "/" DEST_DIR ${DEST_DIR})
install(CODE "
message(\"Copying ${SOURCE_FILE} to ${DEST_DIR}\")
file(MAKE_DIRECTORY ${DEST_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy \"${SOURCE_FILE}\" \"${DEST_DIR}\"
)
endif()
")
set(SOURCE_DIR "${PACKDIR}/${DST}/faust")
set(DEST_DIR $ENV{USERPROFILE}/Documents/ChucK/chugins/faust)
STRING(REGEX REPLACE "\\\\" "/" DEST_DIR ${DEST_DIR})
install(CODE "
message(\"Copying ${SOURCE_DIR} to ${DEST_DIR}\")
file(MAKE_DIRECTORY ${DEST_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_directory \"${SOURCE_DIR}\" \"${DEST_DIR}\"
)
")
else()
set(SOURCE_DIR "${PACKDIR}/${DST}/Faust.chug")
set(DEST_DIR "$ENV{HOME}/.chuck/lib/Faust.chug")
install(CODE "
message(\"Copying ${SOURCE_DIR} to ${DEST_DIR}\")
file(MAKE_DIRECTORY ${DEST_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_directory \"${SOURCE_DIR}\" \"${DEST_DIR}\"
)
")
endif()
93 changes: 93 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Adapted from https://github.com/ccrma/chugl/blob/main/src/makefile

# chugin name
CHUGIN_NAME=Faust
# suffix
CHUGIN_SUFFIX=.chug

CMAKE_OSX_ARCHITECTURES ?=

# Determine the OS and architecture
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)

# Set LIBFAUST_DIR based on OS and architecture
ifeq ($(UNAME_S), Darwin)
ifeq ($(UNAME_M), arm64)
LIBFAUST_DIR ?= $(PWD)/thirdparty/libfaust/darwin-arm64/Release
else
LIBFAUST_DIR ?= $(PWD)/thirdparty/libfaust/darwin-x64/Release
endif
else ifeq ($(OS),Windows_NT)
LIBFAUST_DIR ?= thirdparty/libfaust/win64/Release
else
LIBFAUST_DIR ?= $(PWD)/thirdparty/libfaust/ubuntu-x86_64/Release
endif

CHUG=$(addsuffix $(CHUGIN_SUFFIX),$(CHUGIN_NAME))

########################## DEFAULT MAKE TARGET ################################
# default target: print usage message and quit
current:
@echo "[fauck build]: please use one of the following configurations:"
@echo " make mac, make linux, make win"

.PHONY: libfaust
libfaust:
@OS="`uname`"; \
if echo "$$OS" | grep -qE 'CYGWIN_NT|MINGW32_NT|MINGW64_NT'; then \
cd thirdparty/libfaust && cmd /C download_libfaust.bat; \
else \
cd thirdparty/libfaust && sh download_libfaust.sh; \
fi

.PHONY: libsndfile
libsndfile:
@OS="`uname`"; \
if echo "$$OS" | grep -qE 'CYGWIN_NT|MINGW32_NT|MINGW64_NT'; then \
cd thirdparty && cmd /C download_libsndfile.bat; \
else \
cd thirdparty/libsndfile && \
cmake -Bbuild -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_OSX_ARCHITECTURES=$(CMAKE_OSX_ARCHITECTURES) -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="./install" && \
cmake --build build --config Release && \
cmake --build build --target install; \
fi

build-release: libfaust libsndfile
cmake -DLIBFAUST_DIR=$(LIBFAUST_DIR) -B build-release -DCMAKE_BUILD_TYPE=Release

build-debug: libfaust libsndfile
cmake -DLIBFAUST_DIR=$(LIBFAUST_DIR) -B build-debug -DCMAKE_BUILD_TYPE=Debug

.PHONY: mac osx linux windows win win32 win64
mac osx linux windows win win32 win64: build-release
cmake --build build-release --config Release --target install

debug: build-debug
cmake --build build-debug
cp build-debug/Faust.chug .

# (mac/linux) remove system installed FaucK and install local FaucK
test-install:
@echo "[removing installed Faust.chug...]"
ifneq (,$(wildcard /usr/local/lib/chuck/Faust.chug))
sudo rm -rf /usr/local/lib/chuck/Faust.chug
endif
ifneq (,$(wildcard ~/.chuck/lib/Faust.chug))
rm -rf ~/.chuck/lib/Faust.chug
endif
@echo "[copying Faust.chug to local search path...]"
cp -r Faust.chug ~/.chuck/lib
@echo "[probing chugins...]"
@chuck --color --chugin-probe 2>&1 >/dev/null | grep Faust.chug

clean:
ifneq ("$(wildcard build-release)","")
cmake --build build-release --target clean
endif
ifneq ("$(wildcard build-debug)","")
cmake --build build-debug --target clean
endif

clean-all:
rm -rf $(CHUG) build-release build-debug
70 changes: 38 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,73 @@
# FaucK

FaucK is a [Chugin](https://github.com/ccrma/chugins) that combines the powerful, succinct [Functional AUdio STream (Faust) language](http://faust.grame.fr) with the strongly-timed [ChucK](http://chuck.stanford.edu) audio programming language. FaucK allows programmers to evaluate Faust code on-the-fly inside ChucK and control Faust signal processors using ChucK’s sample-precise timing and concurrency mechanisms. The goal is to create an amalgam that plays to the strengths of each language, giving rise to new possibilities for rapid prototyping, interaction design and controller mapping, pedagogy, and new ways of working with both Faust and ChucK.
FaucK is a [Chugin](https://github.com/ccrma/chugins) that combines the powerful, succinct [Functional AUdio STream (Faust) language](http://faust.grame.fr) with the strongly-timed [ChucK](http://chuck.stanford.edu) audio programming language. FaucK allows programmers to evaluate Faust code on-the-fly inside ChucK and control Faust signal processors using ChucK’s sample-precise timing and concurrency mechanisms. The goal is to create an amalgam that plays to the strengths of each language, giving rise to new possibilities for rapid prototyping, interaction design and controller mapping, pedagogy, and new ways of working with both Faust and ChucK.

## Compilation and Installation
## Compilation requirements

### Prerequisites for all platforms

**After fauck is built, it must be used with ChucK 1.5.2.0 or newer.**
### Compilation requirements for all platforms

You must install [cmake](https://cmake.org/download/) and [git](https://git-scm.com/downloads) so that they're accessible in Terminal/cmd prompts.

You may need to execute `git submodule update --init --recursive` in the `fauck` directory to make sure all submodules are cloned.

### Libsndfile

On Windows, the later scripts will automatically download `libsndfile`, so no action is needed.
### macOS requirements

On macOS, install the dependencies for libsndfile with `brew`:
* macOS version 12.0 or higher (due to Libfaust)
* Xcode and Xcode Command Line Tools

```brew install autoconf autogen automake flac lame libogg libtool libvorbis opus mpg123 pkg-config```
Install the dependencies for libsndfile with `brew`:

On Linux:
```bash
brew install autoconf autogen automake flac lame libogg libtool libvorbis opus mpg123 pkg-config
```

### Linux requirements

Install the dependencies for libsndfile:
```bash
sudo apt install autoconf autogen automake build-essential libasound2-dev \
libflac-dev libogg-dev libtool libvorbis-dev libopus-dev libmp3lame-dev \
libmpg123-dev pkg-config python
```

### Building FaucK

#### macOS/Linux
### Windows requirements

macOS Requirements:

* macOS version 11.0 or higher (due to Libfaust)
* Xcode and Xcode Command Line Tools
* 64-bit Windows, which you are almost certainly using.
* [7z.exe](https://www.7-zip.org/download.html) must be in your system PATH.
* You must have Visual Studio 2022 installed (due to Libfaust)

Navigate to `thirdparty/libfaust` and run `sh download_libfaust.sh` in Terminal.
## Building FaucK

In a Terminal window, navigate to this README and run `sh build_unix.sh`.
### macOS/Linux

Navigate to the `package` directory and find the latest `fauck` version such as `fauck-0.0.1`.
In the root of this repository, run

On macOS, you should expect to see a `Faust.chug` directory. Copy it to `usr/local/lib/chuck`.
```bash
make mac
```

On Linux you should see `Faust.chug`. Copy it to the chugins directory. Also download `https://github.com/grame-cncm/faustlibraries` next to the Faust.chug and name it `faust`.
Afterward, a `Faust.chug` directory will appear at `~/.chuck/lib/Faust.chug`.

Then run chuck with a FaucK example.
### Linux

#### Windows
In the root of this repository, run

* [7z.exe](https://www.7-zip.org/download.html) must be in your system PATH.
* You must have Visual Studio 2022 installed (due to Libfaust)
```bash
make linux
```

Next, create a **permanent** environment variable `CHUCK_CHUGIN_PATH` and set it equal to `%USERPROFILE%/Documents/ChucK/chugins`.
Afterward, a `Faust.chug` file will appear at `~/.chuck/lib/Faust.chug`. Next, download `https://github.com/grame-cncm/faustlibraries` next to the Faust.chug and name it `faust`.

Navigate to `thirdparty/libfaust`. Run `call download_libfaust.bat` in an cmd prompt.
### Windows

Open an `x64 Native Tools Command Prompt for Visual Studio 2022`, navigate to this README, and run `call build_windows.bat`.
Open an `x64 Native Tools Command Prompt for Visual Studio 2022`, navigate to this README, and run
```bash
make win
```

Navigate to the `package` directory and find the latest `fauck` version such as `fauck-0.0.1`. You should see a file `sndfile.dll`, which you should copy next to wherever `chuck.exe` exists on your computer (likely `C:/Program Files/ChucK/chuck.exe`). Next, copy `faust` and `Faust.chug` to `%USERPROFILE%/Documents/ChucK/chugins`.
Afterward, the file `Faust.chug` and directory `faust` should be in `%USERPROFILE%/Documents/ChucK/Chugins`.

Then run chuck with a FaucK example.
Navigate to this repository's `package` directory and find the latest `fauck` version such as `fauck-0.0.1`. You should see a file `sndfile.dll`, which you should copy next to wherever `chuck.exe` exists on your computer (likely `C:/Program Files/ChucK/chuck.exe`).

## Using FaucK

Expand Down
Loading

0 comments on commit 73aad75

Please sign in to comment.