-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (87 loc) · 2.86 KB
/
Makefile
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
SRC_DIR = src
BIN_DIR = out
CORE_DIR= core
TMP_DIR= tmp
SAMPLE_DIR = samples
TESTS_DIR = $(SAMPLE_DIR)/testSamples/
MICROPIUPK = microPIUPK.jar
SEMANTIC_ERRORS_DIR = errorSamples
PGM = TestLoocMakefile
EXTENSION = looc
PGM_JAVA = $(PGM).java
LOG_FILE_ANTLR = antlr.log
export CLASSPATH=/usr/local/lib/antlr-3.3-complete.jar:.:./$(BIN_DIR):./$(TMP_DIR):$$CLASSPATH
#$(shell mkdir -p $(ASM_DIR))
all: antlr
java: antlr
@echo "\n --- Create out/ directory ---"
mkdir -p $(BIN_DIR)
@echo "\n --- Compile java classes ---"
javac -d $(BIN_DIR) $(SRC_DIR)/$(CORE_DIR)/LoocLexer.java $(SRC_DIR)/$(CORE_DIR)/LoocParser.java $(SRC_DIR)/$(PGM_JAVA)
@echo ""
antlr: clean
@echo "\n --- Execute Antlr ---"
java org.antlr.Tool -o $(SRC_DIR)/$(CORE_DIR) Looc.g 2>&1 |tail -n 5
clean:
rm -rf output/
rm -rf target/
rm -rf $(BIN_DIR)
rm -rf $(TMP_DIR)
rm -f $(LOG_FILE_ANTLR)
javaTest:
@echo "\n --- Create tmp/ directory ---"
mkdir -p $(TMP_DIR)
@echo "\n --- Execute Antlr ---"
java org.antlr.Tool -o $(TMP_DIR) Looc.g 2>&1 |tail -n 5
@echo "\n --- Compile java classes ---"
javac -d $(TMP_DIR) $(TMP_DIR)/LoocLexer.java $(TMP_DIR)/LoocParser.java $(SRC_DIR)/$(PGM_JAVA)
@echo ""
testSyntaxErrors:
@echo "\n --- Test Syntax errors ---"
@for file in $(TESTS_DIR)*.$(EXTENSION); do \
FILE=$$(basename $$file); \
TMP=$$(java $(PGM) $$file 2>&1|tr -d '\n'); \
LETTER=$$(echo $$FILE | head -c 2); \
if [ "$$LETTER" != '__' ] ; then \
FIRST=$$(echo $$LETTER | head -c 1); \
if [ "$$FIRST" = '_' ] ; then \
if [ -z "$$TMP" ]; then \
echo "\033[92m --- Check $$(basename $$file)\033[94m (Fichier avec erreur)"; \
echo "\t\033[91mIl devrait y avoir des erreurs...\033[0m"; \
else \
echo "\033[92m --- Check $$(basename $$file)\033[94m (Fichier avec erreur)"; \
echo "\t\033[90mErreur détecté: $$(echo $$TMP|head -c 50)...\033[0m"; \
fi; \
else \
if [ -z "$$TMP" ]; then \
echo "\033[92m --- Check $$(basename $$file)\033[0m"; \
else \
echo "\033[91m --- Check $$(basename $$file)\033[0m"; \
echo "\t\033[91m$$TMP\033[0m"; \
fi; \
fi; \
fi; \
done;
@echo ""
testSemanticErrors:
@echo "\n --- Test Semantic errors ---"
@for file in $(SAMPLE_DIR)/$(SEMANTIC_ERRORS_DIR)/*.$(EXTENSION); do \
FILE=$$(basename $$file); \
TMP=$$(java $(PGM) $$file 2>&1|tr -d '\n'); \
if [ -z "$$TMP" ]; then \
echo "\033[92m --- Check $$(basename $$file)\033[94m (Fichier avec erreur sémantique)"; \
else \
echo "\033[92m --- Check $$(basename $$file)\033[94m (Fichier avec erreur sémantique)"; \
echo "\t\033[91m$$TMP\033[0m"; \
fi; \
done;
@echo ""
test:javaTest testSyntaxErrors testSemanticErrors
@echo "\n\033[0m --- Delete tmp/ directory ---"
rm -rf $(TMP_DIR)
ass:
java -jar $(MICROPIUPK) -ass $(file).asm
sim: ass
java -jar $(MICROPIUPK) -sim
batch: ass
java -jar $(MICROPIUPK) -batch $(file).iup