2024-01-03 06:40:54 +00:00
|
|
|
# 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
|
2023-10-26 03:27:35 +00:00
|
|
|
AUTO_TEST ?= none
|
2023-10-08 09:38:24 +00:00
|
|
|
BOOT_METHOD ?= qemu-grub
|
|
|
|
|
BOOT_PROTOCOL ?= multiboot2
|
2023-08-02 11:08:02 +00:00
|
|
|
BUILD_SYSCALL_TEST ?= 0
|
|
|
|
|
EMULATE_IOMMU ?= 0
|
|
|
|
|
ENABLE_KVM ?= 1
|
2023-08-09 03:40:00 +00:00
|
|
|
GDB_CLIENT ?= 0
|
|
|
|
|
GDB_SERVER ?= 0
|
2023-09-10 11:23:53 +00:00
|
|
|
INTEL_TDX ?= 0
|
2023-11-08 15:59:23 +00:00
|
|
|
KTEST ?= 0
|
|
|
|
|
KTEST_CRATES ?= all
|
|
|
|
|
KTEST_WHITELIST ?=
|
2023-10-23 10:58:40 +00:00
|
|
|
SKIP_GRUB_MENU ?= 1
|
2023-11-28 04:17:42 +00:00
|
|
|
SYSCALL_TEST_DIR ?= /tmp
|
2023-11-02 06:09:37 +00:00
|
|
|
RELEASE_MODE ?= 0
|
2023-10-26 03:27:35 +00:00
|
|
|
# End of setting up Make varaiables
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2023-12-20 08:27:14 +00:00
|
|
|
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
|
2023-10-23 10:58:40 +00:00
|
|
|
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
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
2023-11-02 09:37:21 +00:00
|
|
|
ifeq ($(AUTO_TEST), regression)
|
|
|
|
|
INIT_CMDLINE += /regression/run_regression_test.sh
|
|
|
|
|
endif
|
2023-10-26 03:27:35 +00:00
|
|
|
ifeq ($(AUTO_TEST), boot)
|
2023-11-08 15:59:23 +00:00
|
|
|
INIT_CMDLINE += -c exit 0
|
2023-10-23 10:58:40 +00:00
|
|
|
endif
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2023-09-10 11:23:53 +00:00
|
|
|
CARGO_KBUILD_ARGS :=
|
2023-11-04 08:41:30 +00:00
|
|
|
CARGO_KRUN_ARGS :=
|
|
|
|
|
GLOBAL_RUSTC_FLAGS :=
|
2023-08-02 11:08:02 +00:00
|
|
|
|
2023-11-02 06:09:37 +00:00
|
|
|
ifeq ($(RELEASE_MODE), 1)
|
|
|
|
|
CARGO_KBUILD_ARGS += --release
|
|
|
|
|
CARGO_KRUN_ARGS += --release
|
|
|
|
|
endif
|
|
|
|
|
|
2024-01-28 06:54:38 +00:00
|
|
|
ifeq ($(INTEL_TDX), 1)
|
|
|
|
|
CARGO_KBUILD_ARGS += --features intel_tdx
|
|
|
|
|
CARGO_KRUN_ARGS += --features intel_tdx
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
RUNNER_ARGS := '$(KERNEL_CMDLINE) -- $(INIT_CMDLINE)'
|
|
|
|
|
RUNNER_ARGS += --boot-method="$(BOOT_METHOD)"
|
|
|
|
|
RUNNER_ARGS += --boot-protocol="$(BOOT_PROTOCOL)"
|
2023-08-09 03:40:00 +00:00
|
|
|
|
|
|
|
|
ifeq ($(EMULATE_IOMMU), 1)
|
2024-01-28 06:54:38 +00:00
|
|
|
RUNNER_ARGS += --emulate-iommu
|
2023-09-10 11:23:53 +00:00
|
|
|
endif
|
|
|
|
|
|
2023-08-02 11:08:02 +00:00
|
|
|
ifeq ($(ENABLE_KVM), 1)
|
2024-01-28 06:54:38 +00:00
|
|
|
RUNNER_ARGS += --enable-kvm
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
ifeq ($(GDB_SERVER), 1)
|
|
|
|
|
ENABLE_KVM := 0
|
2024-01-28 06:54:38 +00:00
|
|
|
RUNNER_ARGS += --halt-for-gdb
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
ifeq ($(GDB_CLIENT), 1)
|
2024-01-28 06:54:38 +00:00
|
|
|
RUNNER_ARGS += --run-gdb-client
|
2023-08-09 03:40:00 +00:00
|
|
|
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
|
|
|
|
|
|
2023-08-09 03:40:00 +00:00
|
|
|
ifeq ($(SKIP_GRUB_MENU), 1)
|
2024-01-28 06:54:38 +00:00
|
|
|
RUNNER_ARGS += --skip-grub-menu
|
2023-08-02 11:08:02 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Pass make variables to all subdirectory makes
|
|
|
|
|
export
|
|
|
|
|
|
2023-10-08 09:38:24 +00:00
|
|
|
# Toolchain variables that are used when building the Linux setup header
|
2023-10-06 14:08:20 +00:00
|
|
|
export CARGO := cargo
|
2023-08-09 03:40:00 +00:00
|
|
|
|
2023-11-06 07:42:26 +00:00
|
|
|
# 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 \
|
2023-11-06 07:42:26 +00:00
|
|
|
framework/libs/ktest \
|
2023-11-08 15:59:23 +00:00
|
|
|
framework/libs/ktest-proc-macro \
|
2023-11-06 07:42:26 +00:00
|
|
|
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 \
|
2023-11-06 07:42:26 +00:00
|
|
|
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
|
2024-01-28 06:54:38 +00:00
|
|
|
@RUSTFLAGS="$(GLOBAL_RUSTC_FLAGS)" cargo krun $(CARGO_KRUN_ARGS) -- $(RUNNER_ARGS)
|
2023-07-26 07:36:40 +00:00
|
|
|
|
2023-11-04 08:41:30 +00:00
|
|
|
test:
|
2023-11-06 07:42:26 +00:00
|
|
|
@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
|
|
|
|
2024-02-25 14:03:54 +00:00
|
|
|
format:
|
|
|
|
|
./tools/format_all.sh
|
|
|
|
|
|
2022-08-08 23:02:55 +00:00
|
|
|
check:
|
2024-02-25 14:03:54 +00:00
|
|
|
./tools/format_all.sh --check # Check Rust format issues
|
2023-09-04 03:04:42 +00:00
|
|
|
@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
|