bles
This commit is contained in:
parent
95d7ef4212
commit
b79c9584d5
14
Makefile
14
Makefile
@ -1,5 +1,4 @@
|
|||||||
# Basic configuration
|
# Basic configuration
|
||||||
TARGET := langc
|
|
||||||
AFLAGS = -felf64 -F dwarf -g
|
AFLAGS = -felf64 -F dwarf -g
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
@ -10,7 +9,9 @@ endif
|
|||||||
SRCDIR := src
|
SRCDIR := src
|
||||||
OBJDIR := obj
|
OBJDIR := obj
|
||||||
LIBDIR := lib
|
LIBDIR := lib
|
||||||
|
BINDIR := bin
|
||||||
|
|
||||||
|
TARGET := $(BINDIR)/langc
|
||||||
# Core directories
|
# Core directories
|
||||||
COREDIR := $(SRCDIR)/core
|
COREDIR := $(SRCDIR)/core
|
||||||
MATHDIR := $(COREDIR)/math
|
MATHDIR := $(COREDIR)/math
|
||||||
@ -132,6 +133,7 @@ ALL_OBJ := $(patsubst $(SRCDIR)/%.s,$(OBJDIR)/%.o,$(ALL_SRC))
|
|||||||
|
|
||||||
# Library settings
|
# Library settings
|
||||||
LIBNAME := $(LIBDIR)/core/core.a
|
LIBNAME := $(LIBDIR)/core/core.a
|
||||||
|
LIBCORE_DIR := $(LIBDIR)/core
|
||||||
LIBFTDIR := $(LIBDIR)/libft
|
LIBFTDIR := $(LIBDIR)/libft
|
||||||
LIBFT := $(LIBFTDIR)/lib/libft.a
|
LIBFT := $(LIBFTDIR)/lib/libft.a
|
||||||
LIB_OBJ := $(filter-out $(OBJDIR)/start.o, $(ALL_OBJ))
|
LIB_OBJ := $(filter-out $(OBJDIR)/start.o, $(ALL_OBJ))
|
||||||
@ -158,14 +160,20 @@ all: prepare-build build-core build-parser build-lexer build-global build-main l
|
|||||||
# Stage 1: Prepare build environment
|
# Stage 1: Prepare build environment
|
||||||
prepare-build: create-directories
|
prepare-build: create-directories
|
||||||
|
|
||||||
create-directories: | $(OBJDIRS) $(LIBDIR)
|
create-directories: | $(OBJDIRS) $(LIBDIR) $(LIBCORE_DIR) $(BINDIR)
|
||||||
|
|
||||||
$(OBJDIRS):
|
$(OBJDIRS):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(BINDIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
$(LIBDIR):
|
$(LIBDIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(LIBCORE_DIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
# Stage 2: Build core modules
|
# Stage 2: Build core modules
|
||||||
build-core: build-math build-string build-memory build-vector build-print build-file build-syscall build-string-builder
|
build-core: build-math build-string build-memory build-vector build-print build-file build-syscall build-string-builder
|
||||||
|
|
||||||
@ -214,7 +222,7 @@ $(TARGET): $(ALL_OBJ) $(LIBFT) $(LIBNAME)
|
|||||||
# Stage 8: Create library
|
# Stage 8: Create library
|
||||||
create-library: $(LIBNAME)
|
create-library: $(LIBNAME)
|
||||||
|
|
||||||
$(LIBNAME): $(LIB_OBJ) | $(LIBDIR)
|
$(LIBNAME): $(LIB_OBJ) $(LIBDIR)
|
||||||
ar rcs $@ $(LIB_OBJ)
|
ar rcs $@ $(LIB_OBJ)
|
||||||
|
|
||||||
$(LIBFT):
|
$(LIBFT):
|
||||||
|
|||||||
9
compile
9
compile
@ -1,17 +1,20 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
LD_ARGS="-nostdlib -static"
|
LD_ARGS="-nostdlib -static"
|
||||||
NASM_FLAG="-felf64 -g"
|
NASM_FLAG="-felf64 -g"
|
||||||
LIBS="./lib/core/core.a ./lib/libft/lib/libft.a"
|
LIBS="./lib/core/core.a ./lib/libft/lib/libft.a"
|
||||||
PROGNAME="langproc"
|
|
||||||
|
COMPILER_PATH=./bin/langc
|
||||||
|
|
||||||
filename=$1
|
filename=$1
|
||||||
comp_out=${filename%.lang}.s
|
comp_out=${filename%.lang}.s
|
||||||
nasm_out=${comp_output%.s}.o
|
nasm_out=${comp_out%.s}.o
|
||||||
|
PROGNAME=${filename%.lang}
|
||||||
|
|
||||||
./langc ${filename}
|
${COMPILER_PATH} ${filename}
|
||||||
|
|
||||||
nasm ${NASM_FLAG} ${comp_out} -o ${nasm_out}
|
nasm ${NASM_FLAG} ${comp_out} -o ${nasm_out}
|
||||||
ld ${nasm_out} ${LD_ARGS} ${LIBS} -o ${PROGNAME}
|
ld ${nasm_out} ${LD_ARGS} ${LIBS} -o ${PROGNAME}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
# By: vvobis <marvin@42.fr> +#+ +:+ +#+ #
|
# By: vvobis <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/09/17 14:23:19 by vvobis #+# #+# #
|
# Created: 2024/09/17 14:23:19 by vvobis #+# #+# #
|
||||||
# Updated: 2025/05/14 15:16:25 by vvobis ### ########.fr #
|
# Updated: 2025/05/29 15:50:55 by victor ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ NAME := libft.a
|
|||||||
|
|
||||||
CC := cc
|
CC := cc
|
||||||
|
|
||||||
CFLAGS := -Wall -Wextra -Werror -mabi=sysv
|
CFLAGS := -Wall -Wextra -Werror -fstack-protector
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CFLAGS += -g3
|
CFLAGS += -g3
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
%include "./src/core/string_builder/sb.s"
|
%include "./src/core/string_builder/sb.s"
|
||||||
|
%include "./src/inc/c_alignment.s"
|
||||||
|
|
||||||
section .data
|
section .data
|
||||||
usage: db "Usage: ./debug <file>.lang", 0xa, 0
|
usage: db "Usage: ./debug <file>.lang", 0xa, 0
|
||||||
@ -67,10 +68,13 @@ _start:
|
|||||||
mov rdi, rax
|
mov rdi, rax
|
||||||
mov rdi, [rdi]
|
mov rdi, [rdi]
|
||||||
mov rsi, dot_s
|
mov rsi, dot_s
|
||||||
call ft_strjoin
|
c_call ft_strjoin
|
||||||
mov rdi, rax
|
mov rdi, rax
|
||||||
mov rsi, 0x241
|
mov rsi, 0x241
|
||||||
mov rdx, 0o644
|
mov rdx, 0o644
|
||||||
|
push rdi
|
||||||
|
call putstr
|
||||||
|
pop rdi
|
||||||
call open
|
call open
|
||||||
mov [fd_out], rax
|
mov [fd_out], rax
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user