-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tool to automatically download and test a byond version for mis…
…sing signatures
- Loading branch information
Showing
10 changed files
with
593 additions
and
795 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "auxsigcheck" | ||
rust-version = "1.79" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
byond-get = { git = "https://github.com/absolucy/byond-get" } | ||
cfg-if = "1" | ||
clap = { version = "4", features = ["derive"] } | ||
color-eyre = "0.6" | ||
tempdir = "0.3" | ||
|
||
[lints] | ||
workspace = true |
Empty file.
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,22 @@ | ||
#if DM_VERSION >= 515 | ||
#define LIBCALL call_ext | ||
#else | ||
#define LIBCALL call | ||
#endif | ||
|
||
/world/New() | ||
. = ..() | ||
var/result = run_tests() | ||
if(!result) | ||
world.log << "FAILED (unknown, likely runtime)" | ||
else | ||
world.log << "[result]" | ||
del(src) | ||
|
||
/proc/run_tests() | ||
var/dll = world.GetConfig("env", "AUXTOOLS_DLL") | ||
if(!dll) | ||
return "FAILED (AUXTOOLS_DLL not set)" | ||
if(!fexists(dll)) | ||
return "FAILED (AUXTOOLS_DLL path doesn't exist)" | ||
return LIBCALL(dll, "auxtools_check_signatures")() |
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,19 @@ | ||
// DM Environment file for auxsigcheck.dme. | ||
// All manual changes should be made outside the BEGIN_ and END_ blocks. | ||
// New source code should be placed in .dm files: choose File/New --> Code File. | ||
|
||
// BEGIN_INTERNALS | ||
// END_INTERNALS | ||
|
||
// BEGIN_FILE_DIR | ||
#define FILE_DIR . | ||
// END_FILE_DIR | ||
|
||
// BEGIN_PREFERENCES | ||
#define DEBUG | ||
// END_PREFERENCES | ||
|
||
// BEGIN_INCLUDE | ||
#include "auxsigcheck.dm" | ||
// END_INCLUDE | ||
|
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,85 @@ | ||
mod result; | ||
|
||
use byond_get::OsType; | ||
use cfg_if::cfg_if; | ||
use clap::Parser; | ||
use color_eyre::eyre::{Result, WrapErr}; | ||
use result::TestResult; | ||
use std::{path::PathBuf, process::Command}; | ||
use tempdir::TempDir; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(version, about, long_about = None)] | ||
pub struct Args { | ||
/// Path to the auxtools DLL to use. | ||
#[arg(short, long)] | ||
pub auxtools_path: PathBuf, | ||
|
||
/// Version of BYOND to use. | ||
pub version: u16, | ||
|
||
/// Build of BYOND to use. | ||
pub build: u16 | ||
} | ||
|
||
static TEST_DM: &[u8] = include_bytes!("dm/auxsigcheck.dm"); | ||
static TEST_DME: &[u8] = include_bytes!("dm/auxsigcheck.dme"); | ||
|
||
cfg_if! { | ||
if #[cfg(windows)] { | ||
const OS: OsType = OsType::Windows; | ||
const DREAMMAKER_EXE: &str = "dm.exe"; | ||
const DREAMDAEMON_EXE: &str = "dd.exe"; | ||
} else { | ||
const OS: OsType = OsType::Linux; | ||
const DREAMMAKER_EXE: &str = "DreamMaker"; | ||
const DREAMDAEMON_EXE: &str = "DreamDaemon"; | ||
} | ||
} | ||
|
||
fn main() -> Result<()> { | ||
color_eyre::install()?; | ||
let args = Args::parse(); | ||
let auxtools_path = std::path::absolute(args.auxtools_path).wrap_err("failed to get absolute auxtools path")?; | ||
let tmpdir = TempDir::new("auxsigcheck").wrap_err("failed to crate tempdir")?; | ||
let base_path = tmpdir.path(); | ||
|
||
let byond_path = base_path.join("byond"); | ||
byond_get::download_bin(args.version, args.build, OS, &byond_path).wrap_err("failed to download byond")?; | ||
|
||
std::fs::write(base_path.join("auxsigcheck.dm"), TEST_DM).wrap_err("failed to write auxsigcheck.dm")?; | ||
std::fs::write(base_path.join("auxsigcheck.dme"), TEST_DME).wrap_err("failed to write auxsigcheck.dme")?; | ||
|
||
let status = Command::new(byond_path.join(DREAMMAKER_EXE)) | ||
.arg(base_path.join("auxsigcheck.dme")) | ||
.output() | ||
.wrap_err("failed to run DreamMaker")? | ||
.status; | ||
if !status.success() { | ||
panic!("Failed to compile auxsigcheck.dme, DreamMaker exited with code {status}") | ||
} | ||
|
||
std::env::set_var("LD_LIBRARY_PATH", byond_path.to_str().unwrap()); | ||
std::env::set_var("AUXTOOLS_DLL", auxtools_path); | ||
|
||
let test_run = Command::new(byond_path.join(DREAMDAEMON_EXE)) | ||
.arg(base_path.join("auxsigcheck.dmb")) | ||
.args(["-trusted", "-invisible"]) | ||
.output() | ||
.wrap_err("failed to run DreamDaemon")?; | ||
|
||
// cleanup env variables | ||
std::env::remove_var("AUXTOOLS_DLL"); | ||
if !test_run.status.success() { | ||
panic!("Failed to run auxsigcheck.dmb, DreamDaemon exited with code {status}") | ||
} | ||
|
||
let stderr = String::from_utf8_lossy(&test_run.stderr).into_owned(); | ||
match result::extract_test_result(&stderr) { | ||
TestResult::Success => println!("success"), | ||
TestResult::Failed(reason) => println!("failed: {reason}"), | ||
TestResult::Missing(sigs) => println!("missing: {sigs}") | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pub enum TestResult { | ||
Success, | ||
Failed(String), | ||
Missing(String) | ||
} | ||
|
||
pub fn extract_test_result(s: &str) -> TestResult { | ||
for line in s.lines() { | ||
let trimmed = line.trim(); | ||
if trimmed.is_empty() { | ||
continue; | ||
} else if trimmed.starts_with("SUCCESS") { | ||
return TestResult::Success; | ||
} else if trimmed.starts_with("FAILED") { | ||
return TestResult::Failed(trimmed.split('(').nth(1).unwrap().replace(")", "").trim().to_owned()); | ||
} else if trimmed.starts_with("MISSING") { | ||
return TestResult::Missing(trimmed.split(':').nth(1).unwrap().trim().to_owned()); | ||
} | ||
} | ||
panic!("No test result found") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.