Skip to content

Commit

Permalink
Add config option of architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjian85 committed Jul 3, 2024
1 parent 7b5e13d commit 90b46a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
32 changes: 20 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
cmake_minimum_required(VERSION 3.29)
project(karg C ASM)

if (NOT ARCH)
set(ARCH RISCV)
endif()

if (NOT PLATFORM)
set (PLATFORM VIRT)
set(PLATFORM VIRT)
endif()

add_executable(karg
src/arch
src/arch/riscv/entry.S
src/arch/riscv/intr.c
src/arch/riscv/pm.c
src/arch/riscv/proc.c
src/arch/riscv/proc.S
src/arch/riscv/sbi.c
src/arch/riscv/time.c
src/arch/riscv/timer.c
src/arch/riscv/trap.c
src/arch/riscv/trap.S
src/dev.c
src/drivers/ldisc.c
src/drivers/plic.c
Expand Down Expand Up @@ -49,6 +42,21 @@ add_executable(karg
src/utils/str.c
)

if (ARCH STREQUAL RISCV)
target_sources(karg PRIVATE
src/arch/riscv/entry.S
src/arch/riscv/intr.c
src/arch/riscv/pm.c
src/arch/riscv/proc.c
src/arch/riscv/proc.S
src/arch/riscv/sbi.c
src/arch/riscv/time.c
src/arch/riscv/timer.c
src/arch/riscv/trap.c
src/arch/riscv/trap.S
)
endif()

if (PLATFORM STREQUAL VIRT)
target_sources(karg PRIVATE
src/platforms/virt.c
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build:
@cmake \
-B build \
-D CMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_FILE) \
-D ARCH=$(ARCH) \
-D PLATFORM=$(PLATFORM)

FORCE:
Expand Down

0 comments on commit 90b46a9

Please sign in to comment.