diff --git a/docs/development.md b/docs/development.md index 6f25853b3..e0abe9d46 100644 --- a/docs/development.md +++ b/docs/development.md @@ -30,7 +30,7 @@ cargo compiles a crate once per distinct feature set, and every crate above it o `cl` selects the `feature-root` package beside the package of every command (`-p -p feature-root`). Its dependencies are the gallery's, with every domain crate's `suite`, so every local build resolves features as the gallery does, and a target directory holds one build of each crate. Nothing of `feature-root` is compiled: its one target is a bin no `cl` command selects (`cl` names the crate's own targets), and only the targets a command names are built, so a render still links one domain crate and a framework crate's tests still link no app. On top, `cl` adds the crate's own test feature (`suite`, else `screen-testing`, else `testing`). The Mac's and CI's commands never select `feature-root` and are unaffected. -Five manifest facts keep this true, and `cl doctor` checks them: the gallery links each domain crate's stories as an optional dependency behind a feature of its own (so a render links one domain crate); `feature-root` lists every optional domain crate of the gallery with the gallery's features, and depends on the gallery without its default features (so the gallery lib's own features stay each command's: `apps` for the gallery, one crate for a render); the story renderer asks its shared dependencies for no feature beyond what the gallery's lines turn on (one those features imply, as `suite` implies `testing`, adds nothing); dev-dependency lines ask egui for no features (a feature there differs between a crate's tests and everything else); the proc-macro crate pins syn's and proc-macro2's features to everything other derive crates may add, so the one syn every proc macro shares is the same with or without design-lint in the graph. `cl` names any new build of a framework crate in the target directory after each command; after a manifest change one is expected, otherwise run `cl doctor`. +Five manifest facts keep this true, and `cl doctor` checks them: the gallery links each domain crate's stories as an optional dependency behind a feature of its own (so a render links one domain crate); `feature-root` lists every optional domain crate of the gallery with the gallery's features, and depends on the gallery without its default features (so the gallery lib's own features stay each command's: `apps` for the gallery, one crate for a render); the story renderer asks its shared dependencies for no feature beyond what the gallery's lines turn on (one those features imply, as `suite` implies `testing`, adds nothing); dev-dependency lines ask the egui crates (egui, epaint, epaint_default_fonts, emath, ecolor) for no feature that `feature-root`'s or the normal lines lack (a feature there differs between a crate's tests and everything else); the proc-macro crate pins syn's and proc-macro2's features to everything other derive crates may add, so the one syn every proc macro shares is the same with or without design-lint in the graph. `cl` names any new build of a framework crate in the target directory after each command; after a manifest change one is expected, otherwise run `cl doctor`. The `testing` feature (or `screen-testing` on domain crates) supplies fixtures and helpers for app tests. The `suite` feature implies that kit and adds framework stories, registrations, trials, snapshots, and the suite runner. Framework and gallery tests enable `suite`; apps should use the kit without it. diff --git a/tools/cl b/tools/cl index 9f54f69cc..39078a29b 100755 --- a/tools/cl +++ b/tools/cl @@ -70,6 +70,8 @@ RENDER_FEATURES = { "automation", "browse", "color-ui", "draw", "imaging", "layers", "menu", "pages", "print", "review", "table", "text", "theme-editor", "theme-store", "timeline", "dialogs", "font-manager", "update", } +# The egui crates every framework crate builds on: a feature only a dev-dependency line asks of one rebuilds the framework. +EGUI_FAMILY = {"egui", "epaint", "epaint_default_fonts", "emath", "ecolor"} REFUSED = { "--all-features": "it enables snapshot, system_fonts, color_fonts, all-languages and more, a set no loop uses, which rebuilds every dependency and the whole framework once; CI runs it", "--bins": "the gallery's binaries are 1 GB links each; build the one you need (`cl build gallery`)", @@ -222,12 +224,19 @@ def doctor(top, packages, quiet=False): text = open(os.path.join(top, path)).read() if not re.search(pattern, text, re.M): problems.append(f"{path}: {why}") + asked = {} + for p in packages.values(): + for d in p["dependencies"]: + if d["name"] in EGUI_FAMILY and d["kind"] is None: + asked.setdefault(d["name"], set()).update(d["features"]) for p in packages.values(): manifest = os.path.relpath(p["manifest_path"], top) for d in p["dependencies"]: - if d["name"] == "egui" and d["kind"] == "dev" and d["features"]: - problems.append(f"{manifest}: the egui dev-dependency asks for {d['features']}; a feature on a dev-dependency " - "line changes egui under the framework between a crate's tests and its render") + extra = set(d["features"]) - asked.get(d["name"], set()) + if d["name"] in EGUI_FAMILY and d["kind"] == "dev" and extra: + problems.append(f"{manifest}: the {d['name']} dev-dependency asks for {sorted(extra)}, which no normal line " + f"(feature-root's included) asks for; it changes {d['name']} under the framework between the " + "crate's tests and every other build") gallery = packages.get("craft-ui-gallery") if gallery: for d in gallery["dependencies"]: