diff options
author | Erik K <erikk@previousplan.org> | 2022-05-13 17:24:26 +0000 |
---|---|---|
committer | Erik K <erikk@previousplan.org> | 2022-05-13 17:24:26 +0000 |
commit | b2fada1dd19211d71e04557653d08e697134a6ce (patch) | |
tree | 063b6d1280193046321db1e53506be5b72d2220f /genplugin.awk |
initial commit
Diffstat (limited to 'genplugin.awk')
-rw-r--r-- | genplugin.awk | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/genplugin.awk b/genplugin.awk new file mode 100644 index 0000000..e6f99ac --- /dev/null +++ b/genplugin.awk @@ -0,0 +1,20 @@ +#!/usr/bin/awk -f + +BEGIN { + f = "plugins.h" + printf "#ifndef PLUGIN_H\n#define PLUGIN_H\n#include \"sm.h\"\n" >f +} + +# We read the list of plugins from stdin +{ + plugins[i++] = $0 + printf "extern Plugin %s;\n", $0 >f +} + +END { + printf "#define NPLUGINS %d\n#ifdef MAIN\nPlugin *plugins[%d] = {\n", NR, NR >f + for (i in plugins) { + printf "\t&%s,\n", plugins[i] >f + } + printf "};\n#endif /* MAIN */\n\n#endif /* ! PLUGIN_H */" >f +} |