This commit is contained in:
Nishi 2026-05-08 05:35:07 +09:00
commit a523a42e6e
Signed by: nishi
GPG key ID: 27EF69B208EB9343
10 changed files with 78 additions and 52 deletions

24
.clang-format Normal file
View file

@ -0,0 +1,24 @@
---
UseTab: Always
TabWidth: 8
AlignConsecutiveAssignments:
Enabled: true
AlignConsecutiveDeclarations:
Enabled: true
AccessModifierOffset: -4
NamespaceIndentation: All
IndentWidth: 8
PointerAlignment: Left
ColumnLimit: 0
AllowShortIfStatementsOnASingleLine: Always
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
SpaceBeforeParens: Never
AlignEscapedNewlines: DontAlign
SortIncludes: false
AllowShortEnumsOnASingleLine: false
#IndentPPDirectives: AfterHash

View file

@ -32,7 +32,7 @@ OBJS += external/duktape/duktape.o external/stb/stb_ds.o
NAME = rev | cut -d/ -f1 | rev | cut -d. -f1
.PHONY: all clean mk maint
.PHONY: all clean mk format maint
.SUFFIXES: .c .o
all: pmake$(EXE)
@ -52,6 +52,9 @@ mk/js.mk:
mk: mk/js.mk
format:
clang-format --verbose -i src/*/*.js `find src -name "*.c" -or -name "*.h"`
maint:
rm -f mk/*.mk
$(MAKE) mk
@ -62,16 +65,13 @@ src/config.h:
echo "#ifndef __CONFIG_H__" > $@
echo "#define __CONFIG_H__" >> $@
echo "" >> $@
echo "#define COMPILERS \\" >> $@
find src/compiler -name "*.js" | while read js; do \
echo " X(`echo $$js | $(NAME)`) \\" ; \
done >> $@
echo "" >> $@
echo "#define ACTIONS \\" >> $@
find src/action -name "*.js" | while read js; do \
echo " X(`echo $$js | $(NAME)`) \\" ; \
done >> $@
echo "" >> $@
for i in compiler action; do \
echo "#define `echo $$i | tr '[:lower:]' '[:upper:]'`S \\" >> $@ ; \
find src/$$i -name "*.js" | while read js; do \
echo " X(`echo $$js | $(NAME)`, $$i) \\" ; \
done >> $@ ; \
echo "" >> $@ ; \
done
echo "#define JS \\" >> $@
echo " COMPILERS \\" >> $@
echo " ACTIONS" >> $@

View file

@ -1,5 +1,6 @@
const GCC = pmake.inherit(Compiler);
GCC.name = "GCC";
GCC.description = "GCC/Clang";
pmake.register(GCC);

View file

@ -1,5 +1,6 @@
const Watcom = pmake.inherit(Compiler);
Watcom.name = "Watcom";
Watcom.description = "Open Watcom";
pmake.register(Watcom);

6
src/config.h generated
View file

@ -2,11 +2,11 @@
#define __CONFIG_H__
#define COMPILERS \
X(watcom) \
X(gcc) \
X(watcom, compiler) \
X(gcc, compiler)
#define ACTIONS \
X(gmake) \
X(gmake, action)
#define JS \
COMPILERS \

View file

@ -85,12 +85,12 @@ int js_init(int argc, char** argv){
return 1;
}
#define X(name) \
if(duk_peval_lstring(js_ctx, compiler_ ## name, compiler_ ## name ## _len) != 0){ \
printf("error: %s: %s\n", "compiler/" #name ".js", duk_safe_to_string(js_ctx, -1)); \
#define X(name, prefix) \
if(duk_peval_lstring(js_ctx, prefix##_##name, prefix##_##name##_len) != 0) { \
printf("error: %s: %s\n", #prefix "/" #name ".js", duk_safe_to_string(js_ctx, -1)); \
return 1; \
}
COMPILERS;
JS;
#undef X
if(duk_peval_lstring(js_ctx, js_cmdline, js_cmdline_len) != 0) {

View file

@ -20,12 +20,12 @@ pmake.inherited = function(base, parent){
}
return false;
}
};
pmake.register = function(base) {
if(pmake.inherited(base, Compiler)) {
}
}
};
function Compiler() {
}

View file

@ -14,7 +14,7 @@
extern unsigned char name[]; \
extern unsigned int name##_len;
#define X(name) LOAD(compiler_ ## name)
#define X(name, prefix) LOAD(prefix##_##name)
JS;
#undef X