parent
d76cfe86a3
commit
c53c7b6988
2 changed files with 32 additions and 17 deletions
21
.forgejo/workflows/build.yml
Normal file
21
.forgejo/workflows/build.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: docker
|
||||||
|
container: alpine
|
||||||
|
steps:
|
||||||
|
- run: apt update
|
||||||
|
- name: Install toolchain
|
||||||
|
run: apt install --no-install-recommends -y gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu make
|
||||||
|
- name: Install dependencies
|
||||||
|
run: apt install -y libelf-dev
|
||||||
|
- name: Clone repository
|
||||||
|
run: git clone https://git.m724.eu/Minecon724/crisc .
|
||||||
|
- name: Package for x86_64
|
||||||
|
run: CC=x86_64-linux-gnu-gcc PROGRAM_NAME=crisc-x86_64 make
|
||||||
|
- name: Package for aarch64
|
||||||
|
run: CC=aarch64-linux-gnu-gcc PROGRAM_NAME=crisc-aarch64 make
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: https://github.com/actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
path: build/criscv-*
|
28
Makefile
28
Makefile
|
@ -1,24 +1,13 @@
|
||||||
# Compiler to use
|
# Compiler to use
|
||||||
CC := gcc
|
CC ?= gcc
|
||||||
|
|
||||||
# Compiler flags:
|
BASE_CFLAGS := -Wall -Wextra -std=gnu23 -I include
|
||||||
# -Wall: Enable all warnings
|
|
||||||
# -Wextra: Enable extra warnings
|
|
||||||
# -std=gnu23: Use GNU C23 standard
|
|
||||||
# -I include: Add 'include' directory to the include path
|
|
||||||
# -O3: Optimize code (level 3)
|
|
||||||
# -Wno-unused-variable: Disable warnings for unused variables
|
|
||||||
ifeq ($(DEBUG),1)
|
|
||||||
CFLAGS := -Wall -Wextra -std=gnu23 -I include -O0 -g -lelf
|
|
||||||
else
|
|
||||||
CFLAGS := -Wall -Wextra -std=gnu23 -I include -O3 -lelf
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Directory for build outputs
|
# Directory for build outputs
|
||||||
BUILD_DIR := build
|
BUILD_DIR := build
|
||||||
|
|
||||||
# Name of the output program
|
# Name of the output program
|
||||||
PROGRAM_NAME := criscv
|
PROGRAM_NAME ?= criscv
|
||||||
|
|
||||||
# Find all .c files in the source directory
|
# Find all .c files in the source directory
|
||||||
SRCS := $(wildcard src/*.c)
|
SRCS := $(wildcard src/*.c)
|
||||||
|
@ -30,12 +19,17 @@ OBJS := $(patsubst src/%.c,$(BUILD_DIR)/obj/%.o,$(SRCS))
|
||||||
TARGET := $(BUILD_DIR)/$(PROGRAM_NAME)
|
TARGET := $(BUILD_DIR)/$(PROGRAM_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
# Default target: build the executable
|
||||||
|
all: CFLAGS := $(BASE_CFLAGS) -O3 -lelf
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
# Debug target
|
||||||
|
debug: CFLAGS := $(BASE_CFLAGS) -O0 -g -lelf
|
||||||
|
debug: $(TARGET)
|
||||||
|
|
||||||
# Declare 'all' and 'clean' as phony targets (not files)
|
# Declare 'all' and 'clean' as phony targets (not files)
|
||||||
.PHONY: all clean
|
.PHONY: all debug static clean
|
||||||
|
|
||||||
# Default target: build the executable
|
|
||||||
all: $(TARGET)
|
|
||||||
|
|
||||||
# Rule to link object files into the final executable
|
# Rule to link object files into the final executable
|
||||||
$(TARGET): $(OBJS) | $(BUILD_DIR)
|
$(TARGET): $(OBJS) | $(BUILD_DIR)
|
||||||
|
|
Loading…
Reference in a new issue