Mineclonia/tools/deps-to-luacheck.awk

42 lines
661 B
Awk

BEGIN {
if (!DIR || !MOD) {
printf("error: DIR and MOD must be set.\n");
_panic=1;
exit 1;
}
printf("files[\"" DIR "\"] = { globals = { \"" MOD "\" }");
if (!EMPTY) {
printf(", read_globals = { ");
}
};
# Without a pattern, this will match on empty lines
# and mess up the entry. We clean up the extra commas
# later in the script.
/.+/{
# Get rid of the optional (?) mark from
# depends.txt entries.
sub("?$", "");
# Some files have CRLF, so get rid of those
# too.
sub("\xd", "");
SEP=", ";
if (NR == 1) {
SEP="";
}
printf(SEP "\"" $1 "\"");
};
END {
if (!_panic) {
if (!EMPTY) {
printf(" }");
}
printf(" }\n");
}
};