Skip to content

Commit

Permalink
Add support for tectonic -X build (#901)
Browse files Browse the repository at this point in the history
Add an option to override build filename
  • Loading branch information
figitaki authored Jul 9, 2023
1 parent 5e657d8 commit b0e7101
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/base-db/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::path::PathBuf;
use std::time::Duration;

use parser::SyntaxConfig;
Expand All @@ -22,6 +23,7 @@ pub struct BuildConfig {
pub on_save: bool,
pub forward_search_after: bool,
pub output_dir: String,
pub output_filename: Option<PathBuf>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -111,6 +113,7 @@ impl Default for BuildConfig {
on_save: false,
forward_search_after: false,
output_dir: String::from("."),
output_filename: None,
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/commands/src/fwd_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ impl ForwardSearch {
return Err(ForwardSearchError::InvalidPath(child.uri.clone()));
};

let Some(pdf_path) = parent.path
.as_deref()
let override_path = workspace.config().build.output_filename.as_deref();

let Some(pdf_path) = override_path.or(parent.path.as_deref())
.and_then(Path::file_stem)
.and_then(OsStr::to_str)
.map(|stem| dir.join(format!("{stem}.pdf"))) else
Expand Down
3 changes: 3 additions & 0 deletions crates/texlab/src/server/options.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::path::PathBuf;
use std::time::Duration;

use base_db::{Config, Formatter, SynctexConfig};
Expand Down Expand Up @@ -68,6 +69,7 @@ pub struct BuildOptions {
pub args: Option<Vec<String>>,
pub on_save: bool,
pub forward_search_after: bool,
pub filename: Option<String>,
}

#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
Expand Down Expand Up @@ -154,6 +156,7 @@ impl From<Options> for Config {
config.build.on_save = value.build.on_save;
config.build.forward_search_after = value.build.forward_search_after;
config.build.output_dir = value.aux_directory.unwrap_or_else(|| String::from("."));
config.build.output_filename = value.build.filename.map(PathBuf::from);

config.diagnostics.allowed_patterns = value
.diagnostics
Expand Down

0 comments on commit b0e7101

Please sign in to comment.