diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-11 20:12:18 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-11 20:12:18 (GMT) |
| commit | 50ecff29efb5afd4796ea192982bba10266947fe (patch) | |
| tree | c5374fe9ac9797658867b7627ca3ca971de64247 /tools | |
| parent | 7ef145cdc5f575ae253b6bd0176375feee61bf86 (diff) | |
wasp: Automatically generate watch.py for PineTime
This should ensure that main.py is always up to date.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/preprocess.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/preprocess.py b/tools/preprocess.py new file mode 100755 index 0000000..4c43c2a --- /dev/null +++ b/tools/preprocess.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +# SPDX-License-Identifier: LGPL-3.0-or-later +# Copyright (C) 2020 Daniel Thompson +"""Quick and dirty macro processor. + +Currently the only support macro is #include! +""" + +import sys + +def preprocess(fname): + with open(fname) as f: + for ln in f.readlines(): + ln = ln.rstrip() + + macro = ln.lstrip() + if macro.startswith('#include'): + exec(macro[1:]) + else: + print(ln) + +def include(fname): + preprocess(fname) + +for arg in sys.argv[1:]: + preprocess(arg) |
