libs: refine Makefile rules

Refine Makefile rules to better support the KATA ci env.

Fixes: #3536

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
Liu Jiang 2022-01-06 14:52:59 +08:00 committed by Fupan Li
parent 7cdee4980c
commit 6f8acb94c2
5 changed files with 37 additions and 30 deletions

View File

@ -6,6 +6,7 @@
# List of available components # List of available components
COMPONENTS = COMPONENTS =
COMPONENTS += libs
COMPONENTS += agent COMPONENTS += agent
COMPONENTS += runtime COMPONENTS += runtime
@ -21,11 +22,6 @@ STANDARD_TARGETS = build check clean install test vendor
default: all default: all
all: libs-crate-tests build
libs-crate-tests:
make -C src/libs
include utils.mk include utils.mk
include ./tools/packaging/kata-deploy/local-build/Makefile include ./tools/packaging/kata-deploy/local-build/Makefile
@ -49,7 +45,6 @@ docs-url-alive-check:
binary-tarball \ binary-tarball \
default \ default \
install-binary-tarball \ install-binary-tarball \
libs-crate-tests \
static-checks \ static-checks \
docs-url-alive-check docs-url-alive-check

View File

@ -107,10 +107,7 @@ endef
##TARGET default: build code ##TARGET default: build code
default: $(TARGET) show-header default: $(TARGET) show-header
$(TARGET): $(GENERATED_CODE) libs-crate-tests $(TARGET_PATH) $(TARGET): $(GENERATED_CODE) $(TARGET_PATH)
libs-crate-tests:
make -C $(CWD)/../libs
$(TARGET_PATH): show-summary $(TARGET_PATH): show-summary
@RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) $(EXTRA_RUSTFEATURES) @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) $(EXTRA_RUSTFEATURES)
@ -203,7 +200,6 @@ codecov-html: check_tarpaulin
.PHONY: \ .PHONY: \
help \ help \
libs-crate-tests \
optimize \ optimize \
show-header \ show-header \
show-summary \ show-summary \

View File

@ -3,16 +3,40 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
# It is not necessary to have a build target as this crate is built EXTRA_RUSTFEATURES :=
# automatically by the consumers of it.
# EXTRA_TEST_FLAGS :=
# However, it is essential that the crate be tested. USERID=$(shell id -u)
default: test ifeq ($(USERID), 0)
override EXTRA_TEST_FLAGS = --ignored
endif
default: build
build:
cargo build --all-features
check: clippy format
clippy:
@echo "INFO: cargo clippy..."
cargo clippy --all-targets --all-features --release \
-- \
-D warnings
format:
@echo "INFO: cargo fmt..."
cargo fmt -- --check
clean:
cargo clean
# It is essential to run these tests using *both* build profiles. # It is essential to run these tests using *both* build profiles.
# See the `test_logger_levels()` test for further information. # See the `test_logger_levels()` test for further information.
test: test:
@echo "INFO: testing log levels for development build" @echo "INFO: testing libraries for development build"
@cargo test cargo test --all $(EXTRA_RUSTFEATURES) -- --nocapture $(EXTRA_TEST_FLAGS)
@echo "INFO: testing log levels for release build" @echo "INFO: testing libraries for release build"
@cargo test --release cargo test --release --all $(EXTRA_RUSTFEATURES) -- --nocapture $(EXTRA_TEST_FLAGS)
.PHONY: install vendor

View File

@ -8,12 +8,9 @@ include ../../../utils.mk
.DEFAULT_GOAL := default .DEFAULT_GOAL := default
default: build default: build
build: libs-crate-tests build:
@RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE)
libs-crate-tests:
make -C $(CWD)/../../libs
clean: clean:
cargo clean cargo clean
@ -32,6 +29,5 @@ check: standard_rust_check
check \ check \
clean \ clean \
install \ install \
libs-crate-tests \
test \ test \
vendor vendor

View File

@ -8,12 +8,9 @@ include ../../../utils.mk
.DEFAULT_GOAL := default .DEFAULT_GOAL := default
default: build default: build
build: libs-crate-tests build:
@RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE)
libs-crate-tests:
make -C $(CWD)/../../libs
clean: clean:
cargo clean cargo clean
@ -32,6 +29,5 @@ check: standard_rust_check
check \ check \
clean \ clean \
install \ install \
libs-crate-tests \
test \ test \
vendor vendor