diff --git a/Makefile b/Makefile index 0ca42a509..7411a4c29 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ # List of available components COMPONENTS = +COMPONENTS += libs COMPONENTS += agent COMPONENTS += runtime @@ -21,11 +22,6 @@ STANDARD_TARGETS = build check clean install test vendor default: all -all: libs-crate-tests build - -libs-crate-tests: - make -C src/libs - include utils.mk include ./tools/packaging/kata-deploy/local-build/Makefile @@ -49,7 +45,6 @@ docs-url-alive-check: binary-tarball \ default \ install-binary-tarball \ - libs-crate-tests \ static-checks \ docs-url-alive-check diff --git a/src/agent/Makefile b/src/agent/Makefile index 6c09b5dfa..0a537aa55 100644 --- a/src/agent/Makefile +++ b/src/agent/Makefile @@ -107,10 +107,7 @@ endef ##TARGET default: build code default: $(TARGET) show-header -$(TARGET): $(GENERATED_CODE) libs-crate-tests $(TARGET_PATH) - -libs-crate-tests: - make -C $(CWD)/../libs +$(TARGET): $(GENERATED_CODE) $(TARGET_PATH) $(TARGET_PATH): show-summary @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) $(EXTRA_RUSTFEATURES) @@ -203,7 +200,6 @@ codecov-html: check_tarpaulin .PHONY: \ help \ - libs-crate-tests \ optimize \ show-header \ show-summary \ diff --git a/src/libs/Makefile b/src/libs/Makefile index 74c917ab8..9ce0be19d 100644 --- a/src/libs/Makefile +++ b/src/libs/Makefile @@ -3,16 +3,40 @@ # SPDX-License-Identifier: Apache-2.0 # -# It is not necessary to have a build target as this crate is built -# automatically by the consumers of it. -# -# However, it is essential that the crate be tested. -default: test +EXTRA_RUSTFEATURES := + +EXTRA_TEST_FLAGS := +USERID=$(shell id -u) +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. # See the `test_logger_levels()` test for further information. test: - @echo "INFO: testing log levels for development build" - @cargo test - @echo "INFO: testing log levels for release build" - @cargo test --release + @echo "INFO: testing libraries for development build" + cargo test --all $(EXTRA_RUSTFEATURES) -- --nocapture $(EXTRA_TEST_FLAGS) + @echo "INFO: testing libraries for release build" + cargo test --release --all $(EXTRA_RUSTFEATURES) -- --nocapture $(EXTRA_TEST_FLAGS) + +.PHONY: install vendor diff --git a/src/tools/agent-ctl/Makefile b/src/tools/agent-ctl/Makefile index b020563db..99713f6c8 100644 --- a/src/tools/agent-ctl/Makefile +++ b/src/tools/agent-ctl/Makefile @@ -8,12 +8,9 @@ include ../../../utils.mk .DEFAULT_GOAL := default default: build -build: libs-crate-tests +build: @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) -libs-crate-tests: - make -C $(CWD)/../../libs - clean: cargo clean @@ -32,6 +29,5 @@ check: standard_rust_check check \ clean \ install \ - libs-crate-tests \ test \ vendor diff --git a/src/tools/trace-forwarder/Makefile b/src/tools/trace-forwarder/Makefile index f597f891f..b6b223c00 100644 --- a/src/tools/trace-forwarder/Makefile +++ b/src/tools/trace-forwarder/Makefile @@ -8,12 +8,9 @@ include ../../../utils.mk .DEFAULT_GOAL := default default: build -build: libs-crate-tests +build: @RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) -libs-crate-tests: - make -C $(CWD)/../../libs - clean: cargo clean @@ -32,6 +29,5 @@ check: standard_rust_check check \ clean \ install \ - libs-crate-tests \ test \ vendor