summaryrefslogtreecommitdiff
path: root/subplot-build
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-10-19 19:30:37 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-11-19 20:18:50 +0000
commit5a92266170ae9879b0651e6074e538a4de0a214c (patch)
treed5ecb647701534d6374f441f2c790bfdd2dca848 /subplot-build
parent572d3097770cd8e5cd22d7767c1d18e0d50b9a90 (diff)
downloadsubplot-5a92266170ae9879b0651e6074e538a4de0a214c.tar.gz
various: Rework document to support multiple implementations
In order to eventually shift the document metadata to support more than one template defined for the document this reworks all the internal APIs to expect templates, and also the external CLI to be able to provide it. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplot-build')
-rw-r--r--subplot-build/src/lib.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/subplot-build/src/lib.rs b/subplot-build/src/lib.rs
index 89ea57d..28558e8 100644
--- a/subplot-build/src/lib.rs
+++ b/subplot-build/src/lib.rs
@@ -48,21 +48,26 @@ where
buildrs_output(out_dir, filename, "rs").expect("could not create output filename");
// Generate test program.
- let output = subplot::codegen(filename, &test_rs)?;
+ let output = subplot::codegen(filename, &test_rs, Some("rust"))?;
// Write instructions for Cargo to check if build scripts needs
// re-running.
let base_path = get_basedir_from(filename);
let meta = output.doc.meta();
- buildrs_deps(&base_path, &meta.bindings_filenames());
- buildrs_deps(&base_path, &meta.functions_filenames());
- buildrs_deps(&base_path, &[filename]);
+ buildrs_deps(&base_path, meta.bindings_filenames());
+ let docimpl = output
+ .doc
+ .meta()
+ .document_impl("rust")
+ .expect("We managed to codegen rust, yet the spec is missing?");
+ buildrs_deps(&base_path, docimpl.functions_filenames());
+ buildrs_deps(&base_path, Some(filename));
event!(Level::TRACE, "Finished generating code");
Ok(())
}
-fn buildrs_deps(base_path: &Path, filenames: &[&Path]) {
+fn buildrs_deps<'a>(base_path: &Path, filenames: impl IntoIterator<Item = &'a Path>) {
for filename in filenames {
let filename = base_path.join(filename);
if filename.exists() {