Added mktim-deps for tim dependencies.
Currently, we didn't depend on the image itself, only on the (optional) clut.
This commit is contained in:
parent
7ec665c407
commit
761b4a3a6a
20
tools/ddw3-tim-tools/src/bin/mktim-deps/args.rs
Normal file
20
tools/ddw3-tim-tools/src/bin/mktim-deps/args.rs
Normal file
@ -0,0 +1,20 @@
|
||||
//! Arguments
|
||||
|
||||
// Imports
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(clap::Parser)]
|
||||
#[clap(author, version, about)]
|
||||
pub struct Args {
|
||||
/// Config file
|
||||
pub config_file: PathBuf,
|
||||
|
||||
/// Output file
|
||||
#[clap(long = "output", short = 'o')]
|
||||
pub output_file: PathBuf,
|
||||
|
||||
/// Output dependency
|
||||
#[clap(long = "output-deps", short = 'o')]
|
||||
pub output_deps: PathBuf,
|
||||
}
|
||||
49
tools/ddw3-tim-tools/src/bin/mktim-deps/main.rs
Normal file
49
tools/ddw3-tim-tools/src/bin/mktim-deps/main.rs
Normal file
@ -0,0 +1,49 @@
|
||||
//! `TIM` creator dependencies
|
||||
|
||||
// Features
|
||||
#![feature(seek_stream_len, generic_arg_infer, let_chains)]
|
||||
|
||||
// Modules
|
||||
mod args;
|
||||
|
||||
// Imports
|
||||
use {
|
||||
anyhow::Context,
|
||||
args::Args,
|
||||
clap::Parser,
|
||||
ddw3_tim_tools::{Config, ConfigClutKind},
|
||||
ddw3_util::DepsFileWriter,
|
||||
std::{fs, io::BufWriter},
|
||||
};
|
||||
|
||||
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
// Initialize the logger
|
||||
ddw3_logger::init().context("Unable to initialize logger")?;
|
||||
|
||||
// Get all args
|
||||
let args = Args::parse();
|
||||
tracing::debug!(?args, "Arguments");
|
||||
|
||||
// Read the config
|
||||
let config_parent = args.config_file.parent().context("Unable to get config file parent")?;
|
||||
let config = ddw3_util::read_toml::<Config, _>(&args.config_file).context("Unable to read config file")?;
|
||||
|
||||
// Create the deps file writer
|
||||
let mut deps_file_writer = DepsFileWriter::new();
|
||||
let deps_file_output = deps_file_writer.target_mut(args.output_file);
|
||||
deps_file_output.add_dep(ddw3_util::resolve_input_path(&config.img.path, config_parent));
|
||||
if let Some(clut) = &config.clut &&
|
||||
let ConfigClutKind::Include { path } | ConfigClutKind::External { path } = &clut.kind
|
||||
{
|
||||
deps_file_output.add_dep(ddw3_util::resolve_input_path(path, config_parent));
|
||||
}
|
||||
|
||||
let deps_file = fs::File::create(args.output_deps).context("Unable to create output dependency file")?;
|
||||
let mut deps_file = BufWriter::new(deps_file);
|
||||
deps_file_writer
|
||||
.write_to(&mut deps_file)
|
||||
.context("Unable to write output dependency file")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
19
zbuild.yaml
19
zbuild.yaml
@ -45,6 +45,7 @@ alias:
|
||||
mkpack : $(build_rust_tool_dir)/mkpack
|
||||
mkpack_deps : $(build_rust_tool_dir)/mkpack-deps
|
||||
mktim : $(build_rust_tool_dir)/mktim
|
||||
mktim_deps : $(build_rust_tool_dir)/mktim-deps
|
||||
mkmap : $(build_rust_tool_dir)/mkmap
|
||||
mkmap_deps : $(build_rust_tool_dir)/mkmap-deps
|
||||
mkmap_tile : $(build_rust_tool_dir)/mkmap-tile
|
||||
@ -147,8 +148,7 @@ alias:
|
||||
|
||||
# Tim
|
||||
tim : $(build_tim_dir)/^(path).tim
|
||||
tim_img : tim/^(path).png
|
||||
tim_clut: tim/^(path).clut.png
|
||||
tim_deps: $(build_tim_dir)/^(path).d
|
||||
tim_toml: tim/^(path).toml
|
||||
|
||||
# Map
|
||||
@ -453,13 +453,26 @@ rules:
|
||||
deps:
|
||||
- $(tim_toml)
|
||||
- $(mktim)
|
||||
- opt: $(tim_clut)
|
||||
- deps_file: $(tim_deps)
|
||||
- static: $(tim::dir_name)/
|
||||
exec:
|
||||
- - $(mktim)
|
||||
- $(tim_toml)
|
||||
- --output=$(tim)
|
||||
|
||||
# Tim deps
|
||||
tim_deps:
|
||||
out: [$(tim_deps)]
|
||||
deps:
|
||||
- $(tim_toml)
|
||||
- $(mktim_deps)
|
||||
- static: $(tim_deps::dir_name)/
|
||||
exec:
|
||||
- - $(mktim_deps)
|
||||
- $(tim_toml)
|
||||
- --output=$(tim)
|
||||
- --output-deps=$(tim_deps)
|
||||
|
||||
# Pack
|
||||
pack:
|
||||
out: [$(pack)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user