Various minor changes extracted from unfinished projects #182
2 changed files with 16 additions and 0 deletions
|
@ -55,6 +55,7 @@ pub(crate) fn command_definition() -> Command {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Try to find a `dtmt.cfg` in the given directory or traverse up the parents.
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
async fn find_project_config(dir: Option<PathBuf>) -> Result<ModConfig> {
|
async fn find_project_config(dir: Option<PathBuf>) -> Result<ModConfig> {
|
||||||
let (path, mut file) = if let Some(path) = dir {
|
let (path, mut file) = if let Some(path) = dir {
|
||||||
|
@ -102,6 +103,8 @@ async fn find_project_config(dir: Option<PathBuf>) -> Result<ModConfig> {
|
||||||
Ok(cfg)
|
Ok(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterate over the paths in the given `Package` and
|
||||||
|
/// compile each file by its file type.
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn compile_package_files(pkg: &Package, cfg: &ModConfig) -> Result<Vec<BundleFile>> {
|
async fn compile_package_files(pkg: &Package, cfg: &ModConfig) -> Result<Vec<BundleFile>> {
|
||||||
let root = Arc::new(&cfg.dir);
|
let root = Arc::new(&cfg.dir);
|
||||||
|
@ -148,6 +151,8 @@ async fn compile_package_files(pkg: &Package, cfg: &ModConfig) -> Result<Vec<Bun
|
||||||
results.into_iter().collect()
|
results.into_iter().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Read a `.package` file, collect the referenced files
|
||||||
|
/// and compile all of them into a bundle.
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
async fn build_package(
|
async fn build_package(
|
||||||
cfg: &ModConfig,
|
cfg: &ModConfig,
|
||||||
|
@ -176,6 +181,8 @@ async fn build_package(
|
||||||
Ok(bundle)
|
Ok(bundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cleans the path of internal parent (`../`) or self (`./`) components,
|
||||||
|
/// and ensures that it is relative.
|
||||||
fn normalize_file_path<P: AsRef<Path>>(path: P) -> Result<PathBuf> {
|
fn normalize_file_path<P: AsRef<Path>>(path: P) -> Result<PathBuf> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,15 @@ use crate::bundle::file::UserFile;
|
||||||
use crate::bundle::filetype::BundleFileType;
|
use crate::bundle::filetype::BundleFileType;
|
||||||
use crate::murmur::{HashGroup, IdString64, Murmur64};
|
use crate::murmur::{HashGroup, IdString64, Murmur64};
|
||||||
|
|
||||||
|
/// Resolves a relative path that might contain wildcards into a list of
|
||||||
|
/// paths that exist on disk and match that wildcard.
|
||||||
|
/// This is similar to globbing in Unix shells, but with much less features.
|
||||||
|
///
|
||||||
|
/// The only wilcard character allowed is `*`, and only at the end of the string,
|
||||||
|
/// where it matches all files recursively in that directory.
|
||||||
|
///
|
||||||
|
/// `t` is an optional extension name, that may be used to force a wildcard
|
||||||
|
/// path to only match that file type `t`.
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
async fn resolve_wildcard<P1, P2>(
|
async fn resolve_wildcard<P1, P2>(
|
||||||
|
|
Loading…
Add table
Reference in a new issue