feat: update minishell structure

change rust language -> GNU Assembly
add a Dockerfile to build on x64 linux
also add Makefile pre config (must change)
This commit is contained in:
2025-10-12 19:21:47 +02:00
parent 61980d7946
commit e2a49516ec
9 changed files with 75 additions and 56 deletions

View File

@@ -1,22 +0,0 @@
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

31
.gitignore vendored
View File

@@ -1,21 +1,16 @@
# Generated by Cargo
# will have compiled files and executables
debug
target
*.o
*.out
*.bin
*.elf
*.exe
a.out
# These are backup files generated by rustfmt
**/*.rs.bk
*~
*.swp
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
.vscode/
.idea/
.env/
.DS_Store
# Generated by cargo mutants
# Contains mutation testing data
**/mutants.out*/
# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
*.log

7
Cargo.lock generated
View File

@@ -1,7 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "minishell"
version = "0.1.0"

View File

@@ -1,6 +0,0 @@
[package]
name = "minishell"
version = "0.1.0"
edition = "2024"
[dependencies]

12
Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
# x86_64 build
FROM --platform=linux/amd64 debian:bookworm-slim
RUN apt-get update -y \
&& apt-get install -y \
binutils \
make \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
CMD ["make"]

32
Makefile Normal file
View File

@@ -0,0 +1,32 @@
TARGET ?= main
SRC := $(wildcard src/*.s src/*.asm)
OBJ := $(SRC:.s=.o)
OBJ := $(OBJ:.asm=.o)
AS = as
LD = ld
NASM = nasm
ASFLAGS =
NASMFLAGS = -f elf64
LDFLAGS =
all: $(TARGET) run
%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
%.o: %.asm
$(NASM) $(NASMFLAGS) -o $@ $<
$(TARGET): $(OBJ)
$(LD) $(LDFLAGS) -o $@ $^
clean:
rm -f $(OBJ) $(TARGET)
re: clean all
run: $(TARGET)
./$(TARGET)

BIN
main Executable file

Binary file not shown.

View File

@@ -1,3 +0,0 @@
fn main() {
println!("hello world!");
}

18
src/main.s Normal file
View File

@@ -0,0 +1,18 @@
.global _start
.section .data
msg:
.ascii "Hello World!\n"
len = . - msg
.section .text
_start:
mov $1, %rax
mov $1, %rdi
lea msg(%rip), %rsi
mov $len, %rdx
syscall
mov $60, %rax
xor %rdi, %rdi
syscall