grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.54k stars 319 forks source link

How to set the path to Faust libraries programmatically? #974

Closed shakfu closed 10 months ago

shakfu commented 10 months ago

While building libfaust.a with the interp backend in my recent issue-9273, I found that it was possible to make the location of the directory containing the faust libraries (stdfaust.lib, ...) in <prefix>/share/faust available to compiled code using the interp api by also building the faust executable and putting it <prefix>/bin/faust in PATH

While this is fine for testing, I would like to wrap the parts of the interp api in a cython-based (compiled) python extension and make it self-contained (with the standard libraries packaged inside the python package) along with the extension.

In order to do that I will have to set the path of the Faust standard libs at runtime based on the user install location. So basically, I'm looking for the equivalent of programmatically setting in c or cpp the path of packaged Faust standard libraries.

I would appreciate some guidance on how to do this from the cpp or c apis.

Thanks in advance for any help on this front.

sletz commented 10 months ago

Simply using the -I /path/to/lib model used in the args/arg parameters of createXXFactory API ?

shakfu commented 10 months ago

Thanks @sletz

Simply using the -I /path/to/lib model used in the args/arg parameters of createXXFactory API

So basically for let's say interpreter_dsp_factory* createCInterpreterDSPFactoryFromFile(const char* filename, int argc, const char* argv[], char* error_msg) I just pass path to the libs in the argv[] params.

Ok, I'll have to read up a bit more on how to that. Thanks!

sletz commented 10 months ago

Yes exactly.

shakfu commented 10 months ago

@sletz

Ok, so it look like you are referring the -I dir option in the Faust Compiler Options page

-I <dir>  --import-dir <dir>            add the directory <dir> to the libraries search path.-I <dir>  --import-dir <dir>            add the directory <dir> to the libraries search path.
sletz commented 10 months ago

Yes indeed.

shakfu commented 10 months ago

@sletz

Thanks, Incidentally, I have done a little work already which may be of interest: https://github.com/shakfu/faustlab

Any advice on which parts of the api to wrap would be appreciated!

sletz commented 10 months ago

Looking here, I would say: createInterpreterDSPFactoryFromFile, createInterpreterDSPFactoryFromString, deleteInterpreterDSPFactory, deleteAllInterpreterDSPFactories, readInterpreterDSPFactoryFromBitcode, writeInterpreterDSPFactoryToBitcode, readInterpreterDSPFactoryFromBitcodeFile, writeInterpreterDSPFactoryToBitcodeFile are the most important.

shakfu commented 10 months ago

@sletz Thanks!