From 5a92266170ae9879b0651e6074e538a4de0a214c Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Tue, 19 Oct 2021 19:30:37 +0100 Subject: 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 --- subplot-build/src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'subplot-build') 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) { for filename in filenames { let filename = base_path.join(filename); if filename.exists() { -- cgit v1.2.1