Skip to content

Commit

Permalink
Add workspace-wide default for gen_buildrs (google#167)
Browse files Browse the repository at this point in the history
I want to optimistically default to generating build scripts by default.
  • Loading branch information
illicitonion committed Jun 12, 2020
1 parent 7273ab4 commit d0ed12d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion impl/src/planning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ impl<'planner> CrateSubplanner<'planner> {
&self,
all_targets: &mut Vec<BuildableTarget>,
) -> Option<BuildableTarget> {
if !self.crate_settings.gen_buildrs {
if !self.crate_settings.gen_buildrs.unwrap_or(self.settings.default_gen_buildrs) {
return None;
}

Expand Down
17 changes: 15 additions & 2 deletions impl/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ pub struct RazeSettings {
*/
#[serde(default = "default_raze_settings_field_output_buildfile_suffix")]
pub output_buildfile_suffix: String,

/**
* Default value for per-crate gen_buildrs setting if it's not explicitly for a crate.
*
* See that setting for more information.
*/
#[serde(default = "default_raze_settings_field_gen_buildrs")]
pub default_gen_buildrs: bool,
}

/** Override settings for individual crates (as part of `RazeSettings`). */
Expand Down Expand Up @@ -120,7 +128,7 @@ pub struct CrateSettings {
* scripts that merely generate files into OUT_DIR may be fully functional.
*/
#[serde(default = "default_crate_settings_field_gen_buildrs")]
pub gen_buildrs: bool,
pub gen_buildrs: Option<bool>,

/**
* The verbatim `data` clause to be included for the generated build targets.
Expand Down Expand Up @@ -248,6 +256,7 @@ pub mod testing {
gen_workspace_prefix: "raze_test".to_owned(),
genmode: GenMode::Remote,
output_buildfile_suffix: "BUILD".to_owned(),
default_gen_buildrs: default_raze_settings_field_gen_buildrs(),
}
}
}
Expand All @@ -268,10 +277,14 @@ fn default_raze_settings_field_output_buildfile_suffix() -> String {
"BUILD".to_owned()
}

fn default_crate_settings_field_gen_buildrs() -> bool {
fn default_raze_settings_field_gen_buildrs() -> bool {
false
}

fn default_crate_settings_field_gen_buildrs() -> Option<bool> {
None
}

fn default_crate_settings_field_data_attr() -> Option<String> {
None
}

0 comments on commit d0ed12d

Please sign in to comment.