Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions bazel/rules/rules_score/private/architectural_design.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ def _run_puml_parser(ctx, puml_file):
lobster_output = ctx.actions.declare_file(
"{}/{}.lobster".format(ctx.label.name, file_stem),
)
json_output = ctx.actions.declare_file(
"{}/{}.logic.ast.json".format(ctx.label.name, file_stem),
)

ctx.actions.run(
inputs = [puml_file],
outputs = [fbs_output, lobster_output],
outputs = [fbs_output, lobster_output, json_output],
executable = ctx.executable._puml_parser,
arguments = [
"--file",
Expand All @@ -65,12 +68,14 @@ def _run_puml_parser(ctx, puml_file):
"--lobster-output-dir",
lobster_output.dirname,
"--log-level",
get_log_level(ctx),
# gToDo: log level needs to be debug for ast.json to be generated
"debug",
# get_log_level(ctx),
],
progress_message = "Parsing PlantUML diagram: %s" % puml_file.short_path,
)

return fbs_output, lobster_output
return fbs_output, lobster_output, json_output

def _parse_puml_diagrams(ctx, files):
"""Run the PlantUML parser on all .puml/.plantuml files in a list.
Expand Down Expand Up @@ -226,6 +231,38 @@ _architectural_design = rule(
**VERBOSITY_ATTR
),
)
def _parse_puml_diagrams_impl(ctx):
print(ctx.attr.files)
print(ctx.files.files[0])
# gToDo: shaky mit [0]
fbs_output, lobster_output, json_output = _run_puml_parser(ctx, ctx.files.files[0])
return [
DefaultInfo(
files = depset([fbs_output, lobster_output, json_output]),
),
]

parse_puml_diagrams = rule(
implementation = _parse_puml_diagrams_impl,
doc = "Helper rule to run the PlantUML parser on a list of .puml files and produce FlatBuffers binaries and lobster files.",
attrs = {
"files": attr.label(
mandatory = True,
doc = "List of .puml/.plantuml files to parse",
allow_single_file = True,
),
"_puml_parser": attr.label(
default = Label("@score_tooling//plantuml/parser:parser"),
executable = True,
cfg = "exec",
doc = "PlantUML parser tool that generates FlatBuffers from .puml files",
),
"_verbosity": attr.label(
default = Label("//bazel/rules/rules_score:verbosity"),
doc = "Verbosity level build setting (warn/info/debug).",
),
},
)

# ============================================================================
# Public Macro
Expand Down
2 changes: 2 additions & 0 deletions bazel/rules/rules_score/rules_score.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ load(
load(
"//bazel/rules/rules_score/private:architectural_design.bzl",
_architectural_design = "architectural_design",
_parse_puml_diagrams = "parse_puml_diagrams",
)
load(
"//bazel/rules/rules_score/private:assumed_system_requirements.bzl",
Expand Down Expand Up @@ -71,6 +72,7 @@ load(
)

architectural_design = _architectural_design
parse_puml_diagrams = _parse_puml_diagrams
assumptions_of_use = _assumptions_of_use
assumed_system_requirements = _assumed_system_requirements
component_requirements = _component_requirements
Expand Down
Loading