From 26d17704bf6b5feaa071bdf1d19e8b788686f7ac Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Fri, 23 Feb 2024 11:50:27 +0800 Subject: [PATCH] Put `.PHONY` notations near targets --- Makefile | 28 ++++++++++++++++++++-------- regression/Makefile | 5 +++-- regression/apps/Makefile | 1 - regression/apps/scripts/Makefile | 3 +-- regression/apps/test_common.mk | 1 - regression/syscall_test/Makefile | 4 ++-- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 11f38fabe..9b8d8b6d6 100644 --- a/Makefile +++ b/Makefile @@ -100,12 +100,12 @@ OSDK_CRATES := \ kernel/comps/virtio \ kernel/libs/aster-util -.PHONY: all build tools run test docs check clean update_initramfs install_osdk - +.PHONY: all all: build # Install or update OSDK from source # To uninstall, do `cargo uninstall cargo-osdk` +.PHONY: install_osdk install_osdk: @cargo install cargo-osdk --path osdk @@ -118,38 +118,48 @@ build: $(CARGO_ODSK) @make --no-print-directory -C regression @cd kernel && cargo osdk build $(CARGO_OSDK_ARGS) +.PHONY: tools tools: @cd kernel/libs/comp-sys && cargo install --path cargo-component +.PHONY: run run: build @cd kernel && cargo osdk run $(CARGO_OSDK_ARGS) +.PHONY: test test: @for dir in $(NON_OSDK_CRATES); do \ (cd $$dir && cargo test) || exit 1; \ done -ktest: $(CARGO_ODSK) +.PHONY: ktest +ktest: $(CARGO_OSDK) @# Exclude linux-bzimage-setup from ktest since it's hard to be unit tested @for dir in $(OSDK_CRATES); do \ [ $$dir = "framework/libs/linux-bzimage/setup" ] && continue; \ (cd $$dir && cargo osdk test) || exit 1; \ done +.PHONY: docs docs: - @cargo doc # Build Rust docs - @echo "" # Add a blank line + @cargo doc # Build Rust docs + @echo "" # Add a blank line @cd docs && mdbook build # Build mdBook +.PHONY: format format: @./tools/format_all.sh -check: $(CARGO_ODSK) +.PHONY: check +check: $(CARGO_OSDK) @./tools/format_all.sh --check # Check Rust format issues @# Check if STD_CRATES and NOSTD_CRATES combined is the same as all workspace members - @sed -n '/^\[workspace\]/,/^\[.*\]/{/members = \[/,/\]/p}' Cargo.toml | grep -v "members = \[" | tr -d '", \]' | sort > /tmp/all_crates + @sed -n '/^\[workspace\]/,/^\[.*\]/{/members = \[/,/\]/p}' Cargo.toml | \ + grep -v "members = \[" | tr -d '", \]' | \ + sort > /tmp/all_crates @echo $(NON_OSDK_CRATES) $(OSDK_CRATES) | tr ' ' '\n' | sort > /tmp/combined_crates - @diff -B /tmp/all_crates /tmp/combined_crates || (echo "Error: STD_CRATES and NOSTD_CRATES combined is not the same as all workspace members" && exit 1) + @diff -B /tmp/all_crates /tmp/combined_crates || \ + (echo "Error: STD_CRATES and NOSTD_CRATES combined is not the same as all workspace members" && exit 1) @rm /tmp/all_crates /tmp/combined_crates @for dir in $(NON_OSDK_CRATES); do \ (cd $$dir && cargo clippy -- -D warnings) || exit 1; \ @@ -158,11 +168,13 @@ check: $(CARGO_ODSK) (cd $$dir && cargo osdk clippy) || exit 1; \ done +.PHONY: clean clean: @cargo clean @cd docs && mdbook clean @make --no-print-directory -C regression clean +.PHONY: update_initramfs update_initramfs: @make --no-print-directory -C regression clean @make --no-print-directory -C regression diff --git a/regression/Makefile b/regression/Makefile index 341e24b28..26c8b18c3 100644 --- a/regression/Makefile +++ b/regression/Makefile @@ -26,8 +26,7 @@ INITRAMFS_ALL_DIRS := \ $(INITRAMFS)/benchmark \ $(INITRAMFS_EMPTY_DIRS) -.PHONY: all clean - +.PHONY: all all: build $(INITRAMFS)/lib/x86_64-linux-gnu: $(VDSO_DIR) @@ -100,7 +99,9 @@ $(EXT2_IMAGE): @dd if=/dev/zero of=$(EXT2_IMAGE) bs=2G count=1 @mke2fs $(EXT2_IMAGE) +.PHONY: build build: $(INITRAMFS_IMAGE) $(EXT2_IMAGE) +.PHONY: clean clean: @rm -rf $(BUILD_DIR) diff --git a/regression/apps/Makefile b/regression/apps/Makefile index 9f616d284..ebca80147 100644 --- a/regression/apps/Makefile +++ b/regression/apps/Makefile @@ -8,7 +8,6 @@ REGRESSION_BUILD_DIR ?= $(INITRAMFS)/regression TEST_APPS := signal_c pthread network hello_world hello_pie hello_c fork_c fork execve pty .PHONY: all - all: @mkdir -p $(REGRESSION_BUILD_DIR) @for test_app in $(TEST_APPS); \ diff --git a/regression/apps/scripts/Makefile b/regression/apps/scripts/Makefile index 2e1e19d5a..e41e64e0e 100644 --- a/regression/apps/scripts/Makefile +++ b/regression/apps/scripts/Makefile @@ -1,6 +1,5 @@ # SPDX-License-Identifier: MPL-2.0 .PHONY: all - all: ./*.sh - @cp ./*.sh $(BUILD_DIR) \ No newline at end of file + @cp ./*.sh $(BUILD_DIR) diff --git a/regression/apps/test_common.mk b/regression/apps/test_common.mk index e31292967..8799e4f7d 100644 --- a/regression/apps/test_common.mk +++ b/regression/apps/test_common.mk @@ -14,7 +14,6 @@ CC := gcc C_FLAGS := .PHONY: all - all: $(OBJ_OUTPUT_DIR) $(C_OBJS) $(ASM_OBJS) $(OBJ_OUTPUT_DIR): diff --git a/regression/syscall_test/Makefile b/regression/syscall_test/Makefile index a92ee5fd2..df4b3db72 100644 --- a/regression/syscall_test/Makefile +++ b/regression/syscall_test/Makefile @@ -44,8 +44,7 @@ TARGET_DIR := $(INITRAMFS)/opt/syscall_test RUN_BASH := $(CUR_DIR)/run_syscall_test.sh BLOCK_LIST := $(CUR_DIR)/blocklists -.PHONY: all clean - +.PHONY: all all: $(TESTS) $(TESTS): $(BIN_DIR) $(TARGET_DIR) @@ -75,5 +74,6 @@ $(TARGET_DIR): $(RUN_BASH) $(BLOCK_LIST) @# Copy bash script @cp -f $(RUN_BASH) $@ +.PHONY: clean clean: @rm -rf $(TARGET_DIR)