Created
October 24, 2016 11:37
-
-
Save louisswarren/4e6216662a5c3a51d6b89c55279dd51c to your computer and use it in GitHub Desktop.
Generate C make files automatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
args = sys.argv[1:] | |
def find_dependencies(lines): | |
deps = set() | |
for line in lines: | |
match = re.match('#include "(.*)"', line) | |
if match: | |
deps.add(match.groups()[0]) | |
return deps | |
for fname in args: | |
with open(fname) as f: | |
deps = find_dependencies(f.readlines()) | |
print("{}: {}".format(fname, ' '.join(map(str, sorted(deps))))) | |
print("\t${CC} ${CFLAGS}", fname) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No
@accumulate
. 1/10 for effort.