Skip to content

Commit

Permalink
libs: refine Makefile rules
Browse files Browse the repository at this point in the history
Refine Makefile rules to support the KATA ci env.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
  • Loading branch information
jiangliu committed Jan 6, 2022
1 parent d1caf52 commit d16bcf8
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/static-checks.yaml
Expand Up @@ -80,6 +80,12 @@ jobs:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }}
run: |
cd ${GOPATH}/src/github.com/${{ github.repository }} && make vendor
- name: Check rust libraries
run:
make -C ${{ runner.workspace }}/kata-containers/src/github.com/${{ github.repository }}/src/libs check
- name: Run unit tests for rust libraries
run:
sudo -E PATH="$PATH" make -C ${{ runner.workspace }}/kata-containers/src/github.com/${{ github.repository }}/src/libs test
- name: Static Checks
if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }}
run: |
Expand Down
7 changes: 1 addition & 6 deletions Makefile
Expand Up @@ -6,6 +6,7 @@
# List of available components
COMPONENTS =

COMPONENTS += libs
COMPONENTS += agent
COMPONENTS += runtime

Expand All @@ -19,11 +20,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

Expand All @@ -44,5 +40,4 @@ static-checks: build
binary-tarball \
default \
install-binary-tarball \
libs-crate-tests \
static-checks
6 changes: 1 addition & 5 deletions src/agent/Makefile
Expand Up @@ -101,10 +101,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): $(SOURCES) | show-summary
@RUSTFLAGS="$(EXTRA_RUSTFLAGS) --deny warnings" cargo build --target $(TRIPLE) --$(BUILD_TYPE) $(EXTRA_RUSTFEATURES)
Expand Down Expand Up @@ -208,7 +205,6 @@ codecov-html: check_tarpaulin

.PHONY: \
help \
libs-crate-tests \
optimize \
show-header \
show-summary \
Expand Down
39 changes: 30 additions & 9 deletions src/libs/Makefile
Expand Up @@ -3,16 +3,37 @@
# 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 :=

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 --target $(TRIPLE) $(EXTRA_RUSTFEATURES) -- --nocapture
@echo "INFO: testing libraries for release build"
cargo test --release --all --target $(TRIPLE) $(EXTRA_RUSTFEATURES) -- --nocapture

vendor:
# cargo vendor

.PHONY: install
3 changes: 2 additions & 1 deletion src/libs/sys-util-rs/src/cgroup.rs
Expand Up @@ -519,7 +519,8 @@ mod tests {
// new cgroup
let cgroup = create_or_load_cgroup(cg_path).unwrap();
let cpus: &cgroups::cpuset::CpuSetController = cgroup.controller_of().unwrap();
let path = format!("/sys/fs/cgroup/cpuset/{}/cpuset.cpus", cg_path);
//let path = format!("/sys/fs/cgroup/cpuset/{}/cpuset.cpus", cg_path);
let path = format!("/sys/fs/cgroup/cpuset");
Path::new(&path).canonicalize().unwrap();
assert_eq!(&path, "");
cpus.set_cpus("0-1").unwrap();
Expand Down
6 changes: 1 addition & 5 deletions src/tools/agent-ctl/Makefile
Expand Up @@ -7,12 +7,9 @@ include ../../../utils.mk

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

Expand All @@ -31,6 +28,5 @@ check:
check \
clean \
install \
libs-crate-tests \
test \
vendor
6 changes: 1 addition & 5 deletions src/tools/trace-forwarder/Makefile
Expand Up @@ -7,12 +7,9 @@ include ../../../utils.mk

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

Expand All @@ -31,6 +28,5 @@ check:
check \
clean \
install \
libs-crate-tests \
test \
vendor

0 comments on commit d16bcf8

Please sign in to comment.