-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62933ca
commit a92e3ce
Showing
10 changed files
with
77 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use std::{fs::File, io::Write, path::Path}; | ||
|
||
use hemtt_common::error::thiserror; | ||
use rust_embed::RustEmbed; | ||
use tracing::trace; | ||
|
||
#[cfg(windows)] | ||
#[derive(RustEmbed)] | ||
#[folder = "dist/windows"] | ||
struct Distributables; | ||
|
||
#[cfg(not(windows))] | ||
#[derive(RustEmbed)] | ||
#[folder = "dist/linux"] | ||
struct Distributables; | ||
|
||
#[cfg(windows)] | ||
const SOURCE: [&str; 1] = ["asc.exe"]; | ||
|
||
#[cfg(not(windows))] | ||
const SOURCE: [&str; 1] = ["asc"]; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Io(#[from] std::io::Error), | ||
} | ||
|
||
#[must_use] | ||
pub const fn command() -> &'static str { | ||
SOURCE[0] | ||
} | ||
|
||
/// Install Arma Script Compiler | ||
/// | ||
/// # Errors | ||
/// [`Error::Io`] if the file couldn't be created or written to | ||
/// | ||
/// # Panics | ||
/// If an expected file didn't get packed into the binary | ||
pub fn install(path: &Path) -> Result<(), super::Error> { | ||
_install(path).map_err(super::Error::AscError) | ||
} | ||
|
||
fn _install(path: &Path) -> Result<(), Error> { | ||
let _ = std::fs::create_dir_all(path); | ||
for file in SOURCE { | ||
let out = path.join(file); | ||
trace!("unpacking {:?} to {:?}", file, out.display()); | ||
let mut f = File::create(&out)?; | ||
f.write_all( | ||
&Distributables::get(file) | ||
.expect("dist files should exist") | ||
.data, | ||
)?; | ||
#[cfg(target_os = "linux")] | ||
{ | ||
use std::os::unix::fs::PermissionsExt; | ||
std::fs::set_permissions(out, PermissionsExt::from_mode(0o744))?; | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#[cfg(feature = "asc")] | ||
pub mod asc; | ||
#[cfg(feature = "compiler")] | ||
pub mod compiler; | ||
#[cfg(feature = "parser")] | ||
|