format
This commit is contained in:
parent
ece62938a9
commit
a523a42e6e
10 changed files with 78 additions and 52 deletions
24
.clang-format
Normal file
24
.clang-format
Normal 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
|
||||
22
GNUmakefile
22
GNUmakefile
|
|
@ -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" >> $@
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const GCC = pmake.inherit(Compiler);
|
||||
|
||||
GCC.name = "GCC";
|
||||
GCC.description = "GCC/Clang";
|
||||
|
||||
pmake.register(GCC);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const Watcom = pmake.inherit(Compiler);
|
||||
|
||||
Watcom.name = "Watcom";
|
||||
Watcom.description = "Open Watcom";
|
||||
|
||||
pmake.register(Watcom);
|
||||
|
|
|
|||
6
src/config.h
generated
6
src/config.h
generated
|
|
@ -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 \
|
||||
|
|
|
|||
8
src/js.c
8
src/js.c
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ pmake.inherited = function(base, parent){
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
pmake.register = function(base) {
|
||||
if(pmake.inherited(base, Compiler)) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Compiler() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue