mirror of
https://github.com/pierrechevalier83/ferris.git
synced 2024-11-28 07:23:44 +03:00
build: make successfull ERC a precondition of output generation
Use the dockerised version of kicad-automation-scripts from dockerhub to reliably check ERC without many constraints on the host machine.
This commit is contained in:
parent
6d2b3e3315
commit
db4b83b05a
56
build.ninja
56
build.ninja
@ -1,5 +1,9 @@
|
||||
# 0.1/base
|
||||
|
||||
rule 0_1_base_erc
|
||||
command = ./run_erc.sh 0.1/base && touch build/0.1/base/erc_success
|
||||
build build/0.1/base/erc_success: 0_1_base_erc
|
||||
|
||||
rule 0_1_base_gerbers
|
||||
command = mkdir -p build/0.1/base && kiplot -b 0.1/base/ferris.kicad_pcb $
|
||||
-c .kiplot.yml -d build/0.1/base
|
||||
@ -7,7 +11,8 @@ build build/0.1/base/ferris-B_Cu.gbr build/0.1/base/ferris-B_Mask.gbr $
|
||||
build/0.1/base/ferris-B_Paste.gbr build/0.1/base/ferris-B_SilkS.gbr $
|
||||
build/0.1/base/ferris-Edge_Cuts.gbr build/0.1/base/ferris-F_Cu.gbr $
|
||||
build/0.1/base/ferris-F_Mask.gbr build/0.1/base/ferris-F_Paste.gbr $
|
||||
build/0.1/base/ferris-F_SilkS.gbr: 0_1_base_gerbers
|
||||
build/0.1/base/ferris-F_SilkS.gbr: 0_1_base_gerbers $
|
||||
build/0.1/base/erc_success
|
||||
|
||||
rule 0_1_base_gerbers_zip
|
||||
command = zip -r build/0_1_base_gerbers.zip $
|
||||
@ -25,6 +30,10 @@ build build/0_1_base_gerbers.zip: 0_1_base_gerbers_zip $
|
||||
|
||||
# 0.1/compact
|
||||
|
||||
rule 0_1_compact_erc
|
||||
command = ./run_erc.sh 0.1/compact && touch build/0.1/compact/erc_success
|
||||
build build/0.1/compact/erc_success: 0_1_compact_erc
|
||||
|
||||
rule 0_1_compact_gerbers
|
||||
command = mkdir -p build/0.1/compact && kiplot -b $
|
||||
0.1/compact/ferris.kicad_pcb -c .kiplot.yml -d build/0.1/compact
|
||||
@ -34,7 +43,8 @@ build build/0.1/compact/ferris-B_Cu.gbr build/0.1/compact/ferris-B_Mask.gbr $
|
||||
build/0.1/compact/ferris-Edge_Cuts.gbr $
|
||||
build/0.1/compact/ferris-F_Cu.gbr build/0.1/compact/ferris-F_Mask.gbr $
|
||||
build/0.1/compact/ferris-F_Paste.gbr $
|
||||
build/0.1/compact/ferris-F_SilkS.gbr: 0_1_compact_gerbers
|
||||
build/0.1/compact/ferris-F_SilkS.gbr: 0_1_compact_gerbers $
|
||||
build/0.1/compact/erc_success
|
||||
|
||||
rule 0_1_compact_gerbers_zip
|
||||
command = zip -r build/0_1_compact_gerbers.zip $
|
||||
@ -55,6 +65,10 @@ build build/0_1_compact_gerbers.zip: 0_1_compact_gerbers_zip $
|
||||
|
||||
# 0.1/high
|
||||
|
||||
rule 0_1_high_erc
|
||||
command = ./run_erc.sh 0.1/high && touch build/0.1/high/erc_success
|
||||
build build/0.1/high/erc_success: 0_1_high_erc
|
||||
|
||||
rule 0_1_high_gerbers
|
||||
command = mkdir -p build/0.1/high && kiplot -b 0.1/high/ferris.kicad_pcb $
|
||||
-c .kiplot.yml -d build/0.1/high
|
||||
@ -62,7 +76,8 @@ build build/0.1/high/ferris-B_Cu.gbr build/0.1/high/ferris-B_Mask.gbr $
|
||||
build/0.1/high/ferris-B_Paste.gbr build/0.1/high/ferris-B_SilkS.gbr $
|
||||
build/0.1/high/ferris-Edge_Cuts.gbr build/0.1/high/ferris-F_Cu.gbr $
|
||||
build/0.1/high/ferris-F_Mask.gbr build/0.1/high/ferris-F_Paste.gbr $
|
||||
build/0.1/high/ferris-F_SilkS.gbr: 0_1_high_gerbers
|
||||
build/0.1/high/ferris-F_SilkS.gbr: 0_1_high_gerbers $
|
||||
build/0.1/high/erc_success
|
||||
|
||||
rule 0_1_high_gerbers_zip
|
||||
command = zip -r build/0_1_high_gerbers.zip $
|
||||
@ -80,6 +95,10 @@ build build/0_1_high_gerbers.zip: 0_1_high_gerbers_zip $
|
||||
|
||||
# 0.1/low
|
||||
|
||||
rule 0_1_low_erc
|
||||
command = ./run_erc.sh 0.1/low && touch build/0.1/low/erc_success
|
||||
build build/0.1/low/erc_success: 0_1_low_erc
|
||||
|
||||
rule 0_1_low_gerbers
|
||||
command = mkdir -p build/0.1/low && kiplot -b 0.1/low/ferris.kicad_pcb -c $
|
||||
.kiplot.yml -d build/0.1/low
|
||||
@ -87,7 +106,8 @@ build build/0.1/low/ferris-B_Cu.gbr build/0.1/low/ferris-B_Mask.gbr $
|
||||
build/0.1/low/ferris-B_Paste.gbr build/0.1/low/ferris-B_SilkS.gbr $
|
||||
build/0.1/low/ferris-Edge_Cuts.gbr build/0.1/low/ferris-F_Cu.gbr $
|
||||
build/0.1/low/ferris-F_Mask.gbr build/0.1/low/ferris-F_Paste.gbr $
|
||||
build/0.1/low/ferris-F_SilkS.gbr: 0_1_low_gerbers
|
||||
build/0.1/low/ferris-F_SilkS.gbr: 0_1_low_gerbers $
|
||||
build/0.1/low/erc_success
|
||||
|
||||
rule 0_1_low_gerbers_zip
|
||||
command = zip -r build/0_1_low_gerbers.zip build/0.1/low/ferris-B_Cu.gbr $
|
||||
@ -104,6 +124,10 @@ build build/0_1_low_gerbers.zip: 0_1_low_gerbers_zip $
|
||||
|
||||
# 0.2/bling
|
||||
|
||||
rule 0_2_bling_erc
|
||||
command = ./run_erc.sh 0.2/bling && touch build/0.2/bling/erc_success
|
||||
build build/0.2/bling/erc_success: 0_2_bling_erc
|
||||
|
||||
rule 0_2_bling_gerbers
|
||||
command = mkdir -p build/0.2/bling && kiplot -b $
|
||||
0.2/bling/ferris.kicad_pcb -c .kiplot.yml -d build/0.2/bling
|
||||
@ -111,7 +135,8 @@ build build/0.2/bling/ferris-B_Cu.gbr build/0.2/bling/ferris-B_Mask.gbr $
|
||||
build/0.2/bling/ferris-B_Paste.gbr build/0.2/bling/ferris-B_SilkS.gbr $
|
||||
build/0.2/bling/ferris-Edge_Cuts.gbr build/0.2/bling/ferris-F_Cu.gbr $
|
||||
build/0.2/bling/ferris-F_Mask.gbr build/0.2/bling/ferris-F_Paste.gbr $
|
||||
build/0.2/bling/ferris-F_SilkS.gbr: 0_2_bling_gerbers
|
||||
build/0.2/bling/ferris-F_SilkS.gbr: 0_2_bling_gerbers $
|
||||
build/0.2/bling/erc_success
|
||||
|
||||
rule 0_2_bling_gerbers_zip
|
||||
command = zip -r build/0_2_bling_gerbers.zip $
|
||||
@ -129,6 +154,10 @@ build build/0_2_bling_gerbers.zip: 0_2_bling_gerbers_zip $
|
||||
|
||||
# 0.2/compact
|
||||
|
||||
rule 0_2_compact_erc
|
||||
command = ./run_erc.sh 0.2/compact && touch build/0.2/compact/erc_success
|
||||
build build/0.2/compact/erc_success: 0_2_compact_erc
|
||||
|
||||
rule 0_2_compact_gerbers
|
||||
command = mkdir -p build/0.2/compact && kiplot -b $
|
||||
0.2/compact/ferris.kicad_pcb -c .kiplot.yml -d build/0.2/compact
|
||||
@ -138,7 +167,8 @@ build build/0.2/compact/ferris-B_Cu.gbr build/0.2/compact/ferris-B_Mask.gbr $
|
||||
build/0.2/compact/ferris-Edge_Cuts.gbr $
|
||||
build/0.2/compact/ferris-F_Cu.gbr build/0.2/compact/ferris-F_Mask.gbr $
|
||||
build/0.2/compact/ferris-F_Paste.gbr $
|
||||
build/0.2/compact/ferris-F_SilkS.gbr: 0_2_compact_gerbers
|
||||
build/0.2/compact/ferris-F_SilkS.gbr: 0_2_compact_gerbers $
|
||||
build/0.2/compact/erc_success
|
||||
|
||||
rule 0_2_compact_gerbers_zip
|
||||
command = zip -r build/0_2_compact_gerbers.zip $
|
||||
@ -159,6 +189,10 @@ build build/0_2_compact_gerbers.zip: 0_2_compact_gerbers_zip $
|
||||
|
||||
# 0.2/high
|
||||
|
||||
rule 0_2_high_erc
|
||||
command = ./run_erc.sh 0.2/high && touch build/0.2/high/erc_success
|
||||
build build/0.2/high/erc_success: 0_2_high_erc
|
||||
|
||||
rule 0_2_high_gerbers
|
||||
command = mkdir -p build/0.2/high && kiplot -b 0.2/high/ferris.kicad_pcb $
|
||||
-c .kiplot.yml -d build/0.2/high
|
||||
@ -166,7 +200,8 @@ build build/0.2/high/ferris-B_Cu.gbr build/0.2/high/ferris-B_Mask.gbr $
|
||||
build/0.2/high/ferris-B_Paste.gbr build/0.2/high/ferris-B_SilkS.gbr $
|
||||
build/0.2/high/ferris-Edge_Cuts.gbr build/0.2/high/ferris-F_Cu.gbr $
|
||||
build/0.2/high/ferris-F_Mask.gbr build/0.2/high/ferris-F_Paste.gbr $
|
||||
build/0.2/high/ferris-F_SilkS.gbr: 0_2_high_gerbers
|
||||
build/0.2/high/ferris-F_SilkS.gbr: 0_2_high_gerbers $
|
||||
build/0.2/high/erc_success
|
||||
|
||||
rule 0_2_high_gerbers_zip
|
||||
command = zip -r build/0_2_high_gerbers.zip $
|
||||
@ -184,6 +219,10 @@ build build/0_2_high_gerbers.zip: 0_2_high_gerbers_zip $
|
||||
|
||||
# 0.2/mini
|
||||
|
||||
rule 0_2_mini_erc
|
||||
command = ./run_erc.sh 0.2/mini && touch build/0.2/mini/erc_success
|
||||
build build/0.2/mini/erc_success: 0_2_mini_erc
|
||||
|
||||
rule 0_2_mini_gerbers
|
||||
command = mkdir -p build/0.2/mini && kiplot -b 0.2/mini/ferris.kicad_pcb $
|
||||
-c .kiplot.yml -d build/0.2/mini
|
||||
@ -191,7 +230,8 @@ build build/0.2/mini/ferris-B_Cu.gbr build/0.2/mini/ferris-B_Mask.gbr $
|
||||
build/0.2/mini/ferris-B_Paste.gbr build/0.2/mini/ferris-B_SilkS.gbr $
|
||||
build/0.2/mini/ferris-Edge_Cuts.gbr build/0.2/mini/ferris-F_Cu.gbr $
|
||||
build/0.2/mini/ferris-F_Mask.gbr build/0.2/mini/ferris-F_Paste.gbr $
|
||||
build/0.2/mini/ferris-F_SilkS.gbr: 0_2_mini_gerbers
|
||||
build/0.2/mini/ferris-F_SilkS.gbr: 0_2_mini_gerbers $
|
||||
build/0.2/mini/erc_success
|
||||
|
||||
rule 0_2_mini_gerbers_zip
|
||||
command = zip -r build/0_2_mini_gerbers.zip $
|
||||
|
35
configure.py
35
configure.py
@ -24,6 +24,30 @@ def underscorify(variant):
|
||||
return variant.replace("/", "_").replace(".", "_")
|
||||
|
||||
|
||||
def make_erc_rule_name(variant):
|
||||
return underscorify(variant) + "_erc"
|
||||
|
||||
|
||||
def make_variant_out_dir(variant):
|
||||
return f"{OUTPUT_DIR}/{variant}"
|
||||
|
||||
|
||||
def make_erc_success_stub_file(variant):
|
||||
return f"{make_variant_out_dir(variant)}/erc_success"
|
||||
|
||||
|
||||
def add_erc_rule(ninja, variant):
|
||||
erc_rule = make_erc_rule_name(variant)
|
||||
erc_file = make_erc_success_stub_file(variant)
|
||||
# On success, we create a file which informs the next rule that it's ok to proceed. We don't want to generate gerber files if ERC fails.
|
||||
ninja.rule(
|
||||
name=erc_rule,
|
||||
command=[f"./run_erc.sh {variant} && touch {erc_file}"],
|
||||
)
|
||||
ninja.build(outputs=[erc_file], rule=erc_rule)
|
||||
ninja.newline()
|
||||
|
||||
|
||||
def make_gerber_rule_name(variant):
|
||||
return underscorify(variant) + "_gerbers"
|
||||
|
||||
@ -32,10 +56,6 @@ def make_board_path(variant):
|
||||
return variant + "/ferris.kicad_pcb"
|
||||
|
||||
|
||||
def make_variant_out_dir(variant):
|
||||
return f"{OUTPUT_DIR}/{variant}"
|
||||
|
||||
|
||||
def make_gerber_output_paths(variant):
|
||||
gerbers_out = [
|
||||
"ferris-B_Cu.gbr",
|
||||
@ -60,7 +80,11 @@ def add_gerber_rule(ninja, variant):
|
||||
name=gerber_rule,
|
||||
command=[f"mkdir -p {out_dir} && kiplot -b {board} -c {config} -d {out_dir}"],
|
||||
)
|
||||
ninja.build(outputs=make_gerber_output_paths(variant), rule=gerber_rule)
|
||||
ninja.build(
|
||||
inputs=[make_erc_success_stub_file(variant)],
|
||||
outputs=make_gerber_output_paths(variant),
|
||||
rule=gerber_rule,
|
||||
)
|
||||
ninja.newline()
|
||||
|
||||
|
||||
@ -87,6 +111,7 @@ def generate_buildfile_content():
|
||||
variants = VARIANTS
|
||||
for variant in variants:
|
||||
add_comment_header(ninja, variant)
|
||||
add_erc_rule(ninja, variant)
|
||||
add_gerber_rule(ninja, variant)
|
||||
add_zip_gerber_rule(ninja, variant)
|
||||
return ninja
|
||||
|
17
run_erc.sh
Executable file
17
run_erc.sh
Executable file
@ -0,0 +1,17 @@
|
||||
ERC_OUTPUT=$(docker run --rm -t -v "$(pwd)"/$1:/kicad-project productize/kicad-automation-scripts python -m kicad-automation.eeschema.schematic run_erc /kicad-project/ferris.sch "$(pwd)"/build | grep "DEBUG:root:Last line" | sed "s/DEBUG:root:Last line: //")
|
||||
|
||||
if [[ -z "$ERC_OUTPUT" ]]; then
|
||||
echo -e "\e[1;32mERROR\e[0m"
|
||||
echo "Missing ERC report line. Something went wrong"
|
||||
exit 2
|
||||
else
|
||||
if [[ "$ERC_OUTPUT" = *"ERC messages: 0 Errors 0 Warnings 0"* ]]; then
|
||||
echo -e "\e[1;32mPASS\e[0m"
|
||||
echo "$ERC_OUTPUT"
|
||||
exit 0
|
||||
else
|
||||
echo -e "\e[1;32mFAIL\e[0m"
|
||||
echo "$ERC_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user