asterinas/Makefile

144 lines
3.6 KiB
Makefile
Raw Normal View History

# SPDX-License-Identifier: MPL-2.0
2023-12-25 03:31:06 +00:00
# Make varaiables and defaults, you should refer to aster-runner for more details
AUTO_TEST ?= none
BOOT_METHOD ?= qemu-grub
BOOT_PROTOCOL ?= multiboot2
BUILD_SYSCALL_TEST ?= 0
EMULATE_IOMMU ?= 0
ENABLE_KVM ?= 1
GDB_CLIENT ?= 0
GDB_SERVER ?= 0
INTEL_TDX ?= 0
2023-11-08 15:59:23 +00:00
KTEST ?= 0
KTEST_CRATES ?= all
KTEST_WHITELIST ?=
SKIP_GRUB_MENU ?= 1
2023-11-28 04:17:42 +00:00
SYSCALL_TEST_DIR ?= /tmp
RELEASE_MODE ?= 0
# End of setting up Make varaiables
KERNEL_CMDLINE := SHELL="/bin/sh" LOGNAME="root" HOME="/" USER="root" PATH="/bin:/benchmark" init=/usr/bin/busybox
2023-11-08 15:59:23 +00:00
KERNEL_CMDLINE += ktest.whitelist="$(KTEST_WHITELIST)"
INIT_CMDLINE := sh -l
ifeq ($(AUTO_TEST), syscall)
BUILD_SYSCALL_TEST := 1
2023-11-28 04:17:42 +00:00
KERNEL_CMDLINE += SYSCALL_TEST_DIR=$(SYSCALL_TEST_DIR)
2023-11-08 15:59:23 +00:00
INIT_CMDLINE += /opt/syscall_test/run_syscall_test.sh
endif
2023-11-02 09:37:21 +00:00
ifeq ($(AUTO_TEST), regression)
INIT_CMDLINE += /regression/run_regression_test.sh
endif
ifeq ($(AUTO_TEST), boot)
2023-11-08 15:59:23 +00:00
INIT_CMDLINE += -c exit 0
endif
CARGO_KBUILD_ARGS :=
2023-11-04 08:41:30 +00:00
CARGO_KRUN_ARGS :=
GLOBAL_RUSTC_FLAGS :=
ifeq ($(RELEASE_MODE), 1)
CARGO_KBUILD_ARGS += --release
CARGO_KRUN_ARGS += --release
endif
2023-11-08 15:59:23 +00:00
CARGO_KRUN_ARGS += -- '$(KERNEL_CMDLINE) -- $(INIT_CMDLINE)'
CARGO_KRUN_ARGS += --boot-method="$(BOOT_METHOD)"
CARGO_KRUN_ARGS += --boot-protocol="$(BOOT_PROTOCOL)"
ifeq ($(EMULATE_IOMMU), 1)
CARGO_KRUN_ARGS += --emulate-iommu
endif
ifeq ($(ENABLE_KVM), 1)
CARGO_KRUN_ARGS += --enable-kvm
endif
ifeq ($(GDB_SERVER), 1)
ENABLE_KVM := 0
CARGO_KRUN_ARGS += --halt-for-gdb
endif
ifeq ($(GDB_CLIENT), 1)
CARGO_KRUN_ARGS += --run-gdb-client
2023-08-27 12:17:32 +00:00
endif
ifeq ($(INTEL_TDX), 1)
CARGO_KBUILD_ARGS += --features intel_tdx
CARGO_KRUN_ARGS += --features intel_tdx
endif
2023-11-08 15:59:23 +00:00
ifeq ($(KTEST), 1)
2023-11-04 08:41:30 +00:00
comma := ,
2023-11-08 15:59:23 +00:00
GLOBAL_RUSTC_FLAGS += --cfg ktest --cfg ktest=\"$(subst $(comma),\" --cfg ktest=\",$(KTEST_CRATES))\"
2023-11-04 08:41:30 +00:00
endif
ifeq ($(SKIP_GRUB_MENU), 1)
CARGO_KRUN_ARGS += --skip-grub-menu
endif
# Pass make variables to all subdirectory makes
export
# Toolchain variables that are used when building the Linux setup header
export CARGO := cargo
# Maintain a list of usermode crates that can be tested with `cargo test`
USERMODE_TESTABLE := \
runner \
framework/libs/align_ext \
2023-12-29 07:32:06 +00:00
framework/libs/linux-bzimage/builder \
framework/libs/linux-bzimage/boot-params \
framework/libs/ktest \
2023-11-08 15:59:23 +00:00
framework/libs/ktest-proc-macro \
services/libs/cpio-decoder \
services/libs/int-to-c-enum \
services/libs/int-to-c-enum/derive \
2023-12-25 03:12:25 +00:00
services/libs/aster-rights \
services/libs/aster-rights-proc \
services/libs/keyable-arc \
services/libs/typeflags \
services/libs/typeflags-util
2023-12-28 09:24:23 +00:00
.PHONY: all setup build tools run test docs check clean update_initramfs
2022-08-08 22:43:47 +00:00
2023-04-10 03:12:42 +00:00
all: build
2022-08-08 22:43:47 +00:00
2022-08-17 03:22:49 +00:00
setup:
@rustup component add rust-src
2023-02-07 08:05:21 +00:00
@rustup component add rustc-dev
2022-08-17 03:22:49 +00:00
@rustup component add llvm-tools-preview
@cargo install mdbook
2022-08-08 22:43:47 +00:00
build:
2023-05-29 05:29:53 +00:00
@make --no-print-directory -C regression
2023-11-04 08:41:30 +00:00
@RUSTFLAGS="$(GLOBAL_RUSTC_FLAGS)" cargo kbuild $(CARGO_KBUILD_ARGS)
2023-08-07 02:56:03 +00:00
2023-02-07 08:05:21 +00:00
tools:
2023-04-10 03:12:42 +00:00
@cd services/libs/comp-sys && cargo install --path cargo-component
2023-02-07 08:05:21 +00:00
2022-08-17 03:22:49 +00:00
run: build
2023-11-04 08:41:30 +00:00
@RUSTFLAGS="$(GLOBAL_RUSTC_FLAGS)" cargo krun $(CARGO_KRUN_ARGS)
2023-11-04 08:41:30 +00:00
test:
@for dir in $(USERMODE_TESTABLE); do \
(cd $$dir && cargo test) || exit 1; \
done
2022-08-08 22:43:47 +00:00
docs:
2023-04-10 03:12:42 +00:00
@cargo doc # Build Rust docs
2022-08-08 22:43:47 +00:00
@echo "" # Add a blank line
2022-08-08 23:02:55 +00:00
@cd docs && mdbook build # Build mdBook
2022-08-08 22:43:47 +00:00
2022-08-08 23:02:55 +00:00
check:
2023-09-04 03:04:42 +00:00
@cargo fmt --check # Check Rust format issues
@cargo kclippy -- -D warnings # Make build fail if any warnings are found by rustc and clippy
2022-08-08 22:43:47 +00:00
clean:
2023-04-10 03:12:42 +00:00
@cargo clean
2022-08-17 03:22:49 +00:00
@cd docs && mdbook clean
2023-05-29 05:29:53 +00:00
@make --no-print-directory -C regression clean
2023-12-28 09:24:23 +00:00
update_initramfs:
@make --no-print-directory -C regression clean
@make --no-print-directory -C regression