Debian Codegraph @

tools/faust2appls/faust2linuxunity

raw symbols SCIP
1 #! /bin/bashscip-shell filesystem . . `/bin/bash`. -e
2
3 #############################################################################################################
4 # #
5 # Compiles Faust programs to Linux x86_64 library suitable for the Unity environment #
6 # #
7 # (c) Grame, 2017 #
8 # #
9 #############################################################################################################
10
11 # This script shouldn't be used on its own, use the "faust2unity" script instead
12 # The libraries are firstly wrapped by the unityplugin.cpp architecture file
13 # They have to be used in the Unity environment
14 # The libraries does not work by themselves, they need the FaustPlugin_<dspname>.cs and FaustUtilities_<dspname>.cs files to be functional
15 # These files are automatically generated by the "faust2unity" script
16
17 . faustpathscip-shell source . . faustpath.
18 . faustoptflagsscip-shell source . . faustoptflags.
19 . usage.shscip-shell source . . `usage.sh`.
20
21 CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used
22
23 NVOICES=-1
24
25 echoHelpscip-shell shell shell-project 0.0.0 echoHelp().()
26 {
27 usage faust2linuxunity "[options] [Faust options] <file.dsp>"
28 platform Linux
29 require Jack, Unity
30 echoscip-shell system . . echo. "Compiles Faust programs to Linux x86_64 libraries suitable for the Unity environment"
31 option
32 option "-nvoices <num>"
33 option "Faust options"
34 exit
35 }
36
37 if [scip-shell system . . `[`. "$#" -eq 0 ]; then
38 echoscip-shell system . . echo. 'Please, provide a Faust file to process !'
39 echoscip-shell system . . echo. ''
40 echoHelpscip-shell shell shell-project 0.0.0 echoHelp().
41 fi
42
43 #-------------------------------------------------------------------
44 # Dispatch command arguments
45
46 while [scip-shell system . . `[`. $1 ]
47 do
48 p=$1
49
50 if [scip-shell system . . `[`. $p = "-help" ] || [scip-shell system . . `[`. $p = "-h" ]; then
51 echoHelpscip-shell shell shell-project 0.0.0 echoHelp().
52 elif [scip-shell system . . `[`. $p = "-nvoices" ]; then
53 shift
54 NVOICES=$1
55 elif [scip-shell system . . `[`. ${p:0:1} = "-" ]; then
56 OPTIONS="$OPTIONS $p"
57 elif [[ -f "$p" ]] && [scip-shell system . . `[`. ${p: -4} == ".dsp" ]; then
58 FILES="$FILES $p"
59 else
60 OPTIONS="$OPTIONS $p"
61 fi
62
63 shift
64 done
65
66 #------------------------------------------------------------------------------
67 # Compiler g++
68 #
69
70 CXX="g++"
71 (whichscip-shell system . . which. "$CXX" >/dev/nullscip-shell filesystem . . `/dev/null`.) || (echoscip-shell system . . echo. "compiler $CXX not found. See -help for more info"; exit 1)
72
73 #-------------------------------------------------------------------
74 # Compiler settings
75
76 CXXFLAGS+=" -fPIC"
77 LIB="-shared"
78 EXT=".so"
79
80 #-------------------------------------------------------------------
81 # compile the *.dsp files
82
83 for p in $FILES; do
84
85 CUR=$(pwdscip-shell system . . pwd.)
86 f=$(basenamescip-shell system . . basename. "$p")
87 NAME=${f%.dsp}
88 FNAME=FaustPlugin_$NAME
89 LIBNAME=lib$FNAME$EXT
90 SRCDIR=$(dirnamescip-shell system . . dirname. "$p")
91 FIN=$FNAME/Linux
92
93 # creates a temporary dir
94 TDR=$(mktempscip-shell system . . mktemp. -d faust.XXXXXX)
95 TMP=$TDR/${f%.dsp}
96 mkdirscip-shell system . . mkdir. "$TMP"
97
98 # checks if final dir exists, if not creates it
99 if [scip-shell system . . `[`. ! -d "$FIN" ]; then
100 mkdirscip-shell system . . mkdir. -p "$FIN"
101 fi
102
103 # compile faust to c++
104 faust -uim -i -a $FAUSTARCH/unity/unityplugin.cpp $OPTIONS "$SRCDIR/$f" -o "$TMP/$NAME.cpp" || (echoscip-shell system . . echo. "$f : Faust to C++ compilation failed in faust2linuxunity"; exit 1)
105
106 # compile c++ to binary
107 (
108 cd "$TMP"
109 if [scip-shell system . . `[`. $NVOICES == -1 ]; then
110 $CXX $CXXFLAGS $LIB -Dmydsp=$NAME -o $LIBNAME $NAME.cpp
111 else
112 $CXX $CXXFLAGS $LIB -Dmydsp=$NAME -DPOLY -o $LIBNAME $NAME.cpp
113 fi
114 ) > /dev/nullscip-shell filesystem . . `/dev/null`. || (echoscip-shell system . . echo. "$f : C++ to linux library compilation failed in faust2linuxunity"; exit 1)
115
116 # moves binary to final dir
117 rmscip-shell system . . rm. -rf "$SRCDIR/$LIBNAME"
118 mvscip-shell system . . mv. "$TMP/$LIBNAME" "$FIN/$LIBNAME"
119 rmscip-shell system . . rm. -rf "$TDR"
120
121 echoscip-shell system . . echo. "$f : linux compilation completed"
122 done
123
124
125