DPF icon indicating copy to clipboard operation
DPF copied to clipboard

Best way to handle assets ?

Open SeleDreams opened this issue 2 years ago • 11 comments

Hi, I am working on a vst3 and LV2 plugin using DPF and it is working as intended however I would like to start working on making a user interface for it. I use cmake to handle the build of my project using dpf_add_plugin and I am not sure about how I would indicate the directory holding the assets of the plugin so that it always gets bundled with it

SeleDreams avatar Dec 28 '21 19:12 SeleDreams

that seems more of a general question on using cmake, no?

falkTX avatar Dec 28 '21 19:12 falkTX

that seems more of a general question on using cmake, no?

not really because while in cmake i'd just set the cmake archive output and cmake binary output variables but dpf seems to output to specific directories depending on whether it's lv2, vst3 etc so i'd need to rely on these dpf specific variables to output to the right directory

SeleDreams avatar Dec 28 '21 19:12 SeleDreams

for that the develop branch has a dedicated function to let you know where the resources would be at runtime. see https://github.com/DISTRHO/DPF/blob/develop/distrho/DistrhoPluginUtils.hpp#L50 (that together with the Plugin::getBundlePath should do it)

falkTX avatar Dec 28 '21 20:12 falkTX

from what i can see for each target it sets a target property specifying the library output directory directly

for instance for LV2

set_target_properties("${NAME}-lv2-ui" PROPERTIES
        LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${NAME}.lv2/$<0:>"
        ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/obj/lv2/$<0:>"
        OUTPUT_NAME "${NAME}_ui"
        PREFIX "")
    endif()

the issue I see is that because of it we'd need to manually read the properties of the generated target names i feel like the dpf_add_plugin function should have an argument to specify an asset folder so that it automatically will copy it to each build (lv2/vst etc)

SeleDreams avatar Dec 28 '21 20:12 SeleDreams

I'm referring to copy the asset folder to the folder of the vst, lv2 etc at build time, not locating the folder at runtime

SeleDreams avatar Dec 28 '21 20:12 SeleDreams

Nice, I didn't notice DPF supported the resource bundles yet. We sure can have a cmake helper to copy them.

@falkTX, unrelated: about the fixed resource directories if we're going to ever support vstgui, it's worth knowing that this library has its own resource-finding that can't be overriden. We found the best hierarchy is the macOS-style one for all platforms, it can be made to work everywhere. (and having moved the lv2.so from the root to a subdirectory)

jpcima avatar Dec 28 '21 20:12 jpcima

I am not super keen on changing the binary location and bundle structure at this point tbh.. Supporting multiple architectures (different binaries) in a single bundle would be a reason to go and change things, but outside of VST3 no other plugin format supports this at the moment.

falkTX avatar Dec 28 '21 21:12 falkTX

also I tried getBundlePath but it returns null for vst3

SeleDreams avatar Dec 28 '21 22:12 SeleDreams

I guess i'll rely on res2c instead atm to convert the resources to cpp and directly bundle them in the executable

SeleDreams avatar Dec 28 '21 22:12 SeleDreams

also I tried getBundlePath but it returns null for vst3

there should be some assertion fail if that is the case. vst3 and lv2 are required by design to have a bundle

falkTX avatar Dec 28 '21 23:12 falkTX

also I tried getBundlePath but it returns null for vst3

there should be some assertion fail if that is the case. vst3 and lv2 are required by design to have a bundle

that's kinda what i find weird since i just build it normally using cmake with dpf_add_plugin

SeleDreams avatar Dec 29 '21 00:12 SeleDreams