Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit e0dc87c

Browse files
committed
add genrule for avrdude upload script
1 parent 85edfc0 commit e0dc87c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

AvrToolchain/BUILD.tpl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
UPLOAD_SCRIPT_TEMPLATE = """
3+
DFU_UPLOAD_SCRIPT_TEMPLATE = """
44
{export}
55
{sudo}dfu-programmer $$1 erase;
66
{sudo}dfu-programmer $$1 flash $$2;
77
{sudo}dfu-programmer $$1 reset;
88
"""
99

10+
AVRDUDE_UPLOAD_SCRIPT_TEMPLATE = """
11+
avrdude -c wiring -p \$$1 -P /dev/ttyACM0 -D -V -U flash:w:\$$2" > $@
12+
"""
13+
1014
genrule(
1115
name = "dfu_upload_script",
1216
outs = ["dfu_upload_script.sh"],
1317
cmd = "echo '" + select({
14-
"@AvrToolchain//host_config:dfu_needs_sudo": UPLOAD_SCRIPT_TEMPLATE.format(
18+
"@AvrToolchain//host_config:dfu_needs_sudo": DFU_UPLOAD_SCRIPT_TEMPLATE.format(
1519
export = "",
1620
sudo = "sudo ",
1721
),
18-
"@AvrToolchain//host_config:dfu_needs_ask_pass": UPLOAD_SCRIPT_TEMPLATE.format(
22+
"@AvrToolchain//host_config:dfu_needs_ask_pass": DFU_UPLOAD_SCRIPT_TEMPLATE.format(
1923
export = "export SUDO_ASKPASS=$(ASKPASS)",
2024
sudo = "sudo ",
2125
),
22-
"//conditions:default": UPLOAD_SCRIPT_TEMPLATE.format(
26+
"//conditions:default": DFU_UPLOAD_SCRIPT_TEMPLATE.format(
2327
export = "",
2428
sudo = "",
2529
),
2630
}) + "' > $@",
31+
)
32+
33+
genrule(
34+
name = "avrdude_upload_script",
35+
outs = ["avrdude_upload_script.sh"],
36+
cmd = " echo '" + select({
37+
"//conditions:default": AVRDUDE_UPLOAD_SCRIPT_TEMPLATE.format(
38+
39+
)
40+
}) + "' > $@",
2741
)

0 commit comments

Comments
 (0)