DragonBuild / dragon

pip install dragon | A Powerful buildsystem and toolkit currently targeting darwin (iOS/macOS) machines
MIT License
220 stars 23 forks source link

Rework DragonGen.py #15

Closed LorenzoPane closed 4 years ago

LorenzoPane commented 4 years ago

Flow

The generation process now more closely mirrors the build.ninja output itself. The process looks like this:

  1. Variables are generated in

    def generate_vars(var_d: dict, config: dict, target: str) -> ProjectVars:

    The returned object is pretty much exactly what will be exported as variables in the build.ninja file.

  2. The variables are plugged into an unevaluated outline: a list of objects each representing a Ninja statement

    def generate_ninja_outline(variables: ProjectVars) -> list:

    and extended with the rule and build portions of the outline from

    def build_statements_and_rules(variables: ProjectVars) -> (list, list):
  3. The outline is evaluated in with the variables and written to a buildgen generator (which can be easily swapped out) in

    def generate_ninja_file(outline: list, variables: ProjectVars, stream: TextIO):

    Added classes

    To minimize string manipulation most data is stored as ArgList, BoolFlag, or str objects which are properly converted to strings during evaluation.

Conclusion

I hope this will help with maintainability. Since pretty much everything is iterative, most support additions should just involve dictionary modification.