Mod-plugin-builder for Rust plugins

I’m trying to move to building new rust plugins using the mod-plugin-builder docker route instead of my self-baked docker solution. My builds succeed, however they won’t load on the moddwarf. The browser just shows the cannot load plugin error. I also tried building dm-GrainDelay which should build fine with this tooling, but unfortunately this yields the same result.

Also, in order to get a successful build I had to install rust first and then add the relevant rustup targets (target architectures). I don’t know if that’s intended.

These plugins do work when they’re built with my own docker container. But I would prefer to use mod-plugin-builder now.

1 Like

Oh, and I used the dwarf image run: docker build -t mpb --build-arg platform=moddwarf .

use the platform=moddwarf-new (and docker-image)

1 Like

Good to know only moddwarf-new will work.

Some config for Rust got added about a month ago and isn’t part of the docker image yet. I’ll give the cbix/mod-plugin-builder image a go later. Is that the image you are using @spunktsch?

I use our image aidadsp/mod_plugin_builder-moddwarf-new but its not updated on docker.

1 Like

Unfortunately I can’t trigger builds for moddwarf-new on the cbix/mod-plugin-builder:moddwarf image either.

Ok, it was pretty obvious. :see_no_evil:

Running docker build -t mpb --build-arg platform=moddwarf-new . creates the docker image to compile for moddwarf-new. Will test the compiled plugin later today, but I’m pretty sure this solves my issue.

there is 1 extra step needed for the rust toolchain stuff, as seen in mod-plugin-builder/dm-graindelay.mk at master · moddevices/mod-plugin-builder · GitHub
the extra vars are defined in mod-plugin-builder/mod-plugin-builder.mk at master · moddevices/mod-plugin-builder · GitHub

so in summary for installing rust matching what is needed for dwarf:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y --no-modify-path --profile minimal
~/.cargo/bin/rustup target add aarch64-unknown-linux-gnu

then for building use:

# adjust path as needed, only needed once per terminal session
source /path/to/mod-plugin-builder/local.env moddwarf-new

# trigger local build with the moddwarf-new toolchain
~/.cargo/bin/cargo build --target aarch64-unknown-linux-gnu \
--config 'target.aarch64-unknown-linux-gnu.rustflags=["-Ctarget-cpu=cortex-a35","-Clink-args=--sysroot=${STAGING_DIR}"]' \
--config 'target.aarch64-unknown-linux-gnu.linker="aarch64-modaudio-linux-gnu-gcc"'

maybe that cargo build command needs to become a shell alias… :thinking:

Ah, I overlooked that one. Is there a reason for this to be commented out? Wouldn’t cargo build also work instead of ~/.cargo/bin/cargo build?

sure yes, but that requires modifying your $PATH variable, which is a manual step that not everyone will have done

Are the rust install lines commented because the cloud builder has rust installed already? Btw, I edited the Wiki page to explain you can build for other targets than just modduo, modduox & moddwarf.

1 Like

that is exactly why. we use those mk files directly for cloud builds, and having those lines is both unnecessary and wastes time.

local development builds should use the “source local.env” method instead, it is typically much faster during development

1 Like

Thanks for clearing this up!