Updated the project structure, and modified the Makefile to hopefully be future proof so I can freely make sub-folders in the src/ folder and not have to worry about breaking the Makefile.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
clox
|
||||
*.lox
|
||||
obj/
|
||||
bin/
|
||||
@@ -1,17 +1,26 @@
|
||||
CC = gcc
|
||||
SOURCEFILES := $(wildcard *.c)
|
||||
CFLAGS=-Wall
|
||||
SRC=src
|
||||
OBJ=obj
|
||||
SRCS=$(wildcard $(SRC)/*.c)
|
||||
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
|
||||
|
||||
SOURCE := $(wildcard *.c)
|
||||
BINDIR=bin
|
||||
BIN=$(BINDIR)/clox
|
||||
|
||||
$(SOURCE:.c=.o): $(SOURCE)
|
||||
@mkdir -p obj
|
||||
$(CC) $^ -o obj/clox
|
||||
all:$(BIN)
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $@
|
||||
|
||||
$(OBJ)/%.o: $(SRC)/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: clean
|
||||
.PHONY: test
|
||||
|
||||
clean:
|
||||
rm -r obj
|
||||
rm -r $(BINDIR)/* $(OBJ)/*
|
||||
|
||||
test:
|
||||
./obj/clox test.lox
|
||||
$(BIN) test.lox
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "expr.h"
|
||||
|
||||
char* Parenthesize(char*, int, ...);
|
||||
|
||||
void VisitBinary(struct binary expr) {
|
||||
|
||||
}
|
||||
|
||||
void VisitGrouping(struct grouping);
|
||||
void VisitLiteral(Token);
|
||||
void VisitUnary(struct unary);
|
||||
|
||||
char* Parenthesize(char* operator, int count, ...) {
|
||||
va_list list;
|
||||
va_start(list, count);
|
||||
|
||||
va_arg(list, Expr);
|
||||
}
|
||||
+4
-4
@@ -40,9 +40,9 @@ struct Expr {
|
||||
} expression;
|
||||
};
|
||||
|
||||
void VisitBinary(struct binary);
|
||||
void VisitGrouping(struct grouping);
|
||||
void VisitLiteral(Token);
|
||||
void VisitUnary(struct unary);
|
||||
// void VisitBinary(struct binary);
|
||||
// void VisitGrouping(struct grouping);
|
||||
// void VisitLiteral(Token);
|
||||
// void VisitUnary(struct unary);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user