1
0
Fork 0
wasp-os/tools/preprocess.py
Daniel Thompson c74d9e296b tools: preprocess: Ensure we use python3 interpreter
Not being explicit about the correct python interpreter causes trouble
on distros that do not alias python to python3 and/or that do not
install python2 by default.

Reported by: Mirko Covizzi <mrkcvzz@gmail.com>
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
2020-08-02 11:54:58 +01:00

27 lines
561 B
Python
Executable file

#!/usr/bin/env python3
# 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)