Merge pull request #9 from Alessandro-Salerno/main
Switched from a shell script to a makefile
This commit is contained in:
@@ -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)
|
||||||
@@ -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
|
||||||
@@ -75,4 +69,4 @@ location/of/noja run <filename>
|
|||||||
or you can run strings by doing:
|
or you can run strings by doing:
|
||||||
```sh
|
```sh
|
||||||
location/of/noja run inline <string>
|
location/of/noja run inline <string>
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user