-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
136 lines (115 loc) · 3.58 KB
/
makefile
File metadata and controls
136 lines (115 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
CC = gcc
RM = rm
CLEAR_CMD = clear
SHOW_FILE_CMD = cat
BISON_FLAGS = -v --defines -d
ifeq ($(OS), Windows_NT)
TARGET = Windows
SHOW_FILE_CMD = type
CLEAR_CMD = cls
RM = del
TARGET_EXT = .exe
LUA_TARGET = mingw
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
TARGET = MacOS
else
TARGET = Linux
BISON_FLAGS = -v --defines -d -Wcounterexamples -Wconflicts-rr -Wother
endif
endif
default: build
compile:
$(CC) axo_gram.tab.c lex.yy.c src/axo.c src/utils/utils.c src/utils/hashmap/hashmap.c -o axo$(TARGET_EXT) -Wall -g -L./src/lua/src -llua -lm
@echo [92mCompiler built![0m
gen:
@echo [96mGenerating lexer...[0m
@flex --header-file=lex.yy.h -o lex.yy.c -d -R scan.l
@echo [96mGenerating parser...[0m
@bison -d axo_gram.y $(BISON_FLAGS)
@echo [94mBuilding the compiler... [0m
build:
@make lua -s
@make -s gen
@make -s compile
gh_build:
@make lua -s
@make compile -s
wasm:
@make -s gen
emcc axo_gram.tab.c src/axo.c src/utils/utils.c src/utils/hashmap/hashmap.c lex.yy.c \
./src/lua/src/lapi.c ./src/lua/src/lauxlib.c ./src/lua/src/lbaselib.c ./src/lua/src/lcode.c ./src/lua/src/ldblib.c ./src/lua/src/ldebug.c ./src/lua/src/ldo.c ./src/lua/src/ldump.c \
./src/lua/src/lfunc.c ./src/lua/src/lgc.c ./src/lua/src/linit.c ./src/lua/src/liolib.c ./src/lua/src/llex.c ./src/lua/src/lmathlib.c ./src/lua/src/lmem.c ./src/lua/src/loadlib.c \
./src/lua/src/lobject.c ./src/lua/src/lopcodes.c ./src/lua/src/loslib.c ./src/lua/src/lparser.c ./src/lua/src/lstate.c ./src/lua/src/lstring.c ./src/lua/src/ltable.c \
./src/lua/src/ltm.c ./src/lua/src/lundump.c ./src/lua/src/lvm.c ./src/lua/src/lzio.c ./src/lua/src/lcorolib.c ./src/lua/src/lstrlib.c ./src/lua/src/lutf8lib.c ./src/lua/src/ltablib.c ./src/lua/src/lctype.c \
-o playground.js \
-s MODULARIZE=1 \
-s WASM=1 --preload-file "modules" \
-g -gsource-map \
-s STACK_SIZE=20971520 -s INITIAL_MEMORY=33554432 \
-s EXPORT_ES6=1 \
-s EXPORTED_RUNTIME_METHODS='["cwrap", "stringToUTF8", "UTF8ToString"]' \
-s EXPORTED_FUNCTIONS='["_axo_compile_to_c", "_luaL_newstate", "_luaL_openlibs", "_luaL_loadstring", "_lua_tolstring", "_lua_close"]' \
-lm
@mv ./playground.js docs/playground/playground.js
@mv ./playground.wasm docs/playground/playground.wasm
@mv ./playground.wasm.map docs/playground/playground.wasm.map
@mv ./playground.data docs/playground/playground.data
@cp -r ./modules ./docs/playground/modules
clear_wasm:
$(RM) playground.js
$(RM) playground.wasm
$(RM) playground.wasm.map
$(RM) playground.data
run:
$(CLEAR_CMD)
@make -s build
@$(SHOW_FILE_CMD) test.axo
@./axo$(TARGET_EXT) test.axo
@$(SHOW_FILE_CMD) test.c
@echo [92mRunning output program...[0m
@./test$(TARGET_EXT)
@make -s clean
show:
@make -s build
@$(SHOW_FILE_CMD) test.axo
@$(SHOW_FILE_CMD) test.c
clean:
@make clean_lua -s
@$(RM) axo_gram.tab.c
@$(RM) axo_gram.tab.h
@$(RM) lex.yy.c
@$(RM) lex.yy.h
@$(RM) axo$(TARGET_EXT)
debug_test:
@make -s build
valgrind --track-origins=yes axo test.axo
dbg:
@clear
@make -s
valgrind axo run test.axo
dbgf:
@clear
@make -s
valgrind --leak-check=full axo run test.axo
lua:
@echo [95mBuilding local lua...[0m
@cd src/lua/src && make $(LUA_TARGET)
@echo [95mLua built sucessfully![0m
lua_wasm:
@echo [95mBuilding wasm lua...[0m
@cd src/lua/src && make wasm
@echo [95mLua built sucessfully![0m
clean_lua:
@echo [95mDeleting local lua[0m
@cd src/lua/src && make clean -s
@echo [95mLua deleted![0m
commit:
@clear
@echo [96mPreparing commit...[0m
@make -s
@make -s clean
@make gen
git add .
@echo [96mDone! Name the commit and push it.[0m