Put .PHONY notations near targets

This commit is contained in:
Ruihan Li
2024-02-23 11:50:27 +08:00
committed by Tate, Hongliang Tian
parent e92cbd0e28
commit 26d17704bf
6 changed files with 26 additions and 16 deletions

View File

@ -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

View File

@ -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)

View File

@ -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); \

View File

@ -1,6 +1,5 @@
# SPDX-License-Identifier: MPL-2.0
.PHONY: all
all: ./*.sh
@cp ./*.sh $(BUILD_DIR)

View File

@ -14,7 +14,6 @@ CC := gcc
C_FLAGS :=
.PHONY: all
all: $(OBJ_OUTPUT_DIR) $(C_OBJS) $(ASM_OBJS)
$(OBJ_OUTPUT_DIR):

View File

@ -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)