MobDev.Plugin.Merge (mob_dev v0.5.16)

Copy Markdown View Source

Gathers the contributions of the activated plugins into combined lists the build pipeline consumes.

Pure: every function takes plugins — a list of {plugin_dir, manifest} for the activated plugins — and returns the merged contribution for one build concern (NIFs, permissions, gradle deps, frameworks, native sources, …). Path-bearing declarations are resolved to absolute paths against each plugin's own directory, so contributions from different plugins don't collide or get misresolved. Tier-0 (nil-manifest) plugins contribute nothing.

Discovery (deps → activated → load manifest) is the caller's job; this module is the testable transform once the manifests are in hand.

Summary

Functions

Unique Android permission strings declared across plugins.

Absolute paths of all plugin Android native sources (bridge_kt, jni_source) plus NIF native_dirs — everything the Android build must compile in.

Fully-qualified Kotlin class names (e.g. "io.mob.bluetooth.MobBluetoothBridge") each activated plugin wants registered at startup. native_build generates a MobPluginBootstrap.registerAll/0 that calls <class>.register() for each, so the plugin's nativeRegister thunk can cache its own jclass + method IDs.

Absolute paths of plugin Android bridge_kt Kotlin sources. native_build copies each into the app source tree (at its package-derived path) before gradle assembleDebug, so the app's Kotlin sourceSet compiles it.

Unique Android gradle dependency strings across plugins.

Unique iOS framework names across plugins.

Absolute paths of plugin Android jni_source files — plain JNI-thunk C (e.g. Java_<pkg>_<Class>_nativeDeliver*) that the build compiles into the app .so without a NIF-init libname (unlike nif_sources/1). Fed to the build's -Dplugin_jni_sources arg.

Absolute paths of each plugin C NIF's primary source (NIFs whose manifest entry has no :lang or lang: :c).

Combined NIF entries across all plugins, with :native_dir resolved to an absolute path. Shape matches MobDev.StaticNifs entries (:module plus the plugin's native source dir), so the result can be fed straight into StaticNifs.resolve/1.

Merged iOS plist_keys across plugins (later plugins win on conflict).

Absolute paths of all plugin iOS Swift source files.

Combined ui_components entries across plugins.

Absolute paths of each plugin zig NIF's primary source (NIFs whose manifest entry has lang: :zig).

Types

plugin()

@type plugin() :: {Path.t(), map() | nil}

Functions

android_permissions(plugins)

@spec android_permissions([plugin()]) :: [String.t()]

Unique Android permission strings declared across plugins.

android_sources(plugins)

@spec android_sources([plugin()]) :: [String.t()]

Absolute paths of all plugin Android native sources (bridge_kt, jni_source) plus NIF native_dirs — everything the Android build must compile in.

bridge_classes(plugins)

@spec bridge_classes([plugin()]) :: [String.t()]

Fully-qualified Kotlin class names (e.g. "io.mob.bluetooth.MobBluetoothBridge") each activated plugin wants registered at startup. native_build generates a MobPluginBootstrap.registerAll/0 that calls <class>.register() for each, so the plugin's nativeRegister thunk can cache its own jclass + method IDs.

bridge_kt_sources(plugins)

@spec bridge_kt_sources([plugin()]) :: [String.t()]

Absolute paths of plugin Android bridge_kt Kotlin sources. native_build copies each into the app source tree (at its package-derived path) before gradle assembleDebug, so the app's Kotlin sourceSet compiles it.

gradle_deps(plugins)

@spec gradle_deps([plugin()]) :: [String.t()]

Unique Android gradle dependency strings across plugins.

ios_frameworks(plugins)

@spec ios_frameworks([plugin()]) :: [String.t()]

Unique iOS framework names across plugins.

jni_sources(plugins)

@spec jni_sources([plugin()]) :: [String.t()]

Absolute paths of plugin Android jni_source files — plain JNI-thunk C (e.g. Java_<pkg>_<Class>_nativeDeliver*) that the build compiles into the app .so without a NIF-init libname (unlike nif_sources/1). Fed to the build's -Dplugin_jni_sources arg.

nif_sources(plugins)

@spec nif_sources([plugin()]) :: [String.t()]

Absolute paths of each plugin C NIF's primary source (NIFs whose manifest entry has no :lang or lang: :c).

Convention: for a manifest entry %{module: :foo_nif, native_dir: "priv/jni"} the source is <plugin_dir>/priv/jni/foo_nif.c. This is the <name>.c pattern the build.zig templates already use for project-level NIFs (c_src/<name>.c), extended to plugins. Returned paths feed the build's -Dplugin_c_nifs arg; build.zig derives the NIF name from the basename and applies -DSTATIC_ERLANG_NIF_LIBNAME=<name> so ERL_NIF_INIT emits the static-init symbol the driver table references.

nifs(plugins)

@spec nifs([plugin()]) :: [map()]

Combined NIF entries across all plugins, with :native_dir resolved to an absolute path. Shape matches MobDev.StaticNifs entries (:module plus the plugin's native source dir), so the result can be fed straight into StaticNifs.resolve/1.

plist_keys(plugins)

@spec plist_keys([plugin()]) :: map()

Merged iOS plist_keys across plugins (later plugins win on conflict).

swift_files(plugins)

@spec swift_files([plugin()]) :: [String.t()]

Absolute paths of all plugin iOS Swift source files.

ui_components(plugins)

@spec ui_components([plugin()]) :: [map()]

Combined ui_components entries across plugins.

zig_nif_sources(plugins)

@spec zig_nif_sources([plugin()]) :: [String.t()]

Absolute paths of each plugin zig NIF's primary source (NIFs whose manifest entry has lang: :zig).

Same <plugin_dir>/<native_dir>/<module>.zig convention as the C path, but fed to the build's -Dplugin_zig_nifs arg and compiled via addZigObject. Unlike C, no -DSTATIC_ERLANG_NIF_LIBNAME is needed — the zig source names its own export fn <module>_nif_init() directly. The plugin source reaches mob-core bindings via the named imports @import("erts") / @import("jni") that build.zig wires for plugin zig objects.