-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alberto Faria <[email protected]>
- Loading branch information
1 parent
91ce0d6
commit 4186e59
Showing
2 changed files
with
32 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,43 @@ | ||
# This Makefile is intended for developer convenience. For the most part | ||
# all the targets here simply wrap calls to the `cargo` tool. Therefore, | ||
# most targets must be marked 'PHONY' to prevent `make` getting in the way | ||
# | ||
#prog :=xnixperms | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
DESTDIR ?= | ||
PREFIX ?= /usr/local | ||
BINDIR ?= $(PREFIX)/bin | ||
PREFIX ?= /usr/local | ||
|
||
CARGO ?= cargo | ||
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z) | ||
# Get crate version by parsing the line that starts with version. | ||
CRATE_VERSION ?= $(shell grep ^version Cargo.toml | awk '{print $$3}') | ||
GIT_TAG ?= $(shell git describe --tags) | ||
|
||
# Set this to any non-empty string to enable unoptimized | ||
# build w/ debugging features. | ||
debug ?= | ||
|
||
# Set path to cargo executable | ||
CARGO ?= cargo | ||
|
||
# All complication artifacts, including dependencies and intermediates | ||
# will be stored here, for all architectures. Use a non-default name | ||
# since the (default) 'target' is used/referenced ambiguously in many | ||
# places in the tool-chain (including 'make' itself). | ||
CARGO_TARGET_DIR ?= targets | ||
export CARGO_TARGET_DIR # 'cargo' is sensitive to this env. var. value. | ||
|
||
ifdef debug | ||
$(info debug is $(debug)) | ||
# These affect both $(CARGO_TARGET_DIR) layout and contents | ||
# Ref: https://doc.rust-lang.org/cargo/guide/build-cache.html | ||
release := | ||
profile :=debug | ||
else | ||
release :=--release | ||
profile :=release | ||
endif | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
bin: | ||
mkdir -p $@ | ||
|
||
$(CARGO_TARGET_DIR): | ||
mkdir -p $@ | ||
binpath := $(DESTDIR)/$(PREFIX)/bin/crun-vm | ||
|
||
.PHONY: build | ||
build: bin $(CARGO_TARGET_DIR) | ||
$(CARGO) build $(release) | ||
cp $(CARGO_TARGET_DIR)/$(profile)/crun-vm bin/crun-vm$(if $(debug),.debug,) | ||
build: | ||
$(CARGO) build --release | ||
mkdir -p bin | ||
cp target/release/crun-vm bin/crun-vm | ||
|
||
.PHONY: build-debug | ||
build-debug: | ||
$(CARGO) build | ||
mkdir -p bin | ||
cp target/debug/crun-vm bin/crun-vm.debug | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf bin | ||
if [ "$(CARGO_TARGET_DIR)" = "targets" ]; then rm -rf targets; fi | ||
rm -fr bin target | ||
|
||
.PHONY: install | ||
install: | ||
install ${SELINUXOPT} -D -m0755 bin/crun-vm $(DESTDIR)/$(BINDIR)/crun-vm | ||
install: install | ||
install ${SELINUXOPT} -D -m 0755 bin/crun-vm $(binpath) | ||
|
||
.PHONY: uninstall | ||
uninstall: | ||
rm -f $(DESTDIR)/$(BINDIR)/crun-vm | ||
|
||
#.PHONY: unit | ||
unit: $(CARGO_TARGET_DIR) | ||
$(SHELL) tests/env.sh build | ||
$(SHELL) tests/env.sh start | ||
$(SHELL) tests/env.sh run all all | ||
rm -f $(binpath) | ||
|
||
#.PHONY: code_coverage | ||
code_coverage: $(CARGO_TARGET_DIR) | ||
# Downloads tarpaulin only if same version is not present on local | ||
$(CARGO) install cargo-tarpaulin | ||
$(CARGO) tarpaulin -v | ||
.PHONY: lint | ||
lint: | ||
tests/lint.sh | ||
|
||
.PHONY: validate | ||
validate: $(CARGO_TARGET_DIR) | ||
$(SHELL) lint.sh | ||
.PHONY: test | ||
test: | ||
tests/env.sh build | ||
tests/env.sh start | ||
tests/env.sh run all all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters