Debian Codegraph @

tools/faust2appls/faust2bench

raw symbols SCIP
1 #! /bin/bash -e
2
3 #####################################################################
4 # #
5 # Compiles Faust programs to a bench #
6 # (c) Grame, 2022-2023 #
7 # #
8 #####################################################################
9
10 # Define some common paths
11 . faustpath
12
13 # Define compilation flags
14 . faustoptflags
15
16 # Helper file to build the 'help' option
17 . usage.sh
18
19 CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used
20
21 # The architecture file name
22 ARCHFILE=$FAUSTARCH/bench.cpp
23
24 # Global variables
25 OPTIONS=""
26 FILES=""
27 DOUBLE="0"
28
29 echoHelp()
30 {
31 usage faust2bench "[Faust options] <file.dsp>"
32 echo "Compiles Faust programs to a benchmark executable"
33 option "Faust options"
34 exit
35 }
36
37 if [ "$#" -eq 0 ]; then
38 echo 'Please, provide a Faust file to process !'
39 echo ''
40 echoHelp
41 fi
42
43 #-------------------------------------------------------------------
44 # dispatch command arguments
45 #-------------------------------------------------------------------
46
47 while [ $1 ]
48 do
49 p=$1
50
51 if [ $p = "-help" ] || [ $p = "-h" ]; then
52 echoHelp
53 elif [ "$p" = "-double" ]; then
54 DOUBLE="1"
55 OPTIONS="$OPTIONS $p"
56 elif [ ${p:0:1} = "-" ]; then
57 OPTIONS="$OPTIONS $p"
58 elif [[ -f "$p" ]] && [ ${p: -4} == ".dsp" ]; then
59 FILES="$FILES $p"
60 else
61 OPTIONS="$OPTIONS $p"
62 fi
63
64 shift
65
66 done
67
68 #-------------------------------------------------------------------
69 # compile the *.dsp files
70 #-------------------------------------------------------------------
71
72 for f in $FILES; do
73
74 # compile the DSP to c++ using the architecture file
75 faust -i -a $ARCHFILE $OPTIONS "$f" -o "${f%.dsp}_tmp.cpp"|| exit
76
77 # Create config file
78 echo -n >> Config
79 if [ $DOUBLE == "1" ]; then
80 echo "#define FAUSTFLOAT double" >> Config
81 else
82 echo "#define FAUSTFLOAT float" >> Config
83 fi
84 cat Config "${f%.dsp}_tmp.cpp" > "${f%.dsp}.cpp"
85
86 # compile c++ to binary
87 (
88 $CXX $CXXFLAGS "${f%.dsp}.cpp" -o "${f%.dsp}"
89 ) > /dev/null || exit
90
91 # remove temporary files
92 rm -f Config "${f%.dsp}.cpp" "${f%.dsp}_tmp.cpp"
93
94 # collect binary file name for FaustWorks
95 BINARIES="$BINARIES${f%.dsp};"
96 done
97
98 echo $BINARIES
99
100