mirror of
https://github.com/binary-kitchen/doorlockd
synced 2025-01-04 23:45:23 +01:00
pydoorlock: autogenerate Protocol.py
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
becb21bbbc
commit
e27f6d02da
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,4 +8,5 @@ arch/*.xz
|
|||||||
arch/BKCA.crt
|
arch/BKCA.crt
|
||||||
gpio-wait
|
gpio-wait
|
||||||
|
|
||||||
|
pydoorlock/Protocol.py
|
||||||
pydoorlock/__pycache__/
|
pydoorlock/__pycache__/
|
||||||
|
6
Makefile
6
Makefile
@ -2,13 +2,16 @@ DESTDIR ?= /
|
|||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
SYSCONFDIR ?= /etc
|
SYSCONFDIR ?= /etc
|
||||||
|
|
||||||
all: gpio-wait
|
all: gpio-wait pydoorlock/Protocol.py
|
||||||
|
|
||||||
package:
|
package:
|
||||||
sed -i -r -e "s@(^SYSCONFDIR = ').*('$$)@\1$(SYSCONFDIR)\2@" doorlockd
|
sed -i -r -e "s@(^SYSCONFDIR = ').*('$$)@\1$(SYSCONFDIR)\2@" doorlockd
|
||||||
sed -i -r -e "s@(^PREFIX = ').*('$$)@\1$(PREFIX)\2@" doorlockd
|
sed -i -r -e "s@(^PREFIX = ').*('$$)@\1$(PREFIX)\2@" doorlockd
|
||||||
sed -i -r -e "s@(^__version__ = ').*('$$)@\1$(shell cat VERSION)\2@" doorlockd
|
sed -i -r -e "s@(^__version__ = ').*('$$)@\1$(shell cat VERSION)\2@" doorlockd
|
||||||
|
|
||||||
|
pydoorlock/Protocol.py: avr-code/protocol.h
|
||||||
|
./scripts/gen_protocol.sh $^ > $@
|
||||||
|
|
||||||
gpio-wait: gpio-wait.c
|
gpio-wait: gpio-wait.c
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@ -29,3 +32,4 @@ install:
|
|||||||
clean:
|
clean:
|
||||||
rm -f gpio-wait
|
rm -f gpio-wait
|
||||||
rm -rf pydoorlock/__pycache__
|
rm -rf pydoorlock/__pycache__
|
||||||
|
rm -f pydoorlock/Protocol.py
|
||||||
|
35
scripts/gen_protocol.sh
Executable file
35
scripts/gen_protocol.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# doorlock-avr, AVR code of Binary Kitchen's doorlock
|
||||||
|
#
|
||||||
|
# Copyright (c) Binary Kitchen, 2019
|
||||||
|
#
|
||||||
|
# Authors:
|
||||||
|
# Ralf Ramsauer <ralf@binary-kitchen.de>
|
||||||
|
#
|
||||||
|
# This work is licensed under the terms of the GNU GPL, version 2. See
|
||||||
|
# the COPYING file in the top-level directory.
|
||||||
|
|
||||||
|
PROTOCOL_H=$1
|
||||||
|
|
||||||
|
function find_defines() {
|
||||||
|
header=$1
|
||||||
|
prefix=$2
|
||||||
|
search="#define\s\+${prefix}\(\S*\)\s\+\(\S*\).*"
|
||||||
|
replace=" \1\t= b\2"
|
||||||
|
|
||||||
|
grep $prefix $header | sed -e "s/$search/$replace/"
|
||||||
|
}
|
||||||
|
|
||||||
|
AVR_COMM=$(find_defines $PROTOCOL_H AVR_)
|
||||||
|
|
||||||
|
cat <<END
|
||||||
|
# This file is autogenerated. If you need to change it, edit
|
||||||
|
# scripts/gen_protocol.sh instead.
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class Protocol(Enum):
|
||||||
|
${AVR_COMM}
|
||||||
|
END
|
Loading…
Reference in New Issue
Block a user