-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.am
81 lines (63 loc) · 2.43 KB
/
Makefile.am
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
bin_PROGRAMS = file-expert
file_expert_SOURCES = $(shell find @srcdir@/src -name *.rs) Cargo.toml Cargo.lock
-include ../verbose.mk
-include ../output.mk
CARGO_VERBOSE ::= $(shell test "$(V)" != "1" && echo "-q")
CARGO_TARGET_DIR ?= $(builddir)/target
CARGO_BUILD_FLAGS = $(CARGOFLAGS) $(CARGO_VERBOSE)
CARGO_BUILD_FLAGS += --manifest-path=$(srcdir)/Cargo.toml
CARGO_BUILD_FLAGS += --target-dir=$(CARGO_TARGET_DIR)
CARGO_BUILD_FLAGS += $(if $(CARGO_FAST_BUILD),,--release)
_TARGET_PROFILE_DIR ::= $(CARGO_TARGET_DIR)/$(if $(CARGO_FAST_BUILD),debug,release)
CLEANFILES = file-expert$(EXEEXT)
DISTCLEANFILES = @BKG_RPM_SPECFILE@
# We use the + prefix to pass down the jobserver fds to cargo, but we
# don't use the prefix when make -n is used, so that cargo doesn't run
# in that case)
define RUN_CARGO
$(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)$(call V_TOOL,CARGO,,$(1)) $(CARGO) $(1) $(CARGO_BUILD_FLAGS)
endef
YAML_FILES = named_patterns.yml languages.yml heuristics.yml skipped.yml
EXTRA_DIST = $(YAML_FILES) @[email protected]
EXTRA_DIST += $(shell find @srcdir@/src -name *.php)
.PHONY: generate-files
generate-files: tests/linguist.rs src/linguist_heuristics.rs
generate-files: src/linguist_extensions.rs src/linguist_interpreters.rs
generate-files: src/linguist_aliases.rs src/linguist_filenames.rs
%.rs: %.rs.php $(YAML_FILES)
$< > $@
rustfmt $@
file-expert$(EXEEXT): $(_TARGET_PROFILE_DIR)/file-expert
$(install_sh) -T -C $< $@
$(_TARGET_PROFILE_DIR)/file-expert: $(SOURCES)
@$(INFO_BUILD)
$(call RUN_CARGO,build) --bin $(@F)
mostlyclean-local:
$(V_CLEAN)
-$(call RUN_CARGO,clean)
rm -rf target
.PHONY: check-local
check-local: rust-code-style rust-clippy rust-test
.PHONY: rust-test
rust-test: $(SOURCES)
rust-test: $(if $(wildcard samples/*),tests/linguist.rs)
mkdir -p $(@D)
$(call RUN_CARGO,test)
.PHONY: rust-clippy
rust-clippy: $(SOURCES)
$(call RUN_CARGO,clippy) \
-- -W clippy::all -W clippy::pedantic \
-A clippy::non_ascii_literal \
-A clippy::implicit_return \
-A clippy::expect-used \
-D warnings
.PHONY: rust-code-style
rust-code-style: $(filter-out Cargo.lock,$(filter-out Cargo.toml,$(SOURCES)))
$(call V_TOOL,RUSTFMT,,$?)rustfmt $(CARGO_VERBOSE) $^ --check
.PHONY: coverage
coverage: CARGO_BUILD_FLAGS = $(filter-out $(CARGO_VERBOSE),$(CARGOFLAGS))
coverage: $(SOURCES)
coverage: $(if $(wildcard samples/*),tests/linguist.rs)
$(call RUN_CARGO,tarpaulin) -o html
@BKG_RPM_TEMPLATE@
@BKG_DEPLOY_GENTOO@