Skip to content

Commit

Permalink
fix root paths, improve eof error
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Jan 23, 2023
1 parent ebf14f5 commit ab6ffdc
Show file tree
Hide file tree
Showing 22 changed files with 650 additions and 110 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/book.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ jobs:
- uses: actions/checkout@v2

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
run: cargo install mdbook mdbook-admonish

- run: mdbook build

Expand Down
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ members = [
]

[workspace.dependencies]
clap = "4.1.1"
clap = "4.1.2"
colored = "2.0.0"
git2 = "0.16.1"
pest = "2.5.3"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# HEMTT

An opinionated build system for Arma 3 mods.

[The HEMTT Book](https://brettmayson.github.io/HEMTT)
6 changes: 2 additions & 4 deletions bin/app/src/modules/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ impl Module for Files {
continue;
}

let relative = entry.filename().trim_start_matches('/').to_string();

if !glob::Pattern::new(&file)?.matches(&relative) {
if !glob::Pattern::new(&file)?.matches(entry.as_str()) {
continue;
}

Expand All @@ -47,7 +45,7 @@ impl Module for Files {
create_dir_all(&d)?;
}

d.push(relative);
d.push(entry.as_str().trim_start_matches('/'));
println!("Copying `{:#?}` => {:#?}", entry.as_str(), d);
std::io::copy(&mut entry.open_file()?, &mut std::fs::File::create(&d)?).unwrap();
}
Expand Down
1 change: 1 addition & 0 deletions bin/app/src/modules/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn preprocess(path: VfsPath, ctx: &Context, resolver: &VfsResolver) -> Resul
let rapified = Config::parse(
ctx.config().hemtt().config(),
&mut tokens.into_iter().peekmore(),
&Token::builtin(None),
)?;
println!("parsed {}", path.as_str());
let out = if path.filename() == "config.cpp" {
Expand Down
22 changes: 16 additions & 6 deletions bin/libs/config/src/project/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ pub struct Options {
impl Options {
#[must_use]
pub fn include(&self) -> Vec<String> {
let mut files = self.include.clone();
let mut files = self
.include
.iter()
.map(|i| {
if i.starts_with('/') {
i.to_string()
} else {
format!("/{i}")
}
})
.collect::<Vec<_>>();
for default in [
"mod.cpp",
"meta.cpp",
"LICENSE",
"logo_ca.paa",
"logo_co.paa",
"/mod.cpp",
"/meta.cpp",
"/LICENSE",
"/logo_ca.paa",
"/logo_co.paa",
]
.iter()
.map(std::string::ToString::to_string)
Expand Down
1 change: 1 addition & 0 deletions bin/libs/internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ hemtt-error = { path = "../../../libs/error" }

hemtt-config = { path = "../../../libs/config" }
hemtt-preprocessor = { path = "../../../libs/preprocessor" }
hemtt-tokens = { path = "../../../libs/tokens" }

clap = { workspace = true }
peekmore = "1.0.0"
1 change: 1 addition & 0 deletions bin/libs/internal/src/rapify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn run(source: &Path, dest: &PathBuf) -> Result<(), AppError> {
let rapified = Config::parse(
&hemtt_config::Options::default(),
&mut tokens.into_iter().peekmore(),
&hemtt_tokens::Token::builtin(None),
)?;
let mut output = Vec::new();
rapified.rapify(&mut output, 0).unwrap();
Expand Down
7 changes: 7 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ git-repository-url = "https://github.com/brettmayson/HEMTT/tree/main/book"
edit-url-template = "https://github.com/brettmayson/HEMTT/edit/main/{path}"
default-theme = "ayu"
preferred-dark-theme = "ayu"
additional-css = ['./book/mdbook-admonish.css']

[build]
build-dir = "target/book"

[preprocessor]

[preprocessor.admonish]
command = "mdbook-admonish"
assets_version = "2.0.0" # do not edit: managed by `mdbook-admonish install`
6 changes: 5 additions & 1 deletion book/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ print("Set version to " + HEMTT_PROJECT_VERSION);

### Real

`*_release` phases have a real file system. This means that the files are actually written to disk. Be careful when modifying files, as you can modify the project files.
`*_release` phases have a real file system. This means that the files are actually written to disk.

```admonish danger
Be careful when modifying files while using the real file system, as you can destructively modify the project files. It is recommended to use the virtual file system whenever possible, and commit the changes to the project files prior to testing hooks.
```

When using the real file system, two additional constants are available. `HEMTT_DIRECTORY` is the root of the project, and `HEMTT_OUTPUT` is the root of the build output.

Expand Down
Loading

0 comments on commit ab6ffdc

Please sign in to comment.