Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom make args #59

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it
// objdiff.json
{
"custom_make": "ninja",
"custom_args": [
"-C",
"build"
],

// Only required if objects use "path" instead of "target_path" and "base_path".
"target_dir": "build/asm",
Expand Down
2 changes: 2 additions & 0 deletions objdiff-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct ProjectConfig {
#[serde(default)]
pub custom_make: Option<String>,
#[serde(default)]
pub custom_args: Option<Vec<String>>,
#[serde(default)]
pub target_dir: Option<PathBuf>,
#[serde(default)]
pub base_dir: Option<PathBuf>,
Expand Down
3 changes: 3 additions & 0 deletions objdiff-gui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ pub struct AppConfig {
#[serde(default)]
pub custom_make: Option<String>,
#[serde(default)]
pub custom_args: Option<Vec<String>>,
#[serde(default)]
pub selected_wsl_distro: Option<String>,
#[serde(default)]
pub project_dir: Option<PathBuf>,
Expand Down Expand Up @@ -131,6 +133,7 @@ impl Default for AppConfig {
Self {
version: AppConfigVersion::default().version,
custom_make: None,
custom_args: None,
selected_wsl_distro: None,
project_dir: None,
target_obj_dir: None,
Expand Down
1 change: 1 addition & 0 deletions objdiff-gui/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub fn load_project_config(config: &mut AppConfig) -> Result<()> {
if let Some((result, info)) = try_project_config(project_dir) {
let project_config = result?;
config.custom_make = project_config.custom_make;
config.custom_args = project_config.custom_args;
config.target_obj_dir = project_config.target_dir.map(|p| project_dir.join(p));
config.base_obj_dir = project_config.base_dir.map(|p| project_dir.join(p));
config.build_base = project_config.build_base;
Expand Down
8 changes: 6 additions & 2 deletions objdiff-gui/src/jobs/objdiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Default for BuildStatus {
pub struct BuildConfig {
pub project_dir: Option<PathBuf>,
pub custom_make: Option<String>,
pub custom_args: Option<Vec<String>>,
pub selected_wsl_distro: Option<String>,
}

Expand All @@ -47,6 +48,7 @@ impl BuildConfig {
Self {
project_dir: config.project_dir.clone(),
custom_make: config.custom_make.clone(),
custom_args: config.custom_args.clone(),
selected_wsl_distro: config.selected_wsl_distro.clone(),
}
}
Expand Down Expand Up @@ -96,10 +98,11 @@ pub(crate) fn run_make(config: &BuildConfig, arg: &Path) -> BuildStatus {

fn run_make_cmd(config: &BuildConfig, cwd: &Path, arg: &Path) -> Result<BuildStatus> {
let make = config.custom_make.as_deref().unwrap_or("make");
let make_args = config.custom_args.as_deref().unwrap_or(&[]);
#[cfg(not(windows))]
let mut command = {
let mut command = Command::new(make);
command.current_dir(cwd).arg(arg);
command.current_dir(cwd).args(make_args).arg(arg);
command
};
#[cfg(windows)]
Expand All @@ -120,9 +123,10 @@ fn run_make_cmd(config: &BuildConfig, cwd: &Path, arg: &Path) -> Result<BuildSta
.arg(distro)
.arg("--")
.arg(make)
.args(make_args)
.arg(arg.to_slash_lossy().as_ref());
} else {
command.current_dir(cwd).arg(arg.to_slash_lossy().as_ref());
command.current_dir(cwd).args(make_args).arg(arg.to_slash_lossy().as_ref());
}
command.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW);
command
Expand Down