Skip to content
Snippets Groups Projects
Unverified Commit 889541f7 authored by Jean-Benoist Leger's avatar Jean-Benoist Leger
Browse files

ID logic

parent 7eb329f0
No related branches found
No related tags found
No related merge requests found
......@@ -5,3 +5,5 @@ __pycache__/
*.hex
*.elf
commitid.h
id.h
ID
......@@ -16,19 +16,22 @@ COMPILE = avr-gcc -Wall -Os -mmcu=$(DEVICE)
.PHONY: clean all
.INTERMEDIATE: commitid.h main.o
.INTERMEDIATE: commitid.h id.h message.o main.o
# symbolic targets:
all: main.hex
clean:
rm -f *.o *.elf *.hex commitid.h
rm -f *.o *.elf *.hex commitid.h id.h
commitid.h: .git/refs/heads
cog -r *.c *.h
./define_commit_id.py > $@
%.o: %.c common.h commitid.h
id.h: ID
./define_id.py > $@
%.o: %.c common.h commitid.h id.h
$(COMPILE) -c $< -o $@
.S.o:
......
#!/usr/bin/python3
import re
with open("ID") as f:
content = f.read().strip()
a = re.match("^0x([0-9a-fA-F]{2})$", content)
if not a:
raise SyntaxError
(hbid,) = a.groups()
bid = int(hbid, 16)
hbid = f"{bid:02x}"
print(f"#define BID 0x{hbid}")
print(f"#define BID_C0 '{hbid[0]}'")
print(f"#define BID_C1 '{hbid[1]}'")
/*[[[cog
bid = 0x01
hbid = f"{bid:02x}"
cog.out(f"#define BID 0x{hbid}\n")
cog.out(f"#define BID_C0 '{hbid[0]}'\n")
cog.out(f"#define BID_C1 '{hbid[1]}'\n")
]]]*/
#define BID 0x01
#define BID_C0 '0'
#define BID_C1 '1'
///[[[end]]]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment