forked from rust-lang/cargo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
201 lines (162 loc) · 5.99 KB
/
Makefile.in
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
CFG_RELEASE_NUM=0.0.1
CFG_RELEASE_LABEL=-pre
include config.mk
ifneq ($(CFG_LOCAL_RUST_ROOT),)
export LD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(LD_LIBRARY_PATH)
export DYLD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(DYLD_LIBRARY_PATH)
endif
export PATH := $(dir $(CFG_RUSTC)):$(PATH)
ifdef CFG_ENABLE_NIGHTLY
CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)-nightly
CFG_PACKAGE_VERS = nightly
else
CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)
CFG_PACKAGE_VERS=$(CFG_RELEASE)
endif
CFG_VER_DATE = $(shell git log -1 --pretty=format:'%ai')
CFG_VER_HASH = $(shell git rev-parse --short HEAD)
CFG_VERSION = $(CFG_RELEASE) ($(CFG_VER_HASH) $(CFG_VER_DATE))
PKG_NAME = cargo-$(CFG_PACKAGE_VERS)
ifdef CFG_DISABLE_VERIFY_INSTALL
MAYBE_DISABLE_VERIFY=--disable-verify
else
MAYBE_DISABLE_VERIFY=
endif
ifdef CFG_ENABLE_OPTIMIZE
OPT_FLAG=--release
else
OPT_FLAG=
endif
export CFG_VERSION
export CFG_DISABLE_CROSS_TESTS
ifeq ($(OS),Windows_NT)
X = .exe
endif
TARGET_ROOT = target
BIN_TARGETS := cargo
BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%)
BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS))
define DIST_TARGET
ifdef CFG_ENABLE_OPTIMIZE
TARGET_$(1) = $$(TARGET_ROOT)/$(1)/release
else
TARGET_$(1) = $$(TARGET_ROOT)/$(1)
endif
DISTDIR_$(1) = $$(TARGET_$(1))/dist
IMGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)-image
PKGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)
BIN_TARGETS_$(1) := $$(BIN_TARGETS:%=$$(TARGET_$(1))/%$$(X))
endef
$(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target))))
ifdef CFG_LOCAL_CARGO
CARGO := $(CFG_LOCAL_CARGO)
else
CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X)
endif
all: $(foreach target,$(CFG_TARGET),cargo-$(target))
define CARGO_TARGET
cargo-$(1): $$(CARGO)
"$$(CFG_RUSTC)" -V
$$(CARGO) build --target $(1) $$(OPT_FLAG) $$(ARGS)
test-unit-$(1): $$(CARGO)
$$(CARGO) test --target $(1) $$(only)
endef
$(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target))))
$(TARGET_ROOT)/snapshot/bin/cargo$(X): src/snapshots.txt
$(CFG_PYTHON) src/etc/dl-snapshot.py $(CFG_BUILD)
touch $@
# === Tests
test: style no-exes $(foreach target,$(CFG_TARGET),test-unit-$(target))
style:
sh tests/check-style.sh
no-exes:
find $$(git ls-files) -perm +111 -type f \
-not -name configure -not -name '*.sh' -not -name '*.rs' | \
grep '.*' \
&& exit 1 || exit 0
# === Misc
clean-all: clean
clean:
rm -rf $(TARGET_ROOT)
# === Documentation
DOCS := index faq config guide manifest build-script pkgid-spec crates-io
DOC_DIR := target/doc
DOC_OPTS := --markdown-no-toc \
--markdown-css stylesheets/normalize.css \
--markdown-css stylesheets/all.css \
--markdown-css stylesheets/prism.css \
--html-before-content src/doc/header.html \
--html-after-content src/doc/footer.html
ASSETS := CNAME images/noise.png images/forkme.png images/Cargo-Logo-Small.png \
stylesheets/all.css stylesheets/normalize.css javascripts/prism.js \
javascripts/all.js stylesheets/prism.css images/circle-with-i.png \
images/search.png
doc: $(foreach doc,$(DOCS),target/doc/$(doc).html) \
$(foreach asset,$(ASSETS),target/doc/$(asset))
$(DOC_DIR)/%.html: src/doc/%.md src/doc/header.html src/doc/footer.html
@mkdir -p $(@D)
"$(CFG_RUSTDOC)" $< -o $(@D) $(DOC_OPTS)
$(DOC_DIR)/%: src/doc/%
@mkdir -p $(@D)
cp $< $@
# === Distribution
NON_INSTALLED_PREFIXES := README.md,LICENSE-MIT,LICENSE-APACHE,LICENSE-THIRD-PARTY
define DO_DIST_TARGET
dist-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
# One may wonder why some of the commands here are prefixed with `cd -P .`, and
# that's a good question! On some of the windows bots, PWD has a windows-style
# path, and that ends up choking the installation script in various ways.
# Prefixing commands with this `cd -P .` helps the bots to set the right PWD env
# var.
distcheck-$(1): dist-$(1)
rm -rf $$(TARGET_$(1))/distcheck
mkdir -p $$(TARGET_$(1))/distcheck
(cd $$(TARGET_$(1))/distcheck && tar xf ../dist/$$(PKG_NAME)-$(1).tar.gz)
cd -P . && $$(TARGET_$(1))/distcheck/$$(PKG_NAME)-$(1)/install.sh \
--prefix=$$(TARGET_$(1))/distcheck/install
$$(TARGET_$(1))/distcheck/install/bin/cargo -V > /dev/null
cd -P . && $$(TARGET_$(1))/distcheck/$$(PKG_NAME)-$(1)/install.sh \
--prefix=$$(TARGET_$(1))/distcheck/install --uninstall
[ -f $$(TARGET_$(1))/distcheck/install/bin/cargo$(X) ] && exit 1 || exit 0
prepare-image-$(1):
@[ -f $$(TARGET_$(1))/cargo$$(X) ] || echo 'Please run `make` first'
@[ -f $$(TARGET_$(1))/cargo$$(X) ]
rm -rf $$(IMGDIR_$(1))
mkdir -p $$(IMGDIR_$(1))/bin $$(IMGDIR_$(1))/lib/cargo \
$$(IMGDIR_$(1))/share/man/man1 \
$$(IMGDIR_$(1))/share/doc/cargo \
$$(IMGDIR_$(1))/share/zsh/site-functions \
$$(IMGDIR_$(1))/etc/bash_completion.d
cp $$(TARGET_$(1))/cargo$$(X) $$(IMGDIR_$(1))/bin
cp src/etc/cargo.1 $$(IMGDIR_$(1))/share/man/man1
cp src/etc/_cargo $$(IMGDIR_$(1))/share/zsh/site-functions/_cargo
cp src/etc/cargo.bashcomp.sh $$(IMGDIR_$(1))/etc/bash_completion.d/cargo
cp README.md LICENSE-MIT LICENSE-APACHE LICENSE-THIRD-PARTY \
$$(IMGDIR_$(1))/share/doc/cargo
cp README.md LICENSE-MIT LICENSE-APACHE LICENSE-THIRD-PARTY \
$$(IMGDIR_$(1))
$$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz: prepare-image-$(1)
sh src/rust-installer/gen-installer.sh \
--product-name=Cargo \
--verify-bin=cargo \
--rel-manifest-dir=cargo \
--success-message=Cargo-is-ready-to-roll. \
--image-dir=$$(IMGDIR_$(1)) \
--work-dir=./$$(DISTDIR_$(1)) \
--output-dir=./$$(DISTDIR_$(1)) \
--non-installed-prefixes=$$(NON_INSTALLED_PREFIXES) \
--package-name=$$(PKG_NAME)-$(1)
rm -Rf $$(IMGDIR_$(1))
install-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
$$(PKGDIR_$(1))/install.sh \
--prefix="$$(CFG_PREFIX)" \
--destdir="$$(DESTDIR)" $$(MAYBE_DISABLE_VERIFY)
endef
$(foreach target,$(CFG_TARGET),$(eval $(call DO_DIST_TARGET,$(target))))
dist: $(foreach target,$(CFG_TARGET),dist-$(target))
distcheck: $(foreach target,$(CFG_TARGET),distcheck-$(target))
install: $(foreach target,$(CFG_TARGET),install-$(target))
# Setup phony tasks
.PHONY: all clean clean-all dist distcheck install test test-unit style
# Disable unnecessary built-in rules
.SUFFIXES: