refactor: Add crate for shared functionality

Adds an additional crate for shared functionality between dtmt and dtmm
that doesn't fit in the sdk.
This commit is contained in:
Lucas Schwiderski 2023-02-23 15:18:16 +01:00
parent 41344f022d
commit 45e0d79fa7
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
11 changed files with 78 additions and 39 deletions

9
Cargo.lock generated
View file

@ -673,6 +673,7 @@ dependencies = [
"color-eyre",
"confy",
"druid",
"dtmt-shared",
"futures",
"oodle-sys",
"sdk",
@ -694,6 +695,7 @@ dependencies = [
"color-eyre",
"confy",
"csv-async",
"dtmt-shared",
"futures",
"futures-util",
"glob",
@ -715,6 +717,13 @@ dependencies = [
"zip",
]
[[package]]
name = "dtmt-shared"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "dwrote"
version = "0.11.0"

View file

@ -11,11 +11,12 @@ clap = { version = "4.0.15", features = ["color", "derive", "std", "cargo", "str
color-eyre = "0.6.2"
confy = "0.5.1"
druid = { git = "https://github.com/linebender/druid.git", features = ["im"] }
dtmt-shared = { path = "../../lib/dtmt-shared", version = "*" }
futures = "0.3.25"
sdk = { path = "../../lib/sdk", version = "0.2.0" }
serde = { version = "1.0.152", features = ["derive"] }
serde_sjson = { path = "../../lib/serde_sjson", version = "*" }
oodle-sys = { path = "../../lib/oodle-sys", version = "*" }
sdk = { path = "../../lib/sdk", version = "0.2.0" }
serde_sjson = { path = "../../lib/serde_sjson", version = "*" }
serde = { version = "1.0.152", features = ["derive"] }
tokio = { version = "1.23.0", features = ["rt", "fs", "tracing", "sync"] }
tracing = "0.1.37"
tracing-error = "0.2.0"

View file

@ -8,14 +8,14 @@ use std::sync::Arc;
use color_eyre::eyre::Context;
use color_eyre::{eyre, Help, Result};
use druid::FileInfo;
use dtmt_shared::ModConfig;
use futures::stream;
use futures::StreamExt;
use sdk::filetype::lua;
use sdk::filetype::package::Package;
use sdk::murmur::Murmur64;
use sdk::{
Bundle, BundleDatabase, BundleFile, BundleFileType, BundleFileVariant, FromBinary, ModConfig,
ToBinary,
Bundle, BundleDatabase, BundleFile, BundleFileType, BundleFileVariant, FromBinary, ToBinary,
};
use tokio::io::AsyncWriteExt;
use tokio::{fs, try_join};

View file

@ -7,7 +7,7 @@ use druid::{
AppDelegate, Command, Data, DelegateCtx, Env, FileInfo, Handled, Lens, Selector, SingleUse,
Target,
};
use sdk::ModConfig;
use dtmt_shared::ModConfig;
use tokio::sync::mpsc::UnboundedSender;
use crate::Config;

View file

@ -5,28 +5,29 @@ edition = "2021"
[dependencies]
clap = { version = "4.0.15", features = ["color", "derive", "std", "cargo", "unicode"] }
cli-table = { version = "0.4.7", default-features = false, features = ["derive"] }
color-eyre = "0.6.2"
confy = "0.5.1"
csv-async = { version = "1.2.4", features = ["tokio", "serde"] }
sdk = { path = "../../lib/sdk", version = "0.2.0" }
dtmt-shared = { path = "../../lib/dtmt-shared", version = "*" }
futures = "0.3.25"
futures-util = "0.3.24"
glob = "0.3.0"
libloading = "0.7.4"
nanorand = "0.7.0"
pin-project-lite = "0.2.9"
serde = { version = "1.0.147", features = ["derive"] }
oodle-sys = { path = "../../lib/oodle-sys", version = "*" }
pin-project-lite = "0.2.9"
promptly = "0.3.1"
sdk = { path = "../../lib/sdk", version = "0.2.0" }
serde_sjson = { path = "../../lib/serde_sjson", version = "*" }
tokio = { version = "1.21.2", features = ["rt-multi-thread", "fs", "process", "macros", "tracing", "io-util", "io-std"] }
serde = { version = "1.0.147", features = ["derive"] }
string_template = "0.2.1"
tokio-stream = { version = "0.1.11", features = ["fs", "io-util"] }
tracing = { version = "0.1.37", features = ["async-await"] }
tokio = { version = "1.21.2", features = ["rt-multi-thread", "fs", "process", "macros", "tracing", "io-util", "io-std"] }
tracing-error = "0.2.0"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
confy = "0.5.1"
tracing = { version = "0.1.37", features = ["async-await"] }
zip = "0.6.3"
string_template = "0.2.1"
promptly = "0.3.1"
cli-table = { version = "0.4.7", default-features = false, features = ["derive"] }
[dev-dependencies]
tempfile = "3.3.0"

View file

@ -4,10 +4,11 @@ use std::sync::Arc;
use clap::{value_parser, Arg, ArgMatches, Command};
use color_eyre::eyre::{self, Context, Result};
use color_eyre::{Help, Report};
use dtmt_shared::ModConfig;
use futures::future::try_join_all;
use futures::StreamExt;
use sdk::filetype::package::Package;
use sdk::{Bundle, BundleFile, ModConfig};
use sdk::{Bundle, BundleFile};
use tokio::fs::{self, File};
use tokio::io::AsyncReadExt;

View file

@ -0,0 +1,9 @@
[package]
name = "dtmt-shared"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = "1.0.152"

View file

@ -0,0 +1,13 @@
= dtmt-shared
:idprefix:
:idseparator:
:toc: macro
:toclevels: 1
:!toc-title:
:caution-caption: :fire:
:important-caption: :exclamtion:
:note-caption: :paperclip:
:tip-caption: :bulb:
:warning-caption: :warning:
A set of types and functions shared between multiple crates within _Darktide Mod Tools_ that don't fit into the engine SDK.

View file

@ -0,0 +1,22 @@
#[derive(Clone, Debug, Default, serde::Deserialize)]
pub struct ModConfigResources {
pub init: String,
#[serde(default)]
pub data: Option<String>,
#[serde(default)]
pub localization: Option<String>,
}
#[derive(Clone, Debug, Default, serde::Deserialize)]
pub struct ModConfig {
#[serde(skip)]
pub dir: std::path::PathBuf,
pub id: String,
pub name: String,
pub description: String,
pub version: String,
pub packages: Vec<std::path::PathBuf>,
pub resources: ModConfigResources,
#[serde(default)]
pub depends: Vec<String>,
}

View file

@ -0,0 +1,6 @@
use tracing_subscriber::fmt::format::Writer;
fn format_time(w: &mut Writer) -> std::fmt::Result {
let time = now_local();
write!(w, "");
}

View file

@ -9,26 +9,3 @@ pub use bundle::database::BundleDatabase;
pub use bundle::decompress;
pub use bundle::{Bundle, BundleFile, BundleFileType, BundleFileVariant};
pub use context::Context;
#[derive(Clone, Debug, Default, serde::Deserialize)]
pub struct ModConfigResources {
pub init: String,
#[serde(default)]
pub data: Option<String>,
#[serde(default)]
pub localization: Option<String>,
}
#[derive(Clone, Debug, Default, serde::Deserialize)]
pub struct ModConfig {
#[serde(skip)]
pub dir: std::path::PathBuf,
pub id: String,
pub name: String,
pub description: String,
pub version: String,
pub packages: Vec<std::path::PathBuf>,
pub resources: ModConfigResources,
#[serde(default)]
pub depends: Vec<String>,
}