Skip to content

Commit a119d9a

Browse files
committed
Add scratch preset_id field for decomp.me
Resolves #133
1 parent ebf6538 commit a119d9a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

objdiff-core/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ pub struct ScratchConfig {
165165
pub ctx_path: Option<PathBuf>,
166166
#[serde(default, skip_serializing_if = "Option::is_none")]
167167
pub build_ctx: Option<bool>,
168+
#[serde(default, skip_serializing_if = "Option::is_none")]
169+
pub preset_id: Option<u32>,
168170
}
169171

170172
pub const CONFIG_FILENAMES: [&str; 3] = ["objdiff.json", "objdiff.yml", "objdiff.yaml"];

objdiff-gui/src/app_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl ScratchConfigV1 {
7171
c_flags: self.c_flags,
7272
ctx_path: self.ctx_path,
7373
build_ctx: self.build_ctx.then_some(true),
74+
preset_id: None,
7475
}
7576
}
7677
}

objdiff-gui/src/jobs/create_scratch.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct CreateScratchConfig {
2323
pub compiler_flags: String,
2424
pub function_name: String,
2525
pub target_obj: PathBuf,
26+
pub preset_id: Option<u32>,
2627
}
2728

2829
impl CreateScratchConfig {
@@ -45,6 +46,7 @@ impl CreateScratchConfig {
4546
compiler_flags: scratch_config.c_flags.clone().unwrap_or_default(),
4647
function_name,
4748
target_obj: target_path.to_path_buf(),
49+
preset_id: scratch_config.preset_id,
4850
})
4951
}
5052

@@ -101,15 +103,18 @@ fn run_create_scratch(
101103
let obj_path = project_dir.join(&config.target_obj);
102104
let file = reqwest::blocking::multipart::Part::file(&obj_path)
103105
.with_context(|| format!("Failed to open {}", obj_path.display()))?;
104-
let form = reqwest::blocking::multipart::Form::new()
106+
let mut form = reqwest::blocking::multipart::Form::new()
105107
.text("compiler", config.compiler.clone())
106108
.text("platform", config.platform.clone())
107109
.text("compiler_flags", config.compiler_flags.clone())
108110
.text("diff_label", config.function_name.clone())
109111
.text("diff_flags", diff_flags)
110112
.text("context", context.unwrap_or_default())
111-
.text("source_code", "// Move related code from Context tab to here")
112-
.part("target_obj", file);
113+
.text("source_code", "// Move related code from Context tab to here");
114+
if let Some(preset) = config.preset_id {
115+
form = form.text("preset", preset.to_string());
116+
}
117+
form = form.part("target_obj", file);
113118
let client = reqwest::blocking::Client::new();
114119
let response = client
115120
.post(formatcp!("{API_HOST}/api/scratch"))

0 commit comments

Comments
 (0)