Hi, I have a lot of Bela projects and a bunch of files that exists in all projects. I would be nice with an easy way to make the system build cpp's located in custom folders, so that they are shared between projects...

I know I could place my files in ~/Bela/core, but that seems a bit messy. Could there be a command line option like:

make PROJECTS=theProject ADD_SOURCES_IN=./projects/otherProject/commonSouces ./user/moreSources

Such that the files in the specified folders are build and linked correctly ?

Could be the same make rules as for normal project files, but with user specified folder(s)...

What I would like to do is to have a project where I develop and test the common files. In that project, all the files I'd like to be shared are in a sub-folder. I would then like to specify from other projects to use the files in that folder. I can include with CPPFLAGS=I./projects/otherProject/commonSources but I cant make it compile and link without making a custom makefile... or can I ?

At least I'd like to...

I like the idea of being able to edit the shared lib in the IDE, so that I can do it from any computer at any time with ease....

  • Hjalte

If I understand correctly, what you are looking for is what we call a "library". Basically, you'd add your reused/reusable code in Bela/libraries/YOURLIBRARY, then add a minimal file called lib.metadata, e.g.: https://github.com/BelaPlatform/Bela/blob/master/libraries/AudioFile/lib.metadata

Under dependencies= you can specify names of other Bela libraries it depends on, while in LDLIBS= you'd place linker flags if it depends on shared libraries.

IMPORTANT: at the moment, custom content of the libraries/ folder will be wiped off when the board is updated (i.e.: it is treated the same as the rest of the core code, which allows us to remove libraries in the future without them cluttering your file system). Maybe we should be adding userLibraries/ and treat it the same as libraries/ except we'd avoid wiping it off.

Yes, I did try that and it works,- but are libraries build the same way as a project ? Will it use distcc if enabled ?

Also, it is not possible to edit library content using the IDE. But surely you could enable that for userLibraries 🙂

So, if it will use distcc for compiling -and you could edit the library within the IDE, I'd be happy 🙂

Cheers

    HjalteBestedMoeller ? Will it use distcc if enabled ?

    Yes.

    HjalteBestedMoeller Also, it is not possible to edit library content using the IDE.

    Point is you shouldn't need to. Keep the files in your project as long as you need to edit them. Once they are "mature" enough, move them to libraries/MyLibrary/ and change the #include line in your project files to libraries/MyLIbrary/whatev.h. If at any later point you really want to edit them again, the easiest way is to symlink them into your project :

    ln -s ~/Bela/libraries/MyLibrary/MyFile.cpp ~/Bela/projects/MyProject/
    ln -s ~/Bela/libraries/MyLibrary/whatev.h ~/Bela/projects/MyProject/

    and revert the #include line. Once done and happy (again!), rm the symlinks:

    rm  ~/Bela/projects/MyProject/MyFile.cpp
    rm  ~/Bela/projects/MyProject/whatev.h

    HjalteBestedMoeller But surely you could enable that for userLibraries

    That's much more of a pain than you may think: the IDE relies on the assumption that the only files that will be edited are the ones within a project. Additionally, changes to a file in libraries/ do not trigger a rebuild. You should add RELINK=1 to the Make parameters if you ever edit library files (e.g.: with a text editor in the terminal) and you want your already built program to rebuild

    Suboptimal, I know.