Debian Codegraph @

Makefile

raw symbols SCIP
1 # Copyright 2019 fsyncd, Berlin, Germany.
2 # Additional material, copyright of the containerd authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 TOOLCHAIN := x86_64-unknown-linux-musl
17 VPATH = target/system target/$(TOOLCHAIN)/debug target/$(TOOLCHAIN)/release
18
19 SRCS := $(shell find . -type f -name '*.rs' | grep -v 'tests')
20 ID := $(shell date +%s)
21
22 .PHONY: all check clean tokio_vsock kmod vm
23
24 all: fmt clippy tokio_vsock test_server
25
26 check: tokio_vsock test
27
28 test:
29 cargo test --all
30
31 fmt:
32 cargo fmt --all -- --check
33
34 clippy:
35 cargo clippy --all-targets --all-features -- -D warnings
36
37 clean:
38 cargo clean
39
40 tokio_vsock: $(SRCS)
41 cargo build --lib
42
43 tokio_vsock_all_features: $(SRCS)
44 cargo build --lib --all-features
45
46 tokio_vsock_min_deps: $(SRCS)
47 cargo build --lib --all-features -Z direct-minimal-versions
48
49 test_server: tokio_vsock test_server/src/main.rs
50 cargo build --manifest-path=test_server/Cargo.toml
51
52 # Setup required host kernel modules
53 kmod:
54 sudo /sbin/modprobe -r vmw_vsock_vmci_transport
55 sudo /sbin/modprobe -r vmw_vsock_virtio_transport_common
56 sudo /sbin/modprobe -r vsock
57 sudo /sbin/modprobe vhost_vsock
58
59 # Start a Virtio socket enabled vm
60 vm: initrd.cpio
61 sudo qemu-system-x86_64 -kernel test_fixture/bzImage -initrd target/$(TOOLCHAIN)/debug/initrd.cpio \
62 -enable-kvm -m 256 -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3 -nographic -append "console=ttyS0"
63
64 # Create a simple operating system image for the vm
65 initrd.cpio: test_server
66 -rm -f target/$(TOOLCHAIN)/debug/initrd.cpio
67 mkdir -p /tmp/$(ID)
68 cp test_fixture/busybox.cpio /tmp/$(ID)/initrd.cpio
69 cp test_fixture/init /tmp/$(ID)/init
70 cp test_server/target/$(TOOLCHAIN)/debug/test_server /tmp/$(ID)/
71 (cd '/tmp/$(ID)' && find . | grep -v 'initrd.cpio' | cpio -H newc -o --append -F initrd.cpio)
72 mv /tmp/$(ID)/initrd.cpio target/$(TOOLCHAIN)/debug/
73 rm -Rf /tmp/$(ID)