feat: let a project file return several configurations
A project.cpp described one configuration: CrafterBuildProject returns a Configuration by value, and anything else the project wanted built had to be among that one's dependencies. There it was built as part of that configuration's graph: under the check that a graph builds each module once, with its libraries handed up to whatever links that configuration, and with its tests and scripts out of reach of `test` and `run`. Jorijn asked for a project.cpp that can return several unrelated configurations which all get built, and suggested a separate entry point, so that no existing project file breaks. A project file now defines one of two functions. CrafterBuildProject is as it was. CrafterBuildConfigurations returns std::vector<Configuration*>: pointers to configurations the file keeps alive itself, or that GitProject and LocalProject gave it. The two have different names because the loader finds the entry point by its C symbol, which carries no return type, so one name with two return types would be called as whichever the loader guessed. They are pointers because a project file takes pointers between its configurations, for `dependencies` and for a test's, before it returns them, and a vector of values would move them. LoadConfigurations loads a project file with either entry point and returns the list. A CrafterBuildProject's Configuration comes back as a list of one, constructed by the call where the loader keeps it for the rest of the process; LoadProjectFromRoot, which did that for a sibling's, leaves it to LoadConfigurations, and the project cache holds the lists without owning a Configuration. The Configuration of the project crafter-build is pointed at is kept that long as well, where it was a local of Run(). LoadConfigurations throws for a file that defines both functions or neither, and for a CrafterBuildConfigurations that returns nothing, a null pointer or one configuration twice. It also throws for one that returns a configuration a project loaded through GitProject or LocalProject keeps to itself, which the loader now takes down when it loads that project's file: what the configurations the file returned led to through `dependencies` or through their tests, as far as the first configuration on each way that a loaded project's file had returned or another loaded project keeps. Returned from here, such a configuration would count as this file's own to `test` and `run`, and only the configurations a project file returns are rebased onto its directory. LoadProject stays, for a caller that wants a CrafterBuildProject's Configuration by value, and throws for a file with the other entry point. GitProject and LocalProject keep, per spec and args, the list a sibling's file returned, and return the first one unless the spec's new `configuration` names another by Configuration::name. Every configuration of the list is rebased onto the sibling's directory, except one that another project's file had returned before, which was rebased onto that project's. Specs that differ only in the name they pick share one load. A name the sibling does not have throws, listing the names it has, and a name two of its configurations share throws too. A `#pragma crafter dependency` gets the first. BuildAll builds the returned configurations in one pass. Each is built by Build(), as a project's one configuration is, the first on the calling thread and each other one on a thread of its own, and its result then goes into the record of the pass under its PcmDir, where Build() looks for a dependency. One that another of them is built on is built before that other starts, which then finds it in the record: started beside it, the other would not find it there yet and would build it a second time. A configuration is not put into the record before it is built, because a dependency of its own that is built into the same directory would be handed its unfinished build and wait for it, while it waits for the dependency. All of them are built to the end, and the errors come back in the order given, each message once; an exception a build throws comes back as an error that names the configuration, where Run() printed the exception's own text for a project's one configuration. Refused before anything is built: two that would be built into one directory, which would be two builds writing the same files at once; several that are each built on something of another's directory, so that none could be built first; and one that is built on something of its own directory when another is built on that directory as well, since the record holds one result for a directory and the other could be given either. One shortcut is in it. A wasm executable that declares wasmVariants builds what it is built on once more per variant, and says which variant by rewriting those configurations in place, at the end of its Build(). A library that two returned configurations share would change under the one still building its baseline, so with such an executable anywhere in the graph BuildAll builds the configurations one after the other, on the calling thread. Keeping them side by side takes a variant driver that does not rewrite configurations other builds read, which this commit does not attempt. Run() works on the list. A build builds all of it. `test` runs the tests, and `run` offers the scripts, of the ones in it that the project file made itself. One that another project's file returned to GitProject or LocalProject, and that this file returns in turn, is built with the rest, but its tests and scripts stay that project's, so `run` still reaches only the scripts of the project crafter-build was pointed at. What the list itself rules out Run() refuses once the project file has loaded, before any of the list is built and before AGENTS.md is written: for a build, `-r`, `install` and `bundle` whatever BuildAll refuses a list for, and for `test`, which builds its tests with Build() and never comes to BuildAll, two returned configurations of one directory. BuildAll makes its refusals again for whoever calls it. A script is handed the configuration it is declared on. `lint` and `format` walk from every returned configuration and keep, as before, the configurations in the project's directory: the returned ones first, in the order the file returned them, then what they depend on, so that of two returned ones that register a rule under one name the earlier one's runs. `-r` runs the executable when exactly one of them is one, and `install` and `bundle` export the one that is packaged as a Flatpak; with more than one candidate each refuses and names them, `-r` once everything is built and `install` and `bundle` before anything is. AGENTS.md takes the notes that the dependencyNotes of each returned configuration the file made itself selects among what that one is built against, and the file's pragma tooling and a returned configuration of another project go by the widest of those settings. There, a configuration is another project's when GitProject or LocalProject loaded it from another project file than the one whose AGENTS.md is written, two files being one when they resolve to one path, so UpdateAgentsMd still reads the setting of a Configuration one of the two returned when it is given that Configuration's own project file. For that, RunTests, RunLint, RunScript and UpdateAgentsMd each gained an overload that takes the list, and the one that takes a single Configuration calls it with a list of one. SetParentProject gained one too, and ParentLib searches the graph of every configuration it was given. BuildAll, RunTests and RunScript count a configuration the list names twice once. The tests of several configurations share what one configuration's had to itself: AddTest names a test's sources, tests/<name>, and its build directory after the test and its compile state, not after the configuration that declares it. Two configurations that each declare a test of one name, compiled alike, would have RunTests build both in that one directory, each with the dependencies of its own declaration. RunTests fails both without building either, and each failure names the configurations. It compares tests of different configurations only, so a project of one configuration is treated as it was. The --help text names the second entry point, says what -r, install and bundle do with several configurations, and speaks of the project file's entry point as what gets the project args, where it named CrafterBuildProject. AGENTS.template.md says that a project.cpp returns one configuration or several, that Run() works on the list and what a new verb has to decide about it, which configurations have their path rebased, and that the scripts of a returned configuration of another project cannot be run. Two of its notes named LoadProject as what loads a project.cpp for crafter-build, which Run(), GitProject and LocalProject no longer call, and speak of the load now. Its rule for the link flags of a test that loads a project file names the ways a test loads one, where it named LoadProject, and its entry for `:Script` speaks of the `scripts` of the configurations the driver is given, where it named `cfg.scripts`. Its entry for `:Platform` names LoadConfigurations beside LoadProject. That entry also said that `:Platform` holds all OS-specific code, which it did not before this range either, :Agents, :Progress, :Lint and :Clang including POSIX headers of their own, and no longer says so. The bug-prover lens's section names BuildAll's threads and LoadConfigurations. Not in this commit: a way to say which executable -r runs or which app install and bundle export when there are several, and a keyword that lets a `#pragma crafter dependency` name a configuration.
This commit is contained in:
parent
a7aa22220b
commit
4283a3ecd2
16 changed files with 986 additions and 241 deletions
|
|
@ -70,7 +70,7 @@ export namespace Crafter {
|
|||
// Write the AGENTS.md beside `projectFile` from the AGENTS.template.md
|
||||
// beside it, with the AGENTS.consumer.md of every dependency
|
||||
// project.dependencyNotes selects merged in. `project` is the
|
||||
// Configuration that file returned, after LoadProject: loading is what
|
||||
// Configuration that file returned, once it is loaded: loading is what
|
||||
// found the dependencies. Creates AGENTS.md when it is missing, and
|
||||
// replaces only one a build wrote: an AGENTS.md someone wrote is left
|
||||
// alone, with a warning. Without a template it writes nothing, and only
|
||||
|
|
@ -81,4 +81,17 @@ export namespace Crafter {
|
|||
// a dependency's unusable notes are warnings: the notes never fail a
|
||||
// build, and nothing is reported when nothing would have been written.
|
||||
bool UpdateAgentsMd(const Configuration& project, const fs::path& projectFile);
|
||||
// The same for a project file that returned several configurations.
|
||||
// Each one the file made itself selects, by its dependencyNotes, among
|
||||
// the projects that one is built against, and the notes are merged: a
|
||||
// dependency's are in when a configuration that asks for them leads to
|
||||
// it. The file's `#pragma crafter dependency` lines, and a
|
||||
// configuration it loaded from another project and returns, which
|
||||
// counts as a dependency here, go by the widest of those settings, and
|
||||
// by Transitive when the file made no configuration itself. A
|
||||
// configuration is another project's when GitProject or LocalProject
|
||||
// loaded it from another project file than `projectFile`, two files
|
||||
// being one when they resolve to one path: one they loaded from
|
||||
// `projectFile` itself is that file's own.
|
||||
bool UpdateAgentsMd(std::span<const Configuration* const> configurations, const fs::path& projectFile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -440,9 +440,11 @@ export namespace Crafter {
|
|||
// What a Script's callback is handed when `crafter-build run <name>`
|
||||
// starts it.
|
||||
struct ScriptContext {
|
||||
// The Configuration project.cpp returned. Read the project through
|
||||
// this rather than capturing the local in CrafterBuildProject by
|
||||
// reference: that local is gone by the time a script runs.
|
||||
// The Configuration the script is declared on: the one project.cpp
|
||||
// returned, or of several the one whose `scripts` holds it. Read the
|
||||
// project through this rather than capturing a local of the entry
|
||||
// point by reference: the local need not be the object that the
|
||||
// entry point returned.
|
||||
Configuration& project;
|
||||
// Absolute directory of the project file. Commands run in the
|
||||
// directory crafter-build was started from, like everything else it
|
||||
|
|
@ -595,8 +597,10 @@ export namespace Crafter {
|
|||
// Crafter.Build:Agents):
|
||||
// cfg.dependencyNotes = DependencyNotes::Direct;
|
||||
// Only read on the Configuration project.cpp returns; a dependency's
|
||||
// setting decides nothing for its consumers. Not part of VariantId:
|
||||
// the notes change nothing that is compiled.
|
||||
// setting decides nothing for its consumers. Of several returned
|
||||
// configurations, each one the project file made itself has its own
|
||||
// read, for what that one is built against (see UpdateAgentsMd). Not
|
||||
// part of VariantId: the notes change nothing that is compiled.
|
||||
DependencyNotes dependencyNotes = DependencyNotes::Transitive;
|
||||
void GetInterfacesAndImplementations(std::span<fs::path> interfaces, std::span<fs::path> implementations);
|
||||
// Retry the `import X;` names GetInterfacesAndImplementations could not
|
||||
|
|
@ -867,6 +871,35 @@ export namespace Crafter {
|
|||
// checks everything again and pulls unpinned externals again.
|
||||
BuildResult Build(Configuration& config, std::unordered_map<fs::path, std::shared_future<BuildResult>>& depResults, std::mutex& depMutex);
|
||||
|
||||
// Builds every one of `configurations`, the configurations a project
|
||||
// file returns, in the pass `depResults` records. Each is built by
|
||||
// Build(), as a project's one configuration is, and its result then
|
||||
// goes into the record under its PcmDir, where Build() records a
|
||||
// dependency. What two of them depend on is built once, and so is one
|
||||
// that another of them is built on: it is built before the other
|
||||
// starts, and the other finds it in the record. The first is built on
|
||||
// the calling thread and each other one on a thread of its own, all of
|
||||
// them to the end: one that fails stops none of the others. Returns the
|
||||
// errors of the ones that failed, in the order given and each message
|
||||
// once, so a dependency that failed for three of them is reported once,
|
||||
// and an empty string when all were built. A configuration the list
|
||||
// names twice is built once.
|
||||
//
|
||||
// With a wasm executable that declares wasmVariants among them, or
|
||||
// among what they are built on, they are built one after the other on
|
||||
// the calling thread instead: its build rewrites the configurations it
|
||||
// is built on for each variant, which no other build may be reading.
|
||||
//
|
||||
// Refuses, before building anything, two of them that would be built
|
||||
// into one directory (same path, name, target and compile state), which
|
||||
// would be two builds writing the same files at once; a set of them in
|
||||
// which each is built on something that is built into the directory of
|
||||
// another, so that none could be built first; and one that is built on
|
||||
// something of its own directory when another of them is built on that
|
||||
// directory too, since the record holds one result for a directory and
|
||||
// the other could be given either.
|
||||
std::string BuildAll(std::span<Configuration* const> configurations, std::unordered_map<fs::path, std::shared_future<BuildResult>>& depResults, std::mutex& depMutex);
|
||||
|
||||
// Takes main's argv verbatim so the CLI entry point is a one-liner;
|
||||
// the shape is inherited from the language, not chosen here.
|
||||
// lint-disable-next-line no-char-pointer
|
||||
|
|
|
|||
|
|
@ -76,14 +76,14 @@ export namespace Crafter {
|
|||
// clone can still differ in includeDirs, libDirs and libs.
|
||||
ExternalBuildResult ExternalOutputs(const ExternalDependency& dep, std::string_view target);
|
||||
|
||||
// The args the project file now running its CrafterBuildProject was
|
||||
// loaded with: everything that function receives, --target=, --debug and
|
||||
// The args the project file now running its entry point was loaded
|
||||
// with: everything that function receives, --target=, --debug and
|
||||
// the other standard flags included. Not cfg.projectArgs, which holds
|
||||
// only what ApplyStandardArgs left uninterpreted: `.args =
|
||||
// cfg.projectArgs` would drop the target and the build type. Empty
|
||||
// everywhere else, because it reads the stack LoadProject keeps per
|
||||
// everywhere else, because it reads the stack the loader keeps per
|
||||
// thread, as IsTopLevelProject does: outside a project file, on any
|
||||
// thread but the one running it, once CrafterBuildProject has returned
|
||||
// thread but the one running it, once the entry point has returned
|
||||
// (a script runs later), and before it is called, which covers the
|
||||
// file's static initialisers and its `#pragma crafter dependency`
|
||||
// pre-pass. The specs below default their args to it. Defined beside
|
||||
|
|
@ -97,7 +97,7 @@ export namespace Crafter {
|
|||
// GitSource picks the revision: leave branch + commit empty for the
|
||||
// remote's default branch HEAD (sloppy but convenient), set branch to
|
||||
// track a branch tip, or set commit to pin to an immutable SHA. args are
|
||||
// what the dep's CrafterBuildProject receives. They default to this
|
||||
// what the dep's entry point receives. They default to this
|
||||
// project's own, read when the spec is made, so --target=, --march=,
|
||||
// --debug and the project's own flags reach every sibling down a chain
|
||||
// without being passed. Set them to forward something else: {} for
|
||||
|
|
@ -105,19 +105,28 @@ export namespace Crafter {
|
|||
// a flag only this project reads. Give such a list to every sibling:
|
||||
// Build() refuses a graph in which two paths load one project with two
|
||||
// different lists, since the program would end up with both builds.
|
||||
// configuration picks among the configurations of a project file that
|
||||
// returns several (CrafterBuildConfigurations), by Configuration::name.
|
||||
// Left empty it is the first one the file returns, so a project that
|
||||
// grows a second configuration puts it after the one its consumers
|
||||
// already get.
|
||||
struct GitProjectSpec {
|
||||
GitSource source;
|
||||
fs::path projectFile = "project.cpp";
|
||||
std::vector<std::string> args = ProjectArgs();
|
||||
std::string configuration;
|
||||
};
|
||||
|
||||
// Clones the spec's git URL into the external cache, recursively
|
||||
// LoadProject's the remote's project.cpp, and returns a stable
|
||||
// Configuration* you can drop into cfg.dependencies. The clone is keyed by
|
||||
// url+branch+commit+projectFile alone, so every arg list builds in the
|
||||
// same working tree, each into variant directories of its own. The
|
||||
// Configuration is owned by an internal cache for the lifetime of the
|
||||
// build, keyed by the clone and the args: identical specs share one.
|
||||
// Clones the spec's git URL into the external cache, loads the remote's
|
||||
// project.cpp in turn, and returns a stable Configuration* you can drop
|
||||
// into cfg.dependencies: the configuration the spec picks of the ones
|
||||
// that file describes. The clone is keyed by url+branch+commit+projectFile
|
||||
// alone, so every arg list builds in the same working tree, each into
|
||||
// variant directories of its own. What the file describes is kept in an
|
||||
// internal cache for the lifetime of the build, keyed by the clone and
|
||||
// the args: identical specs share one Configuration, and two that differ
|
||||
// only in `configuration` share one load of the file. Throws when the
|
||||
// file has no configuration of the name the spec asks for, or two.
|
||||
Configuration* GitProject(const GitProjectSpec& spec);
|
||||
|
||||
// Specification for a local sibling crafter-build project (e.g. an
|
||||
|
|
@ -126,12 +135,13 @@ export namespace Crafter {
|
|||
struct LocalProjectSpec {
|
||||
fs::path projectFile; // relative to cwd or absolute
|
||||
std::vector<std::string> args = ProjectArgs(); // as GitProjectSpec::args
|
||||
std::string configuration; // as GitProjectSpec::configuration
|
||||
};
|
||||
|
||||
// Same as GitProject but for a local on-disk project — no fetch, no
|
||||
// cache copy. Resolves projectFile to its canonical absolute path and
|
||||
// recursively LoadProject's it. Returns a stable Configuration* owned
|
||||
// by the same internal cache as GitProject.
|
||||
// loads it in turn. Returns a stable Configuration* kept by the same
|
||||
// internal cache as GitProject.
|
||||
Configuration* LocalProject(const LocalProjectSpec& spec);
|
||||
|
||||
// Clone (or update) the given git source into the shared external
|
||||
|
|
@ -147,11 +157,11 @@ export namespace Crafter {
|
|||
|
||||
namespace Crafter {
|
||||
// Where GitProject or LocalProject loaded a Configuration from. The
|
||||
// loader keeps this beside the cache that owns the Configuration, since
|
||||
// the Configuration itself cannot say: only the one they return has its
|
||||
// path rebased, and the configurations a dependency's project file makes
|
||||
// for itself keep a path such as "./", which resolves against the
|
||||
// consumer's directory.
|
||||
// loader keeps this beside the cache that holds the Configuration, since
|
||||
// the Configuration itself cannot say: only the ones its project file
|
||||
// returns have their paths rebased, and the configurations a
|
||||
// dependency's project file makes for itself and does not return keep a
|
||||
// path such as "./", which resolves against the consumer's directory.
|
||||
struct LoadedProject {
|
||||
fs::path projectFile; // absolute
|
||||
// What a consumer's AGENTS.md calls it: the repository's name for a
|
||||
|
|
@ -166,8 +176,20 @@ namespace Crafter {
|
|||
// Two specs that pin one library differently are one library.
|
||||
std::string identity;
|
||||
};
|
||||
// The LoadedProject behind a Configuration that GitProject or
|
||||
// LocalProject returned; nullopt for any other: the project crafter-build
|
||||
// was pointed at, and every configuration a project file makes itself.
|
||||
// The LoadedProject behind a Configuration that a project file GitProject
|
||||
// or LocalProject loaded returned, the ones the spec did not pick
|
||||
// included; nullopt for any other: what the project file crafter-build
|
||||
// was pointed at makes itself, and what a loaded project file makes for
|
||||
// itself and does not return.
|
||||
std::optional<LoadedProject> LoadedProjectOf(const Configuration& cfg);
|
||||
// The project that keeps `cfg` to itself: one GitProject or LocalProject
|
||||
// loaded whose project file did not return `cfg`, while a configuration
|
||||
// that file did return led to it when the file was loaded. A
|
||||
// configuration leads to what it is built on (`dependencies`) and to
|
||||
// the configurations of its tests (`tests`), and through each of those
|
||||
// to what that one leads to. nullopt for every other configuration: one
|
||||
// a loaded project file returned, and one that nothing a loaded project
|
||||
// file returned led to, such as what the project file crafter-build was
|
||||
// pointed at makes itself.
|
||||
std::optional<LoadedProject> KeptBy(const Configuration& cfg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ export namespace Crafter {
|
|||
// Absolute path of the loaded project.cpp. It is linted too, and its
|
||||
// parent directory is the project root that decides which dependency
|
||||
// Configurations contribute rules/files (GitProject / cache-dir deps
|
||||
// are foreign code and skipped). Empty => fall back to cfg.path.
|
||||
// are foreign code and skipped). Empty => fall back to cfg.path, of
|
||||
// several configurations the first one's.
|
||||
std::filesystem::path projectFile;
|
||||
};
|
||||
|
||||
|
|
@ -62,4 +63,10 @@ export namespace Crafter {
|
|||
// findings compiler-style (Report), would-change paths (Check), or
|
||||
// formatted paths (Apply), plus a summary line.
|
||||
LintSummary RunLint(Configuration& projectCfg, const RunLintOptions& opts);
|
||||
// The same for the several configurations a project file returns, as
|
||||
// one run over all of them: each is a root, and the roots come before
|
||||
// what any of them depends on, in the order given. A rule two of them
|
||||
// register under one name runs once, as the first of them in that order
|
||||
// registered it, and a source two of them reach is linted once.
|
||||
LintSummary RunLint(std::span<Configuration* const> configurations, const RunLintOptions& opts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,17 +98,47 @@ namespace Crafter {
|
|||
// or the org.flatpak.Builder app where the host has none.
|
||||
std::int32_t RunHostFlatpakBuilder(std::string_view arguments);
|
||||
std::string GetBaseCommand(const Configuration& config);
|
||||
// The configurations `projectFile` describes, in the order it gives them.
|
||||
// Compiles the file into a shared object in the build/ beside it, unless
|
||||
// the one there is current, loads that into this process and calls the
|
||||
// file's entry point with `args`. A project file defines one of two:
|
||||
// extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args);
|
||||
// extern "C" std::vector<Configuration*> CrafterBuildConfigurations(std::span<const std::string_view> args);
|
||||
// The first is a project of one configuration, which comes back as a
|
||||
// list of one. The second is a project of several that need not have
|
||||
// anything to do with each other, such as a library and a tool, or the
|
||||
// programs of one repository; they come back as the file returned them.
|
||||
// The two names are how a loaded file says which it is: both are C
|
||||
// symbols, which carry no return type, so one name with two return types
|
||||
// would be called as whichever the loader guessed. Throws for a file
|
||||
// that defines neither or both, and for a CrafterBuildConfigurations
|
||||
// that returns nothing, a null pointer, one configuration twice, or one
|
||||
// that a project GitProject or LocalProject loaded keeps to itself
|
||||
// (KeptBy): every configuration in the list is one the file made or one
|
||||
// those two returned.
|
||||
//
|
||||
// The pointers are used for as long as the process runs. What a
|
||||
// CrafterBuildConfigurations returns is its project file's to keep that
|
||||
// long, at addresses that do not change: in a std::deque the file only
|
||||
// adds to, one new set per call, or what GitProject and LocalProject
|
||||
// gave it. What a CrafterBuildProject returns is kept here, constructed
|
||||
// by that call and never moved.
|
||||
export std::vector<Configuration*> LoadConfigurations(const fs::path& projectFile, std::span<const std::string_view> args);
|
||||
// What the CrafterBuildProject of `projectFile` returns, loaded as
|
||||
// LoadConfigurations loads it. Throws for a project file that defines
|
||||
// CrafterBuildConfigurations: the configurations that one returns stay
|
||||
// where the file keeps them and cannot be returned by value.
|
||||
export Configuration LoadProject(const fs::path& projectFile, std::span<const std::string_view> args);
|
||||
// A dependency the project file currently running its CrafterBuildProject
|
||||
// A dependency the project file currently running its entry point
|
||||
// declared with `#pragma crafter dependency`, so it can also be wired
|
||||
// into the build graph (a test that links the same module, say) without
|
||||
// spelling the source twice. `name` is the dependency's Configuration
|
||||
// name or any module it exports — whatever the project file `import`s.
|
||||
// Throws when no such dependency was declared, or when called from
|
||||
// anywhere other than inside LoadProject.
|
||||
// anywhere other than inside a project file's load.
|
||||
export Configuration* ProjectDependency(std::string_view name);
|
||||
// True while the project file crafter-build was pointed at runs its
|
||||
// CrafterBuildProject, and when no project file is running at all; false
|
||||
// entry point, and when no project file is running at all; false
|
||||
// inside a dependency's project file (a `#pragma crafter dependency`,
|
||||
// GitProject or LocalProject target). Wire anything only the project's
|
||||
// own build or test run needs behind it. The case that forced it: a
|
||||
|
|
@ -117,9 +147,9 @@ namespace Crafter {
|
|||
// project file in turn and the two recurse until the cycle guard throws.
|
||||
export bool IsTopLevelProject();
|
||||
// What the `#pragma crafter dependency` lines of `projectFile` resolved
|
||||
// to the last time LoadProject loaded it in this process, in file order;
|
||||
// to the last time it was loaded in this process, in file order;
|
||||
// empty when it has none or was never loaded. Unlike ProjectDependency
|
||||
// this still answers once LoadProject has returned, which is when the
|
||||
// this still answers once the load has returned, which is when the
|
||||
// dependency notes of the project crafter-build was pointed at are
|
||||
// gathered (Crafter.Build:Agents).
|
||||
std::vector<Configuration*> PragmaDependencies(const fs::path& projectFile);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ export namespace Crafter {
|
|||
// Print the script names instead of running one.
|
||||
bool listOnly = false;
|
||||
// Absolute path of the loaded project.cpp; its directory becomes
|
||||
// ScriptContext::projectDir. Empty => fall back to cfg.path.
|
||||
// ScriptContext::projectDir. Empty => fall back to the path of the
|
||||
// configuration the script is declared on.
|
||||
std::filesystem::path projectFile;
|
||||
};
|
||||
|
||||
|
|
@ -37,4 +38,10 @@ export namespace Crafter {
|
|||
// (a raw wait status passed along by mistake) would otherwise wrap to
|
||||
// success.
|
||||
std::int32_t RunScript(Configuration& projectCfg, const RunScriptOptions& opts);
|
||||
// The same over the scripts of several configurations, the ones a
|
||||
// project file returns, as one list in the order given: a name two of
|
||||
// them declare is a name declared twice, and a configuration the list
|
||||
// names twice counts once. The script's ScriptContext::project is the
|
||||
// configuration it is declared on.
|
||||
std::int32_t RunScript(std::span<Configuration* const> configurations, const RunScriptOptions& opts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,15 +88,26 @@ export namespace Crafter {
|
|||
};
|
||||
|
||||
TestSummary RunTests(Configuration& projectCfg, const RunTestsOptions& opts, std::span<const std::string_view> projectArgs = {});
|
||||
// The tests of several configurations, those a project file returns, as
|
||||
// one run: one sweep over the targets they declare, one summary, and
|
||||
// one build pass per target, so a library that tests of two of them link
|
||||
// is built once. The log a failed, crashed or timed-out test leaves
|
||||
// goes under the path of the configuration that declares it. A test
|
||||
// belongs to one configuration: where two of them each declare one that
|
||||
// would be built into the same directory, which two tests of one name
|
||||
// compiled alike are, both fail without being built and name the
|
||||
// configurations. A configuration the list names twice counts once.
|
||||
TestSummary RunTests(std::span<Configuration* const> configurations, const RunTestsOptions& opts, std::span<const std::string_view> projectArgs = {});
|
||||
TestResult RunSingleTest(const Test& test, const std::filesystem::path& binary, std::chrono::seconds timeout);
|
||||
|
||||
// Parent-project access for test fixtures. Run() sets the pointer to the
|
||||
// root project's Configuration before discovery; fixtures call ParentLib()
|
||||
// to obtain a Configuration* for one of the parent's libraries (or the
|
||||
// parent itself) so they can declare it as a dependency without rebuilding
|
||||
// the lib config from scratch. Lookup is by Configuration::name and
|
||||
// recurses through the parent's dependency graph.
|
||||
// The configurations of the project crafter-build was pointed at, by
|
||||
// name. Run() hands SetParentProject what the project file returned,
|
||||
// once it has loaded. ParentLib() then finds a Configuration* by
|
||||
// Configuration::name among them and what they depend on, searching the
|
||||
// dependency graph of each in the order the file returned them, and
|
||||
// throws when none has that name or no project is set.
|
||||
void SetParentProject(Configuration* parent);
|
||||
void SetParentProject(std::span<Configuration* const> parents);
|
||||
Configuration* ParentLib(std::string_view name);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue