build: Add bom and position files to pcb export Change-Id: Iddf5524a5e4ebfce280c1d1a5c525365c369cdae Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/hardware/testing/+/258993 Pigweed-Auto-Submit: Erik Gilling <konkers@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com> Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com> Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
diff --git a/build/kicad.bzl b/build/kicad.bzl index 8e68657..74d2e94 100644 --- a/build/kicad.bzl +++ b/build/kicad.bzl
@@ -44,7 +44,7 @@ pcb_layers: A list of layers to be exported. pcb_design_rules: A .kicad_dru file. """ - kicad_schematic_pdf( + kicad_schematic_export( name = name + "_sch", root = schematic_root, srcs = schematic_srcs, @@ -106,7 +106,7 @@ out = name + ".exe", ) -def _kicad_schematic_pdf_impl(ctx): +def _kicad_schematic_export_impl(ctx): pdf_file = ctx.actions.declare_file(ctx.label.name + ".pdf") args = ["sch", "export", "pdf", "--output", pdf_file.path, ctx.file.root.path] @@ -120,12 +120,30 @@ executable = ctx.executable._kicad_cli, ) - return [ - DefaultInfo(files = depset([pdf_file])), + bom_output_file = ctx.actions.declare_file(ctx.label.name + "-bom.csv") + bom_args = [ + "sch", + "export", + "bom", + "--output", + bom_output_file.path, + ctx.file.root.path, ] -kicad_schematic_pdf = rule( - implementation = _kicad_schematic_pdf_impl, + ctx.actions.run( + inputs = ctx.files.srcs + [ctx.file.root], + outputs = [bom_output_file], + arguments = bom_args, + use_default_shell_env = True, + progress_message = "running SCH EXPORT BOM on %s" % ctx.attr.name, + executable = ctx.executable._kicad_cli, + ) + return [ + DefaultInfo(files = depset([pdf_file, bom_output_file])), + ] + +kicad_schematic_export = rule( + implementation = _kicad_schematic_export_impl, attrs = { "srcs": attr.label_list(allow_files = [".kicad_sch"]), "root": attr.label( @@ -273,8 +291,29 @@ executable = ctx.executable._kicad_cli, ) + pos_output_file = ctx.actions.declare_file(pcb_file_basename + "-pos.csv") + pos_args = [ + "pcb", + "export", + "pos", + "--format", + "csv", + "--output", + pos_output_file.path, + ctx.file.pcb.path, + ] + + ctx.actions.run( + inputs = ctx.files.data + [ctx.file.pcb], + outputs = [pos_output_file], + arguments = pos_args, + use_default_shell_env = True, + progress_message = "running PCB EXPORT POS on %s" % ctx.attr.name, + executable = ctx.executable._kicad_cli, + ) + return [ - DefaultInfo(files = depset(gerber_outputs + drill_outputs)), + DefaultInfo(files = depset(gerber_outputs + drill_outputs + [pos_output_file])), ] kicad_pcb_export = rule(