-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathMakefile.am
More file actions
91 lines (71 loc) · 2.77 KB
/
Copy pathMakefile.am
File metadata and controls
91 lines (71 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
SHELL := /bin/bash
CARGO := $(if $(CARGO),$(CARGO),cargo)
# ENABLE_DEBUG is set from configure. We respect DEBUG too if set
DEBUG ?= $(ENABLE_DEBUG)
# RUST_TARGET and HAVE_RUST_TARGET is set from configure.
# Can be empty. If empty, we skip export it. Otherwise we do.
#
# We do this to emulate cargo's default behavior (--target=<triplet>) where
# it puts things into `target/` directly when not given or `target/<triplet>`.
# There's no way to force cargo to a stick to one behavior at the moment.
#
# Note: We use HAVE checks due to automake ifeq/ifneq not working outside rules
if HAVE_RUST_TARGET
export CARGO_BUILD_TARGET = $(RUST_TARGET)
endif
TARGET = $(RUST_TARGET)
export CARGO_TARGET_DIR ?= $(abs_builddir)/target
export CARGO_BUILD_JOBS ?= $(if $(JOBS),$(JOBS),-1)
CARGO_MANIFEST_PATH = $(abs_srcdir)/Cargo.toml
BUILD_ARTIFACTS_DIR = $(CARGO_TARGET_DIR)/$(TARGET)/$(if $(DEBUG),debug,release)
CARGO_MANIFEST_ARG = --manifest-path "$(CARGO_MANIFEST_PATH)"
CARGO_BUILD_TYPE_ARG = $(if $(DEBUG),,--release)
# We add --all-targets only on native build, i.e $build == $host
# otherwise things like `--test` cannot run
CARGO_EXTRA_ARGS ?= $(if $(subst $(build),,$(host)),,--all-targets)
# Export toolchain flags
export CC CXX AR NM RANLIB CFLAGS CXXFLAGS
# Not exported as these will break nested assumptions
# CPPFLAGS LDFLAGS ARFLAGS
# Set the native toolchain flags
if HAVE_RUST_HOST
export CC_$(RUST_HOST)=$(BUILD_CC)
export CXX_$(RUST_HOST)=$(BUILD_CXX)
export AR_$(RUST_HOST)=$(BUILD_AR)
export NM_$(RUST_HOST)=$(BUILD_NM)
export RANLIB_$(RUST_HOST)=$(BUILD_RANLIB)
endif
# Export compiler support
export PKG_CONFIG_PATH PKGCONFIG_LIBDIR PYTHONPATH
# Export other dep vars
export PROTOC PROTOC_INCLUDE_DIR SOLC_PATH
# Ensure nested autotools calls by cargo don't end up in unexpected places
unexport DESTDIR
export RUST_BACKTRACE=1
.PHONY: all
all: build
.PHONY: build
build:
$(CARGO) build $(CARGO_MANIFEST_ARG) $(CARGO_BUILD_TYPE_ARG) $(CARGO_EXTRA_ARGS) && \
cp $(BUILD_ARTIFACTS_DIR)/libain_rs_exports.a $(CARGO_TARGET_DIR)/lib/
.PHONY: check
check:
$(CARGO) check $(CARGO_MANIFEST_ARG) $(CARGO_EXTRA_ARGS)
.PHONY: test
test:
$(CARGO) test $(CARGO_MANIFEST_ARG) $(CARGO_EXTRA_ARGS)
.PHONY: doc
doc:
$(CARGO) doc $(CARGO_MANIFEST_ARG)
# We ignore unstable warnings for fmt to enable the use of backward
# compatible nightly features. Stricly backward compatible only, or will
# cause conflicts across toolchains
.PHONY: fmt-check
fmt-check:
$(CARGO) fmt $(CARGO_MANIFEST_ARG) --all --check 2> >(grep -v -E 'group_imports|unstable_features|imports_granularity')
.PHONY: fmt
fmt:
$(CARGO) fmt $(CARGO_MANIFEST_ARG) --all 2> >(grep -v -E 'group_imports|unstable_features|imports_granularity')
clean-local:
$(CARGO) clean $(CARGO_MANIFEST_ARG) && \
rm -rf $(CARGO_TARGET_DIR)/{include,lib,src}