Support commenting out overlays

This commit is contained in:
Björn Gaier 2023-11-04 19:43:59 -04:00
parent f5e9ba0279
commit 5b05f1e51a
4 changed files with 25 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{
"slot_0": {
"timer_tests": {
"pattern": "bin/*/src/Overlay/TimerTests2/*.o"
"!timer_tests": {
"pattern": "bin/*/src/Overlay/TimerTests/*.o"
},
"gpu_tests": {
"pattern": "bin/*/src/Overlay/GPUTests/*.o"

View File

@ -1,6 +1,6 @@
[package]
name = "mkoverlay"
version = "1.5.1"
version = "1.6.0"
edition = "2021"
[profile.release]

View File

@ -7,7 +7,10 @@ pub fn read_config(input: Input) -> Result<OverlayDesc, Error> {
if let Some(objects) = json_reader.as_object() {
for object in objects {
overlay_desc.push(read_as_slot(object)?);
let slot = read_as_slot(object)?;
if !slot.is_commented_out() && slot.has_sections() {
overlay_desc.push(slot);
}
}
Ok(overlay_desc)
@ -24,7 +27,10 @@ fn read_as_slot(json_value: (&String, &serde_json::Value)) -> Result<OverlaySlot
if let Some(json_value) = json_value.as_object() {
for (name, json_value) in json_value {
slot.add_section(read_as_section(name.clone(), json_value)?);
let section = read_as_section(name.clone(), json_value)?;
if !section.is_commented_out() {
slot.add_section(section);
}
}
}

View File

@ -2,6 +2,8 @@ pub mod json_reader;
pub type OverlayDesc = Vec<OverlaySlot>;
const COMMENT_PREFIX:char = '!';
pub struct OverlaySlot {
pub(super) name: String,
pub(super) sections: Vec<OverlaySection>
@ -15,6 +17,14 @@ impl OverlaySlot {
pub fn add_section(&mut self, section: OverlaySection) {
self.sections.push(section);
}
pub fn is_commented_out(&self) -> bool {
self.name.starts_with(COMMENT_PREFIX)
}
pub fn has_sections(&self) -> bool {
!self.sections.is_empty()
}
}
pub struct OverlaySection {
@ -30,4 +40,8 @@ impl OverlaySection {
pub fn add_file_pattern(&mut self, file_pattern: String) {
self.file_pattern.push(file_pattern);
}
pub fn is_commented_out(&self) -> bool {
self.name.starts_with(COMMENT_PREFIX)
}
}