Skip to content

Commit

Permalink
Update faust2faustvst for universal arm64/x86_64 compilation on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Dec 12, 2024
1 parent 94da68b commit 63ee381
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 7 additions & 4 deletions architecture/faust/gui/MidiUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ architecture section is not modified.
/**
* Helper code for MIDI meta and polyphonic 'nvoices' parsing.
*/
struct MidiMeta : public Meta, public std::map<std::string, std::string> {
struct MidiMeta : public Meta {

void declare(const char* key, const char* value)
std::map<std::string, std::string> fData;

void declare(const char* key, const char* value) override
{
(*this)[key] = value;
fData[key] = value;
}

const std::string get(const char* key, const char* def)
{
return (this->find(key) != this->end()) ? (*this)[key] : def;
auto it = fData.find(key);
return (it != fData.end()) ? it->second : def;
}

static void analyse(dsp* mono_dsp, bool& midi, bool& midi_sync, int& nvoices)
Expand Down
7 changes: 4 additions & 3 deletions compiler/generator/rust/rust_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ void RustCodeContainer::produceFaustDspBlob()
*fOut << tab << "fn set_param(&mut self, param: ParamIndex, value: Self::T) {" << endl;
*fOut << tab << tab << "self.set_param(param, value)" << endl;
*fOut << tab << "}" << endl;
*fOut << "fn compute(&mut self, count: i32, inputs: &[&[Self::T]], outputs: &mut [&mut "
*fOut << tab
<< "fn compute(&mut self, count: i32, inputs: &[&[Self::T]], outputs: &mut [&mut "
"[Self::T]]) {"
<< endl;
*fOut << tab << tab << "self.compute(count as usize, inputs, outputs)" << endl;
Expand Down Expand Up @@ -352,7 +353,7 @@ void RustCodeContainer::produceClass()

tab(n, *fOut);
*fOut << "impl " << fKlassName << " {";

// Memory methods
tab(n + 2, *fOut);
if (fAllocateInstructions->fCode.size() > 0) {
Expand Down Expand Up @@ -669,7 +670,7 @@ void RustCodeContainer::generateComputeFrame(int n)
generateComputeBlock(&fCodeProducer);

tab(n + 1, *fOut);
*fOut << "//generateOneSample";
*fOut << "// generateOneSample";
tab(n + 1, *fOut);
// Generates one sample computation
BlockInst* block = fCurLoop->generateOneSample();
Expand Down
15 changes: 10 additions & 5 deletions tools/faust2appls/faust2faustvst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ CXXFLAGS="-Ofast -std=c++11 -march=native"
# Darwin-specific
#ARCH="-arch i386 -arch x86_64"
if [[ $(uname) == Darwin || $CROSSTARGET == Darwin ]]; then
CXXFLAGS="-Ofast -std=c++11 -march=native $ARCH -I/opt/local/include"
#CXXFLAGS="-Ofast -std=c++11 -march=native $ARCH -I/opt/local/include"
CXXFLAGS="-Ofast -std=c++11 -mmacosx-version-min=10.9 $ARCH -I/opt/local/include"
dllext=".vst"
fi

Expand Down Expand Up @@ -145,9 +146,6 @@ EOF
PROCARCH="-m32 -L/usr/lib32"
elif [ $p = "-arch64" ]; then
PROCARCH="-m64 -fPIC"
elif [ $p = "-osx" ]; then
CXXFLAGS="-Ofast -std=c++11 -march=native $ARCH -I/opt/local/include"
dllext=".vst"
elif [ $p = "-keep" ]; then
KEEP="yes"
elif [ $p = "-style" ]; then
Expand Down Expand Up @@ -265,7 +263,14 @@ if [[ $(uname) == Darwin || $CROSSTARGET == Darwin ]]; then
</dict>
</plist>
EOF
$CXX -bundle $CXXFLAGS $FAUSTTOOLSFLAGS $PROCARCH -I"$ABSDIR" $CPPFLAGS $sdksrc "$tmpdir/$cppname" -o "$tmpdir/$soname/Contents/MacOS/$clsname" || exit 1
if [ $(uname -p) == arm ]; then
$CXX -arch arm64 -arch x86_64 -bundle $CXXFLAGS $FAUSTTOOLSFLAGS $PROCARCH -I"$ABSDIR" $CPPFLAGS $sdksrc "$tmpdir/$cppname" -o "$tmpdir/$soname/Contents/MacOS/$clsname" || exit 1
else
$CXX -bundle $CXXFLAGS $FAUSTTOOLSFLAGS $PROCARCH -I"$ABSDIR" $CPPFLAGS $sdksrc "$tmpdir/$cppname" -o "$tmpdir/$soname/Contents/MacOS/$clsname" || exit 1
fi
if which codesign > /dev/null; then
codesign --sign - --deep --force "$tmpdir/$soname/"
fi
else
$CXX -shared $CXXFLAGS $FAUSTTOOLSFLAGS $PROCARCH -I"$ABSDIR" $CPPFLAGS $sdksrc "$tmpdir/$cppname" -o "$tmpdir/$soname" || exit 1
fi
Expand Down

0 comments on commit 63ee381

Please sign in to comment.