Skip to content

Commit 8e68e4b

Browse files
committed
start working on website code
1 parent a9378d0 commit 8e68e4b

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ objdiff-core = { git = "https://github.com/encounter/objdiff", tag = "v3.3.1", s
88
serde = { version = "1.0", features = ["derive"] }
99
serde_json = "1.0"
1010
argp = "0.4"
11-
ts-rs = "10.1"
11+
ts-rs = "11.1"
1212
tabled = "0.20.0"
1313

src/args.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ pub struct OKArgs {
99
#[argp(option)]
1010
pub changes: String,
1111

12-
/// Path to the current Objdiff report file
13-
// #[argp(option)]
14-
// pub report: String,
15-
1612
#[argp(subcommand)]
1713
pub action: Option<OKAction>,
1814
}
@@ -21,6 +17,7 @@ pub struct OKArgs {
2117
#[argp(subcommand)]
2218
pub enum OKAction {
2319
PullRequest(PullRequest),
20+
BuildWebsite(BuildWebsite),
2421
PostToDiscord(PostToDiscord),
2522
}
2623

@@ -42,7 +39,15 @@ pub struct PostToDiscord {
4239
pub add_commentary: bool,
4340
}
4441

45-
// 1. compare two reports and create a struct containing differences
46-
// a) save differences to a file?
47-
// b) post differences to discord?
48-
// 2. load and save progress report to a sensible json format, we only care about game
42+
/// Build the files needed for the progress website
43+
#[derive(FromArgs, Debug)]
44+
#[argp(subcommand, name = "website")]
45+
pub struct BuildWebsite {
46+
/// Path to the latest Objdiff report file
47+
#[argp(option)]
48+
pub report: String,
49+
50+
/// Path to the cached assembly metadata
51+
#[argp(option)]
52+
pub asm_json: String,
53+
}

src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod args;
22
mod commit;
33
mod pr;
4+
mod website;
45

56
use std::{
67
fs::File,
@@ -11,7 +12,7 @@ use args::{OKAction, OKArgs};
1112
use commit::Commit;
1213
use objdiff_core::bindings::report::{Changes, Report};
1314

14-
use crate::pr::generate_pr_report;
15+
use crate::{pr::generate_pr_report, website::AsmInfo};
1516

1617
fn main() {
1718
let args: OKArgs = argp::parse_args_or_exit(argp::DEFAULT);
@@ -33,6 +34,12 @@ fn main() {
3334
// let commit = load_commit(&post_to_discord.commit);
3435
// println!("commit: {:?}", commit);
3536
}
37+
OKAction::BuildWebsite(args) => {
38+
let report = load_report_json(&args.report);
39+
let asm_info = load_asm_json(&args.asm_json);
40+
let first = asm_info.iter().nth(0).unwrap();
41+
println!("{:?}", first);
42+
}
3643
}
3744
}
3845
}
@@ -47,6 +54,11 @@ fn load_report_json(path: &str) -> Report {
4754
serde_json::from_str(&json).unwrap()
4855
}
4956

57+
fn load_asm_json(path: &str) -> Vec<AsmInfo> {
58+
let json = std::fs::read_to_string(path).expect("Unable to read ASM json");
59+
serde_json::from_str(&json).unwrap()
60+
}
61+
5062
fn load_commit(path: &str) -> Commit {
5163
let file = File::open(path).expect("Can't find progress commit file");
5264
let reader = BufReader::new(file);

src/website.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// We need to do some extra processing on the progress report
2+
// before we build the website.
3+
// We mostly use the objdiff report types, but with some added fields.
4+
5+
use objdiff_core::bindings::report::Report;
6+
use serde::{Deserialize, Serialize};
7+
// use ts_rs::TS;
8+
9+
#[derive(Debug, Deserialize)]
10+
// #[ts(export)]
11+
pub struct AsmInfo {
12+
name: String,
13+
opcodes: Vec<String>,
14+
labels: Option<u32>,
15+
}

0 commit comments

Comments
 (0)