Merge pull request #9 from Alessandro-Salerno/main

Switched from a shell script to a makefile
This commit is contained in:
Francesco Cozzuto
2022-05-21 22:51:17 +02:00
committed by GitHub
3 changed files with 44 additions and 9 deletions
+41
View File
@@ -0,0 +1,41 @@
# Aux functions
rwildcard = $(foreach d, $(wildcard $(1:=/*)), $(call rwildcard ,$d, $2) $(filter $(subst *, %, $2), $d))
# Compiler
CXX = gcc
CC = $(CROSS_COMPILE)$(CXX)
# Compiler flags
CFLAGS = -O3 -Wall -Wextra -g
LFLAGS = -lm
# Files and directories
SRCDIR = src
OBJDIR = temp
BINDIR = build
OUTFILE = noja
# Find all files
SRC = $(call rwildcard, $(SRCDIR), *.c)
OBJS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
# Compile everything to object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@ echo $(shell tput setaf 3) [C] $(shell tput setaf 5) [SRC] $(shell tput setaf 7) $^
@ mkdir -p $(@D)
@ $(CC) $(CFLAGS) -c $^ -o $@
# Clean all artifacts and rebuild the whole thing
all: clean $(OBJS) build
# Link all object files
build:
@ echo !==== LINKING
@ mkdir -p $(BINDIR)
@ $(CC) -o $(BINDIR)/$(OUTFILE) $(OBJS) $(LFLAGS)
clean:
@ rm -rf $(BINDIR)
@ rm -rf $(OBJDIR)
+1 -7
View File
@@ -56,16 +56,10 @@ The interpreter is fully functional, but lots of built-in functions that one wou
## Build ## Build
To build it, just run: To build it, just run:
```sh ```sh
$ ./build.sh $ make
``` ```
it will create a `build` folder where the interpreter's executable will be generated. it will create a `build` folder where the interpreter's executable will be generated.
You may need to give executable permissions to the script. You can do so with by running:
```sh
$ chmod +x build.sh
```
## Usage ## Usage
You can run files by doing: You can run files by doing:
```sh ```sh
+1 -1
View File
@@ -1795,7 +1795,7 @@ static Node *parse_ifelse_statement(Context *ctx)
static Node *parse_compound_statement(Context *ctx, TokenKind end) static Node *parse_compound_statement(Context *ctx, TokenKind end)
{ {
int end_offset; int end_offset = 0;
Node *head, **tail; Node *head, **tail;
tail = &head; tail = &head;