Repository navigation
feat: build cross modules standalone and during --prepare - #275
Conversation
Modules declared in cross.modules are now compiled alongside the embedder whenever --build is used, staging artifacts into <buildRoot>/modules/ rather than silently skipping them when no --app is provided. Modules are logically part of the embedder — they share its toolchain and sysroot — and should not depend on a Flutter app being present. Deprecate build.app_path: emb matrix now warns when the field is set, directing users to pass --app at the command line instead. The field parsed silently but had no effect after the matrix command stopped deriving --app from it.
_buildModules now skips (with an info log) any module whose path
contains ${app_root} when appDir is null, preventing a misleading
"source dir not found" error during --prepare or standalone --build.
Adds dry-run tests for manifests with plain and ${app_root} module paths,
and matrix command tests for host_dev_packages output and the
build.app_path deprecation warning.
Move expandManifestVars call before hasUnresolvedVars check so variables that can be resolved (e.g. from moduleVars) don't cause modules to be incorrectly skipped when --app is absent. Also eliminates the duplicate expand call when constructing the src Directory. Move build.app_path deprecation warning before the target loop to emit it once per manifest rather than once per target.
…re step) and copies them into the runnable rather than re-building. Uses existing fingerprint mechanism to determine if modules are up-to-date or need to be re-built.
jwinarske
left a comment
There was a problem hiding this comment.
Review of the implementation, not the goal — the goal is right and #272's point 2 is worth closing.
Verified before posting: buildRoot encodes buildKey, and buildKey carries sysrootKey plus a mod: entry per module with its defines and features, so the new source-fingerprint stamp cache correctly misses on a toolchain, sysroot or defines change. That looked unsound on first read and isn't.
Six comments below. Two are worth fixing before merge — the untested feature path and the stale documentation; the rest are small.
Note that #276 just landed and removed the build: block from all eight cross examples, which changes the blast radius of the deprecation warning (see the comment on matrix_command.dart).
- Fix --prepare _buildModules call omitting appDir, causing false
"skipped (path has ${app_root})" log when --app is passed
- Fix module build log message hardcoding "→ lib/" regardless of
destination; now shows the actual staged directory basename
- Fix build.app_path deprecation warning firing only on non-default
values; now triggers on key presence in both `emb matrix` and
`emb cross --build`
- Remove host_dev_packages from matrix cell output (no workflow reader)
- Update README and CHANGELOG to document standalone/--prepare module
build behaviour and the new staging destination
- Add test covering the ${app_root} skip path via --build --target local
with pre-seeded build root, and update matrix tests for the revised
deprecation and host_dev_packages behaviour
There was a problem hiding this comment.
Verified all six addressed.
Mutation-checked the new skip test: replacing if (appDir == null && hasUnresolvedVars(expanded)) with if (false) makes --build --target local skips ${app_root} modules without --app fail (exit 70 against the expected 0), so it genuinely covers the path it claims to. dart analyze clean, both touched test files pass locally (74 tests), CI 41/41 with only the opt-in build job skipped.
The pre-seeded .emb-source-stamp + fake ELF to get past skipIfBuilt is a neat way into _buildModules without a toolchain — worth remembering for the standalone-build case, which still has no test.
Three nits below, none blocking.
Three nits from the second review pass.
`<buildRoot>/modules/` was documented as being "for use by downstream
tooling", which reads like a supported integration point. Nothing in a
manifest reaches it: the path variables are ${embedder_root}, ${app_root}
and ${runnable}, and none names the build root, so `cross.package.files`
cannot pick these artifacts up. Say that instead.
The deprecation warning in `emb cross` read only the selected target's
declaring file. A `.emb/` project can hold a shared `build:` block in its
base while the target comes from a sibling, so the warning missed a case the
same manifest would hit when flat. Checks both paths now, as a set, which
collapses to one load for a flat manifest. The presence test is now
`declaresAppPath` in build_config.dart, shared with `emb matrix` rather than
spelled out twice.
The ${app_root} skip test asserted on the `${app_root}` substring, which the
"source dir not found" error this path produces on a regression also prints.
Pins the message instead; the exit-code expectation was doing the real work.
Tests: `declaresAppPath` directly, and the `emb cross` warning end-to-end --
it had none, only the matrix side did. Both mutation-checked: `if (false)`
fails the --build test, `if (true)` fails the --dry-run test.
Not covered: the sibling-file case itself. Selecting a cross target needs a
real toolchain, and the native path makes both lookups the same file.
Signed-off-by: Joel Winarske <joel.winarske@linux.com>
|
Pushed
Added tests for Not covered: the sibling-file case itself. Selecting a cross target needs a real toolchain, and the native path makes both lookups the same file — so that fix is reasoned, not tested. |
Description
Addresses #272
Previously, cross modules could only be built as part of an app bundle
(
--app). Without--app, declaring modules emitted a warning and skippedthem entirely.
This changes that in two ways:
Standalone module builds — when
--appis absent buttarget.modulesis non-empty, modules are now built and staged into
<buildRoot>/modules/instead of being silently skipped.
--preparemodule builds — modules are now built during--prepare,placed into
<preparedEmbedder.buildRoot>/modules/, so a subsequent--deploy/--runfinds them without needing a separate build step.Modules whose paths contain unresolved
${app_root}are skipped with aninformational message (requires
--appto resolve).--prepareskips thestandalone build path since it already ran.
build.app_pathis deprecated in favour of the--appflag.Type of Change