mirror of
https://github.com/Luzifer/tasmota-build.git
synced 2024-11-09 18:00:07 +00:00
Remove config patcher
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
c666d70476
commit
c181607592
3 changed files with 1 additions and 56 deletions
12
Makefile
12
Makefile
|
@ -7,7 +7,7 @@ chown:
|
|||
|
||||
ci: full-clean default
|
||||
|
||||
build_%: download venv
|
||||
build_%: download
|
||||
$(MAKE) update_user-config_$*
|
||||
cd tasmota && ../venv/bin/platformio run -e $*
|
||||
mkdir -p build
|
||||
|
@ -22,13 +22,3 @@ download:
|
|||
|
||||
full-clean: clean
|
||||
rm -rf build
|
||||
|
||||
update_user-config_%: venv
|
||||
./venv/bin/python update.py config_$*.yml
|
||||
cd tasmota && git --no-pager diff -w sonoff/user_config.h
|
||||
|
||||
venv:
|
||||
virtualenv -p python2 venv
|
||||
./venv/bin/pip install -r requirements.txt
|
||||
|
||||
.PHONY: venv
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
PyYAML
|
||||
platformio
|
43
update.py
43
update.py
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def fmt_line(prefix, param, content, comment):
|
||||
return '{: <47} // {}'.format('{}#define {: <22} {}'.format(prefix, param, content), comment)
|
||||
|
||||
|
||||
def get_line(param, content, comment):
|
||||
if content == '!undef':
|
||||
return fmt_line('//', param, '', comment)
|
||||
if content == '!def':
|
||||
return fmt_line('', param, '', comment)
|
||||
|
||||
if content[:2] == '${':
|
||||
envvar = content.strip('${}')
|
||||
if envvar in os.environ:
|
||||
content = os.environ[envvar]
|
||||
|
||||
return fmt_line('', param, content, comment)
|
||||
|
||||
|
||||
def main():
|
||||
cfg = yaml.load(open(sys.argv[1]))
|
||||
config = open('tasmota/sonoff/user_config.h').read().split('\n')
|
||||
|
||||
for (i, line) in enumerate(config):
|
||||
for param, content in cfg.items():
|
||||
if '#define {} '.format(param) in line:
|
||||
comment = line.lstrip('/').split(' //', 1)[1].strip()
|
||||
config[i] = get_line(param, content, comment)
|
||||
|
||||
with open('tasmota/sonoff/user_config.h', 'w') as fh:
|
||||
fh.write('\n'.join(config))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue