Debian Codegraph @

tools/faust2appls/faust2jackrust

raw symbols SCIP
1 #! /usr/bin/env bash
2 set -e
3
4 #####################################################################
5 # #
6 # Compiles Faust programs to JACK and Rust binary #
7 # (c) Grame, 2017-2021 #
8 # #
9 #####################################################################
10
11 . faustpath
12 . faustoptflags
13 . usage.sh
14
15 SRC="0"
16 ARCHFILE=$FAUSTARCH/rust/jack-float.rs
17
18 echoHelp()
19 {
20 usage faust2jackrust "[-source] [Faust options] <file.dsp>"
21 echo "Compiles Faust programs to JACK and Rust binary"
22 option
23 option -source "only generates the source project."
24 option "Faust options"
25 }
26
27 if [ "$#" -eq 0 ]; then
28 echo 'Please, provide a Faust file to process !'
29 echo ''
30 echoHelp
31 fi
32
33 #PHASE 2 : dispatch command arguments
34 while [ $1 ]
35 do
36 p=$1
37
38 if [ $p = "-help" ] || [ $p = "-h" ]; then
39 echoHelp
40 elif [ $p = "-source" ]; then
41 SRC="1"
42 elif [ $p = "-double" ]; then
43 ARCHFILE=$FAUSTARCH/rust/jack-double.rs
44 OPTIONS="$OPTIONS $p"
45 elif [ ${p:0:1} = "-" ]; then
46 OPTIONS="$OPTIONS $p"
47 elif [[ -f "$p" ]] && [ ${p: -4} == ".dsp" ]; then
48 FILES="$FILES $p"
49 else
50 OPTIONS="$OPTIONS $p"
51 fi
52
53 shift
54
55 done
56
57 #-------------------------------------------------------------------
58 # compile the *.dsp files
59 #
60
61 for p in $FILES; do
62
63 f=$(basename "$p")
64 SRCDIR=$(dirname "$p")
65
66 # creates the dir
67 dspName="${f%.dsp}-jackrust"
68 rm -rf "$SRCDIR/$dspName"
69
70 # create rust project
71 pushd "$SRCDIR"
72 cargo new $dspName --bin
73 popd
74
75 # compile Faust DSP and put in the cargo folder
76 faust -a $ARCHFILE -lang rust $OPTIONS "$SRCDIR/$f" -o "$SRCDIR/$dspName/src/main.rs"
77
78 # add dependencies
79 cat <<EOT >> "$SRCDIR/$dspName/Cargo.toml"
80 jack = "0.5.3"
81 libm = "*"
82
83 [dependencies.default-boxed]
84 version = "0.2.0"
85 optional = true
86
87 [features]
88 default = ["default-boxed"]
89 default-boxed = ["dep:default-boxed"]
90 EOT
91
92 # build the project
93 if [ $SRC = "0" ]; then
94 (
95 cd "$SRCDIR/$dspName"
96 cargo build --release
97 cargo build
98 ) > /dev/null || exit
99
100 fi
101
102 done