build icon indicating copy to clipboard operation
build copied to clipboard

Add configuration set aliases

Open natebosch opened this issue 7 years ago • 3 comments

Allow builder to define a simple alias which represents multiple options. This would be an enhancement over release/dev option defaults.

Use case: To truly debug in prod mode we would need to set options on multiple builders. The Dart source cleanup would need to stop filtering out Dart files, and the dart2js archive extractor would need to stop filtering out the source map. Our instructions today recommend running without --release and enabling dart2js becaus it's a smaller amount to --define, but it also means you're not getting release mode options for any other builder. We could allow both of these builders to agree on what the option alias debug or keep_source_maps should mean and provide the right configuration for that intention.

Configuration would look something like:

builders:
  some_builder_name:
    ...
    defaults:
      release_options:
        compiler: dart2js
        dart2js_use_source_maps: false
    option_aliases:
      debug:
        help: "Keep source maps"
        options:
          dart2js_use_source_maps: true

Usage looks like:

pub run build_runner build --release --define debug

Behind the scenes we'd merge in the options in the following order:

  1. Existing options as we're using them today:
    • builder defaults
    • builder defaults by mode
    • user options
    • user options by mode
  2. Global options from build.yaml
  3. Option aliases
  4. "legacy" style --define options

natebosch avatar Jun 08 '18 17:06 natebosch

Should we also enable using these aliases when statically configuring a builder somehow?

jakemac53 avatar Jun 08 '18 19:06 jakemac53

Should we also enable using these aliases when statically configuring a builder somehow?

I don't see why not as long as we can make a decision about syntax and merge order.

targets:
  $default:
    builders:
      some_package:
        option_sets:
          - debug
        options:
          foo: bar
        release_options:
          foo: baz
  1. builder defaults
  2. builder defaults by mode
  3. Option sets from build.yaml
  4. user options
  5. user options by mode
  6. Global option sets.
  7. Global options from build.yaml
  8. Option aliases from command line
  9. "legacy" style --define options

natebosch avatar Jun 08 '18 19:06 natebosch

What if you want to only apply an option set in a specific mode though? Do we support debug_option_sets etc? lol

jakemac53 avatar Jun 08 '18 19:06 jakemac53

Closing as stale.

davidmorgan avatar Jul 07 '25 11:07 davidmorgan