mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-10 22:17:51 +00:00
Option to skip building target obj
This commit is contained in:
@@ -7,7 +7,7 @@ use anyhow::{Context, Result};
|
||||
|
||||
use crate::{
|
||||
app::{AppConfig, DiffKind, ViewState},
|
||||
jobs::{bindiff::queue_bindiff, build::queue_build},
|
||||
jobs::{bindiff::queue_bindiff, objdiff::queue_build},
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -50,12 +50,13 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
available_wsl_distros,
|
||||
selected_wsl_distro,
|
||||
project_dir,
|
||||
project_dir_change,
|
||||
build_asm_dir,
|
||||
build_src_dir,
|
||||
build_obj,
|
||||
target_obj_dir,
|
||||
base_obj_dir,
|
||||
obj_path,
|
||||
build_target,
|
||||
left_obj,
|
||||
right_obj,
|
||||
project_dir_change,
|
||||
} = &mut *config_guard;
|
||||
|
||||
ui.heading("Build config");
|
||||
@@ -92,9 +93,9 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
if let Some(path) = rfd::FileDialog::new().pick_folder() {
|
||||
*project_dir = Some(path);
|
||||
*project_dir_change = true;
|
||||
*build_asm_dir = None;
|
||||
*build_src_dir = None;
|
||||
*build_obj = None;
|
||||
*target_obj_dir = None;
|
||||
*base_obj_dir = None;
|
||||
*obj_path = None;
|
||||
}
|
||||
}
|
||||
if let Some(dir) = project_dir {
|
||||
@@ -104,58 +105,59 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
||||
ui.separator();
|
||||
|
||||
if let Some(project_dir) = project_dir {
|
||||
if ui.button("Select asm build dir").clicked() {
|
||||
if ui.button("Select target build dir").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new().set_directory(&project_dir).pick_folder()
|
||||
{
|
||||
*build_asm_dir = Some(path);
|
||||
*build_obj = None;
|
||||
*target_obj_dir = Some(path);
|
||||
*obj_path = None;
|
||||
}
|
||||
}
|
||||
if let Some(dir) = build_asm_dir {
|
||||
if let Some(dir) = target_obj_dir {
|
||||
ui.label(dir.to_string_lossy());
|
||||
}
|
||||
ui.checkbox(build_target, "Build target");
|
||||
|
||||
ui.separator();
|
||||
|
||||
if ui.button("Select src build dir").clicked() {
|
||||
if ui.button("Select base build dir").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new().set_directory(&project_dir).pick_folder()
|
||||
{
|
||||
*build_src_dir = Some(path);
|
||||
*build_obj = None;
|
||||
*base_obj_dir = Some(path);
|
||||
*obj_path = None;
|
||||
}
|
||||
}
|
||||
if let Some(dir) = build_src_dir {
|
||||
if let Some(dir) = base_obj_dir {
|
||||
ui.label(dir.to_string_lossy());
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
}
|
||||
|
||||
if let Some(build_src_dir) = build_src_dir {
|
||||
if let Some(base_dir) = base_obj_dir {
|
||||
if ui.button("Select obj").clicked() {
|
||||
if let Some(path) = rfd::FileDialog::new()
|
||||
.set_directory(&build_src_dir)
|
||||
.set_directory(&base_dir)
|
||||
.add_filter("Object file", &["o", "elf"])
|
||||
.pick_file()
|
||||
{
|
||||
let mut new_build_obj: Option<String> = None;
|
||||
if let Ok(obj_path) = path.strip_prefix(&build_src_dir) {
|
||||
if let Ok(obj_path) = path.strip_prefix(&base_dir) {
|
||||
new_build_obj = Some(obj_path.display().to_string());
|
||||
} else if let Some(build_asm_dir) = build_asm_dir {
|
||||
} else if let Some(build_asm_dir) = target_obj_dir {
|
||||
if let Ok(obj_path) = path.strip_prefix(&build_asm_dir) {
|
||||
new_build_obj = Some(obj_path.display().to_string());
|
||||
}
|
||||
}
|
||||
if let Some(new_build_obj) = new_build_obj {
|
||||
*build_obj = Some(new_build_obj.clone());
|
||||
*obj_path = Some(new_build_obj.clone());
|
||||
view_state.jobs.push(queue_build(new_build_obj, config.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(build_obj) = build_obj {
|
||||
ui.label(&*build_obj);
|
||||
if let Some(obj) = obj_path {
|
||||
ui.label(&*obj);
|
||||
if ui.button("Build").clicked() {
|
||||
view_state.jobs.push(queue_build(build_obj.clone(), config.clone()));
|
||||
view_state.jobs.push(queue_build(obj.clone(), config.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
|
||||
Color32::WHITE,
|
||||
demangled.as_ref().unwrap_or(selected_symbol),
|
||||
);
|
||||
ui.label("Diff asm:");
|
||||
ui.label("Diff target:");
|
||||
ui.separator();
|
||||
});
|
||||
});
|
||||
@@ -342,7 +342,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
|
||||
);
|
||||
}
|
||||
}
|
||||
ui.label("Diff src:");
|
||||
ui.label("Diff base:");
|
||||
ui.separator();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ use egui_extras::{Size, StripBuilder};
|
||||
|
||||
use crate::{
|
||||
app::{View, ViewState},
|
||||
jobs::build::BuildStatus,
|
||||
jobs::objdiff::BuildStatus,
|
||||
obj::{ObjInfo, ObjSymbol, ObjSymbolFlags},
|
||||
};
|
||||
|
||||
@@ -20,6 +20,13 @@ pub fn match_color_for_symbol(symbol: &ObjSymbol) -> Color32 {
|
||||
}
|
||||
}
|
||||
|
||||
const FONT_SIZE: f32 = 14.0;
|
||||
const FONT_ID: FontId = FontId::new(FONT_SIZE, FontFamily::Monospace);
|
||||
|
||||
fn write_text(str: &str, color: Color32, job: &mut LayoutJob) {
|
||||
job.append(str, 0.0, TextFormat { font_id: FONT_ID, color, ..Default::default() });
|
||||
}
|
||||
|
||||
fn symbol_ui(
|
||||
ui: &mut Ui,
|
||||
symbol: &ObjSymbol,
|
||||
@@ -34,61 +41,28 @@ fn symbol_ui(
|
||||
if let Some(sym) = highlighted_symbol {
|
||||
selected = sym == &symbol.name;
|
||||
}
|
||||
let font_id = FontId::new(14.0, FontFamily::Monospace);
|
||||
job.append("[", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GRAY,
|
||||
..Default::default()
|
||||
});
|
||||
write_text("[", Color32::GRAY, &mut job);
|
||||
if symbol.flags.0.contains(ObjSymbolFlags::Common) {
|
||||
job.append("c", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::from_rgb(0, 255, 255),
|
||||
..Default::default()
|
||||
});
|
||||
write_text("c", Color32::from_rgb(0, 255, 255), &mut job);
|
||||
} else if symbol.flags.0.contains(ObjSymbolFlags::Global) {
|
||||
job.append("g", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GREEN,
|
||||
..Default::default()
|
||||
});
|
||||
write_text("g", Color32::GREEN, &mut job);
|
||||
} else if symbol.flags.0.contains(ObjSymbolFlags::Local) {
|
||||
job.append("l", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GRAY,
|
||||
..Default::default()
|
||||
});
|
||||
write_text("l", Color32::GRAY, &mut job);
|
||||
}
|
||||
if symbol.flags.0.contains(ObjSymbolFlags::Weak) {
|
||||
job.append("w", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GRAY,
|
||||
..Default::default()
|
||||
});
|
||||
write_text("w", Color32::GRAY, &mut job);
|
||||
}
|
||||
job.append("] ", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GRAY,
|
||||
..Default::default()
|
||||
});
|
||||
write_text("] ", Color32::GRAY, &mut job);
|
||||
if symbol.match_percent > 0.0 {
|
||||
job.append("(", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GRAY,
|
||||
..Default::default()
|
||||
});
|
||||
job.append(&format!("{:.0}%", symbol.match_percent), 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: match_color_for_symbol(symbol),
|
||||
..Default::default()
|
||||
});
|
||||
job.append(") ", 0.0, TextFormat {
|
||||
font_id: font_id.clone(),
|
||||
color: Color32::GRAY,
|
||||
..Default::default()
|
||||
});
|
||||
write_text("(", Color32::GRAY, &mut job);
|
||||
write_text(
|
||||
&format!("{:.0}%", symbol.match_percent),
|
||||
match_color_for_symbol(symbol),
|
||||
&mut job,
|
||||
);
|
||||
write_text(") ", Color32::GRAY, &mut job);
|
||||
}
|
||||
job.append(name, 0.0, TextFormat { font_id, color: Color32::WHITE, ..Default::default() });
|
||||
write_text(name, Color32::WHITE, &mut job);
|
||||
let response = SelectableLabel::new(selected, job).ui(ui);
|
||||
if response.clicked() {
|
||||
*selected_symbol = Some(symbol.name.clone());
|
||||
@@ -175,7 +149,7 @@ pub fn symbol_diff_ui(ui: &mut Ui, view_state: &mut ViewState) {
|
||||
Some(egui::TextStyle::Monospace);
|
||||
ui.style_mut().wrap = Some(false);
|
||||
|
||||
ui.label("Build asm:");
|
||||
ui.label("Build target:");
|
||||
if result.first_status.success {
|
||||
ui.label("OK");
|
||||
} else {
|
||||
@@ -190,7 +164,7 @@ pub fn symbol_diff_ui(ui: &mut Ui, view_state: &mut ViewState) {
|
||||
Some(egui::TextStyle::Monospace);
|
||||
ui.style_mut().wrap = Some(false);
|
||||
|
||||
ui.label("Build src:");
|
||||
ui.label("Build base:");
|
||||
if result.second_status.success {
|
||||
ui.label("OK");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user