1*7c28051eSlinfengTOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu" 2fae6e9adSlinfengRUSTFLAGS+="" 3fae6e9adSlinfeng 4fae6e9adSlinfengifdef DADK_CURRENT_BUILD_DIR 5fae6e9adSlinfeng# 如果是在dadk中编译,那么安装到dadk的安装目录中 6fae6e9adSlinfeng INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) 7fae6e9adSlinfengelse 8fae6e9adSlinfeng# 如果是在本地编译,那么安装到当前目录下的install目录中 9fae6e9adSlinfeng INSTALL_DIR = ./install 10fae6e9adSlinfengendif 11fae6e9adSlinfeng 12fae6e9adSlinfengifeq ($(ARCH), x86_64) 13fae6e9adSlinfeng export RUST_TARGET=x86_64-unknown-linux-musl 14fae6e9adSlinfengelse ifeq ($(ARCH), riscv64) 15fae6e9adSlinfeng export RUST_TARGET=riscv64gc-unknown-linux-gnu 16fae6e9adSlinfengelse 17fae6e9adSlinfeng# 默认为x86_86,用于本地编译 18fae6e9adSlinfeng export RUST_TARGET=x86_64-unknown-linux-musl 19fae6e9adSlinfengendif 20fae6e9adSlinfeng 21fae6e9adSlinfengrun: 22fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) 23fae6e9adSlinfeng 24fae6e9adSlinfengbuild:build-ebpf 25fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) 26fae6e9adSlinfeng 27fae6e9adSlinfengclean:clean-ebpf 28fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) 29fae6e9adSlinfeng 30fae6e9adSlinfengtest: 31fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) 32fae6e9adSlinfeng 33fae6e9adSlinfengdoc: 34fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET) 35fae6e9adSlinfeng 36fae6e9adSlinfengfmt: 37fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt 38fae6e9adSlinfeng 39fae6e9adSlinfengfmt-check: 40fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check 41fae6e9adSlinfeng 42fae6e9adSlinfengrun-release: 43fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release 44fae6e9adSlinfeng 45fae6e9adSlinfengbuild-release:build-ebpf 46fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release 47fae6e9adSlinfeng 48fae6e9adSlinfengclean-release:clean-ebpf 49fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release 50fae6e9adSlinfeng 51fae6e9adSlinfengtest-release: 52fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release 53fae6e9adSlinfeng 54fae6e9adSlinfengbuild-ebpf: 55fae6e9adSlinfeng cd ./syscall_ebpf && RUST_LOG=debug cargo xtask build --release 56fae6e9adSlinfengclean-ebpf: 57fae6e9adSlinfeng cd ./syscall_ebpf && cargo clean 58fae6e9adSlinfeng 59fae6e9adSlinfeng.PHONY: install 60fae6e9adSlinfenginstall:build-ebpf 61fae6e9adSlinfeng RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force 62