chiark / gitweb /
otterlib: Initialise the nwtemplates
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 13:53:01 +0000 (14:53 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 15:02:05 +0000 (16:02 +0100)
Otherwise library items that depend on magical pieces that use these
templates (eg, dice) don't work correctly.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
src/bin/otterlib.rs

index ee8cd157c45d7d9494cff568c0d4290b21524b64..c7094ccc6631649133520056acc2099f158fa4d5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -373,8 +373,10 @@ $(addprefix templates/,$(TXTFILES)): templates/%: %.txt
 
 libraries: $(LIBRARY_FILES)
 
-templates/shapelib.html: $(TARGET_DIR)/debug/otterlib $(LIBRARY_FILES)
+templates/shapelib.html: $(TARGET_DIR)/debug/otterlib $(LIBRARY_FILES) \
+                       $(NWTEMPLATEASSETS)
        $(NAILING_CARGO_JUST_RUN) $(abspath $<) \
+       --nwtemplates $(abspath nwtemplates) \
        --libs '$(addprefix $(PWD)/, $(addsuffix .toml, $(LIBRARIES)))' \
                preview >$@.tmp && mv -f $@.tmp $@
 
index 51820650aab2c0a0763cf851d8bdc2ef0e648857..fb05bb40815c782098de8c479e8fc27705dc79e7 100644 (file)
@@ -46,6 +46,9 @@ use structopt::StructOpt;
 #[derive(Debug,Clone)]
 #[derive(StructOpt)]
 pub struct Opts {
+  #[structopt(long="--nwtemplates", default_value="./nwtemplates")]
+  nwtemplates: String,
+
   #[structopt(long="--libs", default_value="library/*.toml")]
   libs: String,
 
@@ -82,6 +85,8 @@ fn preview(opts: &Opts, items: Vec<ItemForOutput>) {
   const SEVERAL: usize = 3;
   let ig_dummy = Instance::dummy();
 
+  nwtemplates::init_from_dir(&opts.nwtemplates)?;
+
   impl Prep {
     fn want_several(&self) -> bool {
       self.size[0] < 50.0