Skip to content

Commit

Permalink
use python arma3-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 18, 2024
1 parent 246d1c2 commit 6c890d2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 20 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,15 @@ jobs:
cd mod && hemtt dev
- name: Install Arma 3 Tools
if: startsWith(matrix.os.runner, 'windows')
uses: arma-actions/arma3-tools@master
uses: arma-actions/arma3-tools@python
with:
toolsUrl: ${{ secrets.ARMA3_TOOLS_URL }}
- name: Install Arma 3 Tools (Linux)
if: startsWith(matrix.os.runner, 'ubuntu')
run: |
wget -O arma3.zip ${{ secrets.ARMA3_TOOLS_URL }}
unzip arma3.zip -d /tmp/arma3tools
- name: Install Wine
if: startsWith(matrix.os.runner, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y wine64
- name: Run `hemtt build` on ${{ matrix.mod.repo }}
env:
HEMTT_BI_TOOLS: /tmp/arma3tools
run: |
cd mod && hemtt build
Expand Down
36 changes: 36 additions & 0 deletions bin/src/modules/binarize/error/bbe7_wine_not_found.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::sync::Arc;

use hemtt_workspace::reporting::{Code, Diagnostic, Severity};

pub struct WineNotFound;

impl Code for WineNotFound {
fn ident(&self) -> &'static str {
"BBE7"
}

fn severity(&self) -> Severity {
Severity::Error
}

fn message(&self) -> String {
String::from("`wine64` not found in PATH.")
}

fn note(&self) -> Option<String> {
Some(String::from(
"When specifying tools on Linux, make sure `wine64` is in your PATH.",
))
}

fn diagnostic(&self) -> Option<Diagnostic> {
Some(Diagnostic::simple(self))
}
}

impl WineNotFound {
#[allow(dead_code)] // only used on non-windows platforms
pub fn code() -> Arc<dyn Code> {
Arc::new(Self)
}
}
10 changes: 6 additions & 4 deletions bin/src/modules/binarize/error/bbw1_tools_not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ use std::sync::Arc;

use hemtt_workspace::reporting::{Code, Diagnostic, Severity};

pub struct ToolsNotFound;
pub struct ToolsNotFound {
severity: Severity,
}

impl Code for ToolsNotFound {
fn ident(&self) -> &'static str {
"BBW1"
}

fn severity(&self) -> Severity {
Severity::Warning
self.severity
}

fn message(&self) -> String {
Expand All @@ -30,7 +32,7 @@ impl Code for ToolsNotFound {

impl ToolsNotFound {
#[allow(dead_code)] // used in windows only
pub fn code() -> Arc<dyn Code> {
Arc::new(Self)
pub fn code(severity: Severity) -> Arc<dyn Code> {
Arc::new(Self { severity })
}
}
1 change: 1 addition & 0 deletions bin/src/modules/binarize/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod bbe3_binarize_failed;
pub mod bbe4_missing_textures;
pub mod bbe5_missing_material;
pub mod bbe6_missing_pdrive;
pub mod bbe7_wine_not_found;

pub mod bbw1_tools_not_found;
pub mod bbw2_platform_not_supported;
30 changes: 22 additions & 8 deletions bin/src/modules/binarize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{

use hemtt_common::config::PDriveOption;
use hemtt_p3d::SearchCache;
use hemtt_workspace::reporting::Severity;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use vfs::VfsFileType;

Expand Down Expand Up @@ -74,26 +75,39 @@ impl Module for Binarize {
if path.exists() {
self.command = Some(path.display().to_string());
} else {
report.push(ToolsNotFound::code());
report.push(ToolsNotFound::code(Severity::Warning));
}
setup_tmp(ctx)?;
Ok(report)
}

#[cfg(not(windows))]
fn init(&mut self, ctx: &Context) -> Result<Report, Error> {
use error::bbe7_wine_not_found::WineNotFound;

let mut report = Report::new();
let Ok(tools_path) = std::env::var("HEMTT_BI_TOOLS") else {
report.push(PlatformNotSupported::code());
return Ok(report);
let tools_path = {
let default = PathBuf::from("~/.local/share/arma3tools");
if let Ok(path) = std::env::var("HEMTT_BI_TOOLS") {
PathBuf::from(path)
} else {
if !default.exists() {
report.push(PlatformNotSupported::code());
return Ok(report);
}
default
}
};
let path = PathBuf::from(tools_path)
.join("Binarize")
.join("binarize_x64.exe");
let path = tools_path.join("Binarize").join("binarize_x64.exe");
if path.exists() {
self.command = Some(path.display().to_string());
let mut cmd = Command::new("wine64");
cmd.arg("--version");
if cmd.output().is_err() {
report.push(WineNotFound::code());
}
} else {
report.push(ToolsNotFound::code());
report.push(ToolsNotFound::code(Severity::Warning));
}
setup_tmp(ctx)?;
Ok(report)
Expand Down

0 comments on commit 6c890d2

Please sign in to comment.