Debian Codegraph @

tools/faust2appls/faust2androidunity

raw symbols SCIP
1 #! /bin/bashscip-shell filesystem . . `/bin/bash`. -e
2
3 #############################################################################################################
4 # #
5 # Compiles Faust programs to Android libraries for the Unity environment #
6 # suitable for armeabi-v7a and x86 Android architectures #
7 # #
8 # (c) Grame, 2017 #
9 # #
10 #############################################################################################################
11
12 # This script shouldn't be used on its own, use the "faust2unity" script instead
13 # The libraries are firstly wrapped by the unityplugin.cpp architecture file
14 # They have to be used in the Unity environment
15 # The libraries does not work by themselves, they need the FaustPlugin_<dspname>.cs and FaustUtilities_<dspname>.cs files to be functional
16 # These files are automatically generated by the "faust2unity" script
17
18 . faustpathscip-shell source . . faustpath.
19 . faustoptflagsscip-shell source . . faustoptflags.
20 . usage.shscip-shell source . . `usage.sh`.
21
22 CXXFLAGS+=" $MYGCCFLAGS" # So that additional CXXFLAGS can be used
23
24 NVOICES=-1
25 ANDROID_MK=Android.mk
26
27 echoHelpscip-shell shell shell-project 0.0.0 echoHelp().()
28 {
29 usage faust2androidunity "[options] [Faust options] <file1.dsp> [<file2.dsp>]"
30 platform Android Unity
31 require Android SDK "Make sure the ANDROID_HOME environment variable is set to the sdk folder."
32 echoscip-shell system . . echo. "Creates android libraries (armeabi-v7a and x86) for faust unity plugin."
33 echoscip-shell system . . echo. "If you need other android architectures, open architecture/unity/Android/Application.mk and modify APP_ABI."
34 echoscip-shell system . . echo. "See architecture/unity/README.md for more info (also available from the compile folder)"
35 option
36 option "-nvoices <num>"
37 option -android "creates also the c# and JSON files"
38 option "Faust options"
39 exit
40 }
41
42 if [scip-shell system . . `[`. "$#" -eq 0 ]; then
43 echoscip-shell system . . echo. 'Please, provide a Faust file to process !'
44 echoscip-shell system . . echo. ''
45 echoHelpscip-shell shell shell-project 0.0.0 echoHelp().
46 fi
47
48 #-------------------------------------------------------------------
49 # Dispatch command arguments
50
51 SOURCE="0"
52
53 while [scip-shell system . . `[`. $1 ]
54 do
55 p=$1
56
57 if [scip-shell system . . `[`. $p = "-help" ] || [scip-shell system . . `[`. $p = "-h" ]; then
58 echoHelpscip-shell shell shell-project 0.0.0 echoHelp().
59 elif [scip-shell system . . `[`. $p = "-nvoices" ]; then
60 shift
61 NVOICES=$1
62 if [scip-shell system . . `[`. $NVOICES != -1 ]; then
63 ANDROID_MK=AndroidPoly.mk
64 fi
65 elif [scip-shell system . . `[`. ${p:0:1} = "-" ]; then
66 OPTIONS="$OPTIONS $p"
67 elif [[ -f "$p" ]] && [scip-shell system . . `[`. ${p: -4} == ".dsp" ]; then
68 FILES="$FILES $p"
69 else
70 OPTIONS="$OPTIONS $p"
71 fi
72
73 shift
74 done
75
76 #-------------------------------------------------------------------
77 # compiles the *.dsp files
78
79 for p in $FILES; do
80
81 CUR=$(pwdscip-shell system . . pwd.)
82 f=$(basenamescip-shell system . . basename. "$p")
83 NAME=${f%.dsp}
84 FNAME=FaustPlugin_$NAME
85 SRCDIR=$(dirnamescip-shell system . . dirname. "$p")
86 FIN=$FNAME/Android
87
88 # creates a temporary dir
89 TMP=$(mktempscip-shell system . . mktemp. -d android.XXXX)
90
91 # checks if final dir exists
92 if [scip-shell system . . `[`. ! -d "$FIN" ]; then
93 mkdirscip-shell system . . mkdir. -p "$FIN"
94 fi
95
96 # compiles faust to c++
97 faust -uim -i -a $FAUSTLIB/unity/unityplugin.cpp $OPTIONS "$SRCDIR/$f" -o "$TMP/$NAME.cpp" || (echoscip-shell system . . echo. "$f : Faust to C++ compilation failed in faust2androidunity"; exit 1)
98
99 # compiles c++ to binary
100 cd "$TMP"
101
102 # Android.mk and Application.mk contains the compilation settings.
103 # They are moved to the working directory for compilation then deleted
104 cpscip-shell system . . cp. -r "$FAUSTLIB/unity/Android/$ANDROID_MK" "Android.mk"
105 cpscip-shell system . . cp. -r "$FAUSTLIB/unity/Android/Application.mk" "Application.mk"
106 $ANDROID_HOME/ndk-bundle/ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk FILE=$NAME > /dev/nullscip-shell filesystem . . `/dev/null`. || (echoscip-shell system . . echo. "$f : C++ to armeabi-v7a and x86 library compilations failed in faust2androidunity"; exit 1)
107 rmscip-shell system . . rm. -rf "Android.mk"
108 rmscip-shell system . . rm. -rf "Application.mk"
109 rmscip-shell system . . rm. -rf "obj"
110 rmscip-shell system . . rm. -rf "$NAME.cpp"
111 cd ..
112
113 # moves binaries to final dir and deletes libs/
114 mvscip-shell system . . mv. $TMP/libs/* $TMP
115 rmscip-shell system . . rm. -rf $TMP/libs
116
117 mvscip-shell system . . mv. $TMP/* $FIN/
118 rmscip-shell system . . rm. -rf $TMP
119
120 echoscip-shell system . . echo. "$f : Android armeabi-v7a and x86 compilations completed"
121
122 done
123