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 vsock kmod vm
23
24 all: vsock echo_server
25
26 check: vsock echo_server 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 vsock: $(SRCS)
41 cargo build --lib
42
43 echo_server: vsock echo_server/src/main.rs
44 cargo build --manifest-path=echo_server/Cargo.toml
45
46 # Set up required host kernel modules
47 kmod:
48 sudo /sbin/modprobe -r vmw_vsock_vmci_transport
49 sudo /sbin/modprobe -r vmw_vsock_virtio_transport_common
50 sudo /sbin/modprobe -r vsock
51 sudo /sbin/modprobe vhost_vsock
52
53 # Start a virtio socket enabled vm
54 vm: initrd.cpio
55 sudo qemu-system-x86_64 -kernel test_fixture/bzImage -initrd target/$(TOOLCHAIN)/debug/initrd.cpio \
56 -enable-kvm -m 256 -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3 -nographic -append "console=ttyS0"
57
58 # Start a virtio socket enabled vm in background
59 vm-for-action: initrd.cpio
60 sudo qemu-system-x86_64 -kernel test_fixture/bzImage -initrd target/$(TOOLCHAIN)/debug/initrd.cpio \
61 -m 256 -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3 -display none -daemonize -append "console=ttyS0"
62
63 # Create a simple operating system image for the vm
64 initrd.cpio: echo_server
65 -rm -f target/$(TOOLCHAIN)/debug/initrd.cpio
66 mkdir -p /tmp/$(ID)
67 cp test_fixture/busybox.cpio /tmp/$(ID)/initrd.cpio
68 cp test_fixture/init /tmp/$(ID)/init
69 cp echo_server/target/$(TOOLCHAIN)/debug/echo_server /tmp/$(ID)/
70 (cd '/tmp/$(ID)' && find . | grep -v 'initrd.cpio' | cpio -H newc -o --append -F initrd.cpio)
71 mv /tmp/$(ID)/initrd.cpio target/$(TOOLCHAIN)/debug/
72 rm -Rf /tmp/$(ID)