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
|
NAME = rev | cut -d/ -f1 | rev | cut -d. -f1
|
||||||
|
|
||||||
.PHONY: all clean mk maint
|
.PHONY: all clean mk format maint
|
||||||
.SUFFIXES: .c .o
|
.SUFFIXES: .c .o
|
||||||
|
|
||||||
all: pmake$(EXE)
|
all: pmake$(EXE)
|
||||||
|
|
@ -52,6 +52,9 @@ mk/js.mk:
|
||||||
|
|
||||||
mk: mk/js.mk
|
mk: mk/js.mk
|
||||||
|
|
||||||
|
format:
|
||||||
|
clang-format --verbose -i src/*/*.js `find src -name "*.c" -or -name "*.h"`
|
||||||
|
|
||||||
maint:
|
maint:
|
||||||
rm -f mk/*.mk
|
rm -f mk/*.mk
|
||||||
$(MAKE) mk
|
$(MAKE) mk
|
||||||
|
|
@ -62,16 +65,13 @@ src/config.h:
|
||||||
echo "#ifndef __CONFIG_H__" > $@
|
echo "#ifndef __CONFIG_H__" > $@
|
||||||
echo "#define __CONFIG_H__" >> $@
|
echo "#define __CONFIG_H__" >> $@
|
||||||
echo "" >> $@
|
echo "" >> $@
|
||||||
echo "#define COMPILERS \\" >> $@
|
for i in compiler action; do \
|
||||||
find src/compiler -name "*.js" | while read js; do \
|
echo "#define `echo $$i | tr '[:lower:]' '[:upper:]'`S \\" >> $@ ; \
|
||||||
echo " X(`echo $$js | $(NAME)`) \\" ; \
|
find src/$$i -name "*.js" | while read js; do \
|
||||||
done >> $@
|
echo " X(`echo $$js | $(NAME)`, $$i) \\" ; \
|
||||||
echo "" >> $@
|
done >> $@ ; \
|
||||||
echo "#define ACTIONS \\" >> $@
|
echo "" >> $@ ; \
|
||||||
find src/action -name "*.js" | while read js; do \
|
done
|
||||||
echo " X(`echo $$js | $(NAME)`) \\" ; \
|
|
||||||
done >> $@
|
|
||||||
echo "" >> $@
|
|
||||||
echo "#define JS \\" >> $@
|
echo "#define JS \\" >> $@
|
||||||
echo " COMPILERS \\" >> $@
|
echo " COMPILERS \\" >> $@
|
||||||
echo " ACTIONS" >> $@
|
echo " ACTIONS" >> $@
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const GCC = pmake.inherit(Compiler);
|
const GCC = pmake.inherit(Compiler);
|
||||||
|
|
||||||
|
GCC.name = "GCC";
|
||||||
GCC.description = "GCC/Clang";
|
GCC.description = "GCC/Clang";
|
||||||
|
|
||||||
pmake.register(GCC);
|
pmake.register(GCC);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const Watcom = pmake.inherit(Compiler);
|
const Watcom = pmake.inherit(Compiler);
|
||||||
|
|
||||||
|
Watcom.name = "Watcom";
|
||||||
Watcom.description = "Open Watcom";
|
Watcom.description = "Open Watcom";
|
||||||
|
|
||||||
pmake.register(Watcom);
|
pmake.register(Watcom);
|
||||||
|
|
|
||||||
6
src/config.h
generated
6
src/config.h
generated
|
|
@ -2,11 +2,11 @@
|
||||||
#define __CONFIG_H__
|
#define __CONFIG_H__
|
||||||
|
|
||||||
#define COMPILERS \
|
#define COMPILERS \
|
||||||
X(watcom) \
|
X(watcom, compiler) \
|
||||||
X(gcc) \
|
X(gcc, compiler)
|
||||||
|
|
||||||
#define ACTIONS \
|
#define ACTIONS \
|
||||||
X(gmake) \
|
X(gmake, action)
|
||||||
|
|
||||||
#define JS \
|
#define JS \
|
||||||
COMPILERS \
|
COMPILERS \
|
||||||
|
|
|
||||||
8
src/js.c
8
src/js.c
|
|
@ -85,12 +85,12 @@ int js_init(int argc, char** argv){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define X(name) \
|
#define X(name, prefix) \
|
||||||
if(duk_peval_lstring(js_ctx, compiler_ ## name, compiler_ ## name ## _len) != 0){ \
|
if(duk_peval_lstring(js_ctx, prefix##_##name, prefix##_##name##_len) != 0) { \
|
||||||
printf("error: %s: %s\n", "compiler/" #name ".js", duk_safe_to_string(js_ctx, -1)); \
|
printf("error: %s: %s\n", #prefix "/" #name ".js", duk_safe_to_string(js_ctx, -1)); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
COMPILERS;
|
JS;
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
if(duk_peval_lstring(js_ctx, js_cmdline, js_cmdline_len) != 0) {
|
if(duk_peval_lstring(js_ctx, js_cmdline, js_cmdline_len) != 0) {
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ pmake.inherited = function(base, parent){
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
pmake.register = function(base) {
|
pmake.register = function(base) {
|
||||||
if(pmake.inherited(base, Compiler)) {
|
if(pmake.inherited(base, Compiler)) {
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function Compiler() {
|
function Compiler() {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
extern unsigned char name[]; \
|
extern unsigned char name[]; \
|
||||||
extern unsigned int name##_len;
|
extern unsigned int name##_len;
|
||||||
|
|
||||||
#define X(name) LOAD(compiler_ ## name)
|
#define X(name, prefix) LOAD(prefix##_##name)
|
||||||
JS;
|
JS;
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue