feat(cli): add a flag to compile a parser in debug mode with -O0 C/C++ compiler flag
This commit is contained in:
parent
5c2ebf093b
commit
62d79b80e1
2 changed files with 39 additions and 8 deletions
|
|
@ -101,6 +101,7 @@ pub struct Loader {
|
|||
language_configuration_ids_by_file_type: HashMap<String, Vec<usize>>,
|
||||
highlight_names: Box<Mutex<Vec<String>>>,
|
||||
use_all_highlight_names: bool,
|
||||
debug_build: bool,
|
||||
}
|
||||
|
||||
unsafe impl Send for Loader {}
|
||||
|
|
@ -122,6 +123,7 @@ impl Loader {
|
|||
language_configuration_ids_by_file_type: HashMap::new(),
|
||||
highlight_names: Box::new(Mutex::new(Vec::new())),
|
||||
use_all_highlight_names: true,
|
||||
debug_build: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +349,11 @@ impl Loader {
|
|||
parser_path: &Path,
|
||||
scanner_path: &Option<PathBuf>,
|
||||
) -> Result<Language> {
|
||||
let mut library_path = self.parser_lib_path.join(name);
|
||||
let mut lib_name = name.to_string();
|
||||
if self.debug_build {
|
||||
lib_name.push_str(".debug._");
|
||||
}
|
||||
let mut library_path = self.parser_lib_path.join(lib_name);
|
||||
library_path.set_extension(DYLIB_EXTENSION);
|
||||
|
||||
let recompile = needs_recompile(&library_path, &parser_path, &scanner_path)
|
||||
|
|
@ -369,11 +375,13 @@ impl Loader {
|
|||
}
|
||||
|
||||
if cfg!(windows) {
|
||||
command
|
||||
.args(&["/nologo", "/LD", "/I"])
|
||||
.arg(header_path)
|
||||
.arg("/Od")
|
||||
.arg(parser_path);
|
||||
command.args(&["/nologo", "/LD", "/I"]).arg(header_path);
|
||||
if self.debug_build {
|
||||
command.arg("/Od");
|
||||
} else {
|
||||
command.arg("/O2");
|
||||
}
|
||||
command.arg(parser_path);
|
||||
if let Some(scanner_path) = scanner_path.as_ref() {
|
||||
command.arg(scanner_path);
|
||||
}
|
||||
|
|
@ -389,8 +397,13 @@ impl Loader {
|
|||
.arg("-I")
|
||||
.arg(header_path)
|
||||
.arg("-o")
|
||||
.arg(&library_path)
|
||||
.arg("-O2");
|
||||
.arg(&library_path);
|
||||
|
||||
if self.debug_build {
|
||||
command.arg("-O0");
|
||||
} else {
|
||||
command.arg("-O2");
|
||||
}
|
||||
|
||||
// For conditional compilation of external scanner code when
|
||||
// used internally by `tree-siteer parse` and other sub commands.
|
||||
|
|
@ -644,6 +657,10 @@ impl Loader {
|
|||
Err(anyhow!("No language found"))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn use_debug_build(&mut self, flag: bool) {
|
||||
self.debug_build = flag;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LanguageConfiguration<'a> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue