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/comps/virtio \
kernel/libs/aster-util kernel/libs/aster-util
.PHONY: all build tools run test docs check clean update_initramfs install_osdk .PHONY: all
all: build all: build
# Install or update OSDK from source # Install or update OSDK from source
# To uninstall, do `cargo uninstall cargo-osdk` # To uninstall, do `cargo uninstall cargo-osdk`
.PHONY: install_osdk
install_osdk: install_osdk:
@cargo install cargo-osdk --path osdk @cargo install cargo-osdk --path osdk
@ -118,38 +118,48 @@ build: $(CARGO_ODSK)
@make --no-print-directory -C regression @make --no-print-directory -C regression
@cd kernel && cargo osdk build $(CARGO_OSDK_ARGS) @cd kernel && cargo osdk build $(CARGO_OSDK_ARGS)
.PHONY: tools
tools: tools:
@cd kernel/libs/comp-sys && cargo install --path cargo-component @cd kernel/libs/comp-sys && cargo install --path cargo-component
.PHONY: run
run: build run: build
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS) @cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
.PHONY: test
test: test:
@for dir in $(NON_OSDK_CRATES); do \ @for dir in $(NON_OSDK_CRATES); do \
(cd $$dir && cargo test) || exit 1; \ (cd $$dir && cargo test) || exit 1; \
done done
ktest: $(CARGO_ODSK) .PHONY: ktest
ktest: $(CARGO_OSDK)
@# Exclude linux-bzimage-setup from ktest since it's hard to be unit tested @# Exclude linux-bzimage-setup from ktest since it's hard to be unit tested
@for dir in $(OSDK_CRATES); do \ @for dir in $(OSDK_CRATES); do \
[ $$dir = "framework/libs/linux-bzimage/setup" ] && continue; \ [ $$dir = "framework/libs/linux-bzimage/setup" ] && continue; \
(cd $$dir && cargo osdk test) || exit 1; \ (cd $$dir && cargo osdk test) || exit 1; \
done done
.PHONY: docs
docs: docs:
@cargo doc # Build Rust docs @cargo doc # Build Rust docs
@echo "" # Add a blank line @echo "" # Add a blank line
@cd docs && mdbook build # Build mdBook @cd docs && mdbook build # Build mdBook
.PHONY: format
format: format:
@./tools/format_all.sh @./tools/format_all.sh
check: $(CARGO_ODSK) .PHONY: check
check: $(CARGO_OSDK)
@./tools/format_all.sh --check # Check Rust format issues @./tools/format_all.sh --check # Check Rust format issues
@# Check if STD_CRATES and NOSTD_CRATES combined is the same as all workspace members @# 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 @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 @rm /tmp/all_crates /tmp/combined_crates
@for dir in $(NON_OSDK_CRATES); do \ @for dir in $(NON_OSDK_CRATES); do \
(cd $$dir && cargo clippy -- -D warnings) || exit 1; \ (cd $$dir && cargo clippy -- -D warnings) || exit 1; \
@ -158,11 +168,13 @@ check: $(CARGO_ODSK)
(cd $$dir && cargo osdk clippy) || exit 1; \ (cd $$dir && cargo osdk clippy) || exit 1; \
done done
.PHONY: clean
clean: clean:
@cargo clean @cargo clean
@cd docs && mdbook clean @cd docs && mdbook clean
@make --no-print-directory -C regression clean @make --no-print-directory -C regression clean
.PHONY: update_initramfs
update_initramfs: update_initramfs:
@make --no-print-directory -C regression clean @make --no-print-directory -C regression clean
@make --no-print-directory -C regression @make --no-print-directory -C regression

View File

@ -26,8 +26,7 @@ INITRAMFS_ALL_DIRS := \
$(INITRAMFS)/benchmark \ $(INITRAMFS)/benchmark \
$(INITRAMFS_EMPTY_DIRS) $(INITRAMFS_EMPTY_DIRS)
.PHONY: all clean .PHONY: all
all: build all: build
$(INITRAMFS)/lib/x86_64-linux-gnu: $(VDSO_DIR) $(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 @dd if=/dev/zero of=$(EXT2_IMAGE) bs=2G count=1
@mke2fs $(EXT2_IMAGE) @mke2fs $(EXT2_IMAGE)
.PHONY: build
build: $(INITRAMFS_IMAGE) $(EXT2_IMAGE) build: $(INITRAMFS_IMAGE) $(EXT2_IMAGE)
.PHONY: clean
clean: clean:
@rm -rf $(BUILD_DIR) @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 TEST_APPS := signal_c pthread network hello_world hello_pie hello_c fork_c fork execve pty
.PHONY: all .PHONY: all
all: all:
@mkdir -p $(REGRESSION_BUILD_DIR) @mkdir -p $(REGRESSION_BUILD_DIR)
@for test_app in $(TEST_APPS); \ @for test_app in $(TEST_APPS); \

View File

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

View File

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

View File

@ -44,8 +44,7 @@ TARGET_DIR := $(INITRAMFS)/opt/syscall_test
RUN_BASH := $(CUR_DIR)/run_syscall_test.sh RUN_BASH := $(CUR_DIR)/run_syscall_test.sh
BLOCK_LIST := $(CUR_DIR)/blocklists BLOCK_LIST := $(CUR_DIR)/blocklists
.PHONY: all clean .PHONY: all
all: $(TESTS) all: $(TESTS)
$(TESTS): $(BIN_DIR) $(TARGET_DIR) $(TESTS): $(BIN_DIR) $(TARGET_DIR)
@ -75,5 +74,6 @@ $(TARGET_DIR): $(RUN_BASH) $(BLOCK_LIST)
@# Copy bash script @# Copy bash script
@cp -f $(RUN_BASH) $@ @cp -f $(RUN_BASH) $@
.PHONY: clean
clean: clean:
@rm -rf $(TARGET_DIR) @rm -rf $(TARGET_DIR)