-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (32 loc) · 1.02 KB
/
Makefile
File metadata and controls
44 lines (32 loc) · 1.02 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
# Variables
SRC_DIR = lox/com/craftinginterpreters/lox
TOOL_DIR = lox/com/craftinginterpreters/tool
CLASS_DIR = out
MAIN_CLASS = com.craftinginterpreters.lox.Lox
# New target for GenerateAst main class
GENERATE_AST_CLASS = com.craftinginterpreters.tool.GenerateAst
# Find all .java files
JAVA_FILES := $(shell find $(SRC_DIR) $(TOOL_DIR) -name "*.java")
# Targets
.PHONY: all clean compile run lox
all: compile
compile:
@mkdir -p $(CLASS_DIR)
javac -d $(CLASS_DIR) $(JAVA_FILES)
run: compile
java -cp $(CLASS_DIR) $(MAIN_CLASS)
lox: compile
java -cp $(CLASS_DIR) $(MAIN_CLASS) $(ARGS)
debug: compile
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -cp $(CLASS_DIR) $(MAIN_CLASS) $(ARGS)
generate_ast: compile
java -cp $(CLASS_DIR) $(GENERATE_AST_CLASS) $(ARGS)
clean:
rm -rf $(CLASS_DIR)
# Usage
# To compile and run the program:
# make run
# To compile and run with arguments:
# make lox ARGS="your arguments here"
# To generate AST classes:
# make generate_ast ARGS="your output directory here"