Skip to content

Commit 57d273f

Browse files
committed
auto merge of #12284 : brson/rust/install, r=alexcrichton
Work toward #9876. This adds `prepare.mk`, which is simply a more heavily-parameterized `install.mk`, then uses `prepare` to implement both `install` and the windows installer (`dist`). Smoke tested on both Linux and Windows.
2 parents c848906 + 2b64cb2 commit 57d273f

File tree

6 files changed

+256
-157
lines changed

6 files changed

+256
-157
lines changed

Makefile.in

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,6 @@ include $(CFG_SRC_DIR)mk/llvm.mk
198198
# Secondary makefiles, conditionalized for speed
199199
######################################################################
200200

201-
# Source and binary distribution artifacts
202-
ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
203-
$(findstring check,$(MAKECMDGOALS)) \
204-
$(findstring test,$(MAKECMDGOALS)) \
205-
$(findstring tidy,$(MAKECMDGOALS)) \
206-
$(findstring clean,$(MAKECMDGOALS))),)
207-
CFG_INFO := $(info cfg: including dist rules)
208-
include $(CFG_SRC_DIR)mk/dist.mk
209-
endif
210-
211201
# Binary snapshots
212202
ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
213203
$(findstring clean,$(MAKECMDGOALS))),)
@@ -230,18 +220,33 @@ ifneq ($(findstring perf,$(MAKECMDGOALS)),)
230220
include $(CFG_SRC_DIR)mk/perf.mk
231221
endif
232222

233-
# Cleaning
234-
ifneq ($(findstring clean,$(MAKECMDGOALS)),)
235-
CFG_INFO := $(info cfg: including clean rules)
236-
include $(CFG_SRC_DIR)mk/clean.mk
223+
# Copy all the distributables to another directory for binary install
224+
ifneq ($(strip $(findstring prepare,$(MAKECMDGOALS)) \
225+
$(findstring dist,$(MAKECMDGOALS)) \
226+
$(findstring install,$(MAKECMDGOALS))),)
227+
CFG_INFO := $(info cfg: including prepare rules)
228+
include $(CFG_SRC_DIR)mk/prepare.mk
237229
endif
238230

239-
# Installation from the build directory
231+
# (Unix) Installation from the build directory
240232
ifneq ($(findstring install,$(MAKECMDGOALS)),)
241233
CFG_INFO := $(info cfg: including install rules)
242234
include $(CFG_SRC_DIR)mk/install.mk
243235
endif
244236

237+
# Source and binary distribution artifacts
238+
ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
239+
$(findstring clean,$(MAKECMDGOALS))),)
240+
CFG_INFO := $(info cfg: including dist rules)
241+
include $(CFG_SRC_DIR)mk/dist.mk
242+
endif
243+
244+
# Cleaning
245+
ifneq ($(findstring clean,$(MAKECMDGOALS)),)
246+
CFG_INFO := $(info cfg: including clean rules)
247+
include $(CFG_SRC_DIR)mk/clean.mk
248+
endif
249+
245250
# CTAGS building
246251
ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
247252
$(findstring TAGS.vi,$(MAKECMDGOALS))),)

mk/dist.mk

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ PKG_FILES := \
2424
$(S)RELEASES.txt \
2525
$(S)configure $(S)Makefile.in \
2626
$(S)man \
27-
$(S)doc \
2827
$(addprefix $(S)src/, \
2928
README.md \
3029
compiletest \
30+
doc \
3131
driver \
3232
etc \
3333
$(foreach crate,$(CRATES),lib$(crate)) \
@@ -52,12 +52,24 @@ LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
5252
cp $< $@
5353

5454
$(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
55-
$(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD))
56-
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py i686-pc-mingw32/stage3/bin
55+
$(PKG_FILES) $(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
56+
dist-prepare-win
57+
$(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin
5758
@$(call E, ISCC: $@)
5859
$(Q)"$(CFG_ISCC)" $<
59-
endif
6060

61+
dist-prepare-win: PREPARE_HOST=$(CFG_BUILD)
62+
dist-prepare-win: PREPARE_TARGETS=$(CFG_BUILD)
63+
dist-prepare-win: PREPARE_DEST_DIR=tmp/dist/win
64+
# On windows we're using stage3, unlike Unix...
65+
dist-prepare-win: PREPARE_STAGE=3
66+
dist-prepare-win: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
67+
dist-prepare-win: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
68+
dist-prepare-win: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
69+
dist-prepare-win: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
70+
dist-prepare-win: prepare-base
71+
72+
endif
6173

6274
$(PKG_TAR): $(PKG_FILES)
6375
@$(call E, making dist dir)

mk/install.mk

Lines changed: 24 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -12,117 +12,33 @@
1212
# For consistency it might be desirable for stageN to be an exact
1313
# mirror of the installation directory structure.
1414

15-
# Installation macros.
16-
# For INSTALL,
17-
# $(1) is the source dirctory
18-
# $(2) is the destination directory
19-
# $(3) is the filename/libname-glob
20-
ifdef VERBOSE
21-
INSTALL = install -m755 $(1)/$(3) $(DESTDIR)$(2)/$(3)
22-
else
23-
INSTALL = $(Q)$(call E, install: $(DESTDIR)$(2)/$(3)) && install -m755 $(1)/$(3) $(DESTDIR)$(2)/$(3)
24-
endif
25-
26-
# For MK_INSTALL_DIR
27-
# $(1) is the directory to create
28-
MK_INSTALL_DIR = (umask 022 && mkdir -p $(DESTDIR)$(1))
29-
30-
# For INSTALL_LIB,
31-
# Target-specific $(LIB_SOURCE_DIR) is the source directory
32-
# Target-specific $(LIB_DESTIN_DIR) is the destination directory
33-
# $(1) is the filename/libname-glob
34-
ifdef VERBOSE
35-
DO_INSTALL_LIB = install -m644 `ls -drt1 $(LIB_SOURCE_DIR)/$(1) | tail -1` $(DESTDIR)$(LIB_DESTIN_DIR)/
36-
else
37-
DO_INSTALL_LIB = $(Q)$(call E, install_lib: $(DESTDIR)$(LIB_DESTIN_DIR)/$(1)) && \
38-
install -m644 `ls -drt1 $(LIB_SOURCE_DIR)/$(1) | tail -1` $(DESTDIR)$(LIB_DESTIN_DIR)/
39-
endif
40-
41-
# Target-specific $(LIB_SOURCE_DIR) is the source directory
42-
# Target-specific $(LIB_DESTIN_DIR) is the destination directory
43-
# $(1) is the filename/libname-glob
44-
define INSTALL_LIB
45-
$(if $(filter-out 1,$(words $(wildcard $(LIB_SOURCE_DIR)/$(1)))), \
46-
$(error Aborting install because more than one library matching \
47-
$(1) is present in build tree $(LIB_SOURCE_DIR): \
48-
$(wildcard $(LIB_SOURCE_DIR)/$(1))))
49-
$(Q)LIB_NAME="$(notdir $(lastword $(wildcard $(LIB_SOURCE_DIR)/$(1))))"; \
50-
MATCHES="$(filter-out %$(notdir $(lastword $(wildcard $(LIB_SOURCE_DIR)/$(1)))),\
51-
$(wildcard $(LIB_DESTIN_DIR)/$(1)))"; \
52-
if [ -n "$$MATCHES" ]; then \
53-
echo "warning: one or libraries matching Rust library '$(1)'" && \
54-
echo " (other than '$$LIB_NAME' itself) already present" && \
55-
echo " at destination $(LIB_DESTIN_DIR):" && \
56-
echo $$MATCHES ; \
57-
fi
58-
$(call DO_INSTALL_LIB,$(1))
59-
endef
60-
6115
# The stage we install from
6216
ISTAGE = 2
6317

18+
install: PREPARE_HOST=$(CFG_BUILD)
19+
install: PREPARE_TARGETS=$(CFG_TARGET)
20+
install: PREPARE_STAGE=$(ISTAGE)
21+
install: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
22+
install: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
23+
install: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
24+
install: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
25+
install: PREPARE_SOURCE_DIR=$(PREPARE_HOST)/stage$(PREPARE_STAGE)
26+
install: PREPARE_SOURCE_BIN_DIR=$(PREPARE_SOURCE_DIR)/bin
27+
install: PREPARE_SOURCE_LIB_DIR=$(PREPARE_SOURCE_DIR)/$(CFG_LIBDIR_RELATIVE)
28+
install: PREPARE_SOURCE_MAN_DIR=$(S)/man
29+
install: PREPARE_DEST_BIN_DIR=$(DESTDIR)$(CFG_PREFIX)/bin
30+
install: PREPARE_DEST_LIB_DIR=$(DESTDIR)$(CFG_LIBDIR)
31+
install: PREPARE_DEST_MAN_DIR=$(DESTDIR)$(CFG_MANDIR)/man1
32+
install: prepare-everything
33+
34+
35+
# Uninstall code
36+
6437
PREFIX_ROOT = $(CFG_PREFIX)
6538
PREFIX_BIN = $(PREFIX_ROOT)/bin
6639
PREFIX_LIB = $(CFG_LIBDIR)
6740

68-
INSTALL_TOOLS := $(filter-out compiletest, $(TOOLS))
69-
70-
define INSTALL_PREPARE_N
71-
# $(1) is the target triple
72-
# $(2) is the host triple
73-
74-
# T{B,L} == Target {Bin, Lib} for stage ${ISTAGE}
75-
TB$(1)$(2) = $$(TBIN$$(ISTAGE)_T_$(1)_H_$(2))
76-
TL$(1)$(2) = $$(TLIB$$(ISTAGE)_T_$(1)_H_$(2))
77-
78-
# PT{R,B,L} == Prefix Target {Root, Bin, Lib}
79-
PTR$(1)$(2) = $$(PREFIX_LIB)/$(CFG_RUSTLIBDIR)/$(1)
80-
PTB$(1)$(2) = $$(PTR$(1)$(2))/bin
81-
PTL$(1)$(2) = $$(PTR$(1)$(2))/lib
82-
83-
endef
84-
85-
$(foreach target,$(CFG_TARGET), \
86-
$(eval $(call INSTALL_PREPARE_N,$(target),$(CFG_BUILD))))
87-
88-
define INSTALL_TARGET_N
89-
install-target-$(1)-host-$(2): LIB_SOURCE_DIR=$$(TL$(1)$(2))
90-
install-target-$(1)-host-$(2): LIB_DESTIN_DIR=$$(PTL$(1)$(2))
91-
install-target-$(1)-host-$(2): \
92-
$$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) \
93-
$$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
94-
$$(Q)$$(call MK_INSTALL_DIR,$$(PTL$(1)$(2)))
95-
$$(Q)$$(foreach crate,$$(TARGET_CRATES),\
96-
$$(call INSTALL_LIB,$$(call CFG_LIB_GLOB_$(1),$$(crate)));\
97-
$$(call INSTALL_LIB,$$(call CFG_RLIB_GLOB,$$(crate)));)
98-
$$(Q)$$(call INSTALL_LIB,libmorestack.a)
99-
$$(Q)$$(call INSTALL_LIB,libcompiler-rt.a)
100-
101-
endef
102-
103-
define INSTALL_HOST_N
104-
105-
install-target-$(1)-host-$(2): LIB_SOURCE_DIR=$$(TL$(1)$(2))
106-
install-target-$(1)-host-$(2): LIB_DESTIN_DIR=$$(PTL$(1)$(2))
107-
install-target-$(1)-host-$(2): $$(CSREQ$$(ISTAGE)_T_$(1)_H_$(2))
108-
$$(Q)$$(call MK_INSTALL_DIR,$$(PTL$(1)$(2)))
109-
$$(Q)$$(foreach crate,$$(CRATES),\
110-
$$(call INSTALL_LIB,$$(call CFG_LIB_GLOB_$(1),$$(crate)));)
111-
$$(Q)$$(foreach crate,$$(TARGET_CRATES),\
112-
$$(call INSTALL_LIB,$$(call CFG_RLIB_GLOB,$$(crate)));)
113-
$$(Q)$$(call INSTALL_LIB,libmorestack.a)
114-
$$(Q)$$(call INSTALL_LIB,libcompiler-rt.a)
115-
endef
116-
117-
$(foreach target,$(CFG_TARGET), \
118-
$(if $(findstring $(target), $(CFG_BUILD)), \
119-
$(eval $(call INSTALL_HOST_N,$(target),$(CFG_BUILD))), \
120-
$(eval $(call INSTALL_TARGET_N,$(target),$(CFG_BUILD)))))
121-
122-
INSTALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
123-
install-target-$(target)-host-$(CFG_BUILD))
124-
125-
install: all install-host install-targets
41+
INSTALL_TOOLS := $(PREPARE_TOOLS)
12642

12743
# Shorthand for build/stageN/bin
12844
HB = $(HBIN$(ISTAGE)_H_$(CFG_BUILD))
@@ -134,39 +50,6 @@ PHB = $(PREFIX_BIN)
13450
# Shorthand for the prefix bin directory
13551
PHL = $(PREFIX_LIB)
13652

137-
install-host%: LIB_SOURCE_DIR=$(HL)
138-
install-host%: LIB_DESTIN_DIR=$(PHL)
139-
install-host: \
140-
install-host-prep \
141-
$(foreach tool,$(INSTALL_TOOLS),install-host-tool-$(tool))
142-
143-
install-host-prep: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD)_H_$(CFG_BUILD))
144-
$(Q)$(call MK_INSTALL_DIR,$(PREFIX_BIN))
145-
$(Q)$(call MK_INSTALL_DIR,$(PREFIX_LIB))
146-
$(Q)$(call MK_INSTALL_DIR,$(CFG_MANDIR)/man1)
147-
148-
define INSTALL_HOST_TOOL
149-
install-host-tool-$(1): \
150-
$$(foreach dep,$$(TOOL_DEPS_$(1)),install-host-lib-$$(dep)) \
151-
$$(CSREQ$$(ISTAGE)_T_$$(CFG_BUILD)_H_$$(CFG_BUILD))
152-
$$(Q)$$(call INSTALL,$$(HB2),$$(PHB),$(1)$$(X_$$(CFG_BUILD)))
153-
$$(Q)$$(call INSTALL,$$(S)/man,$$(CFG_MANDIR)/man1,$(1).1)
154-
endef
155-
156-
$(foreach tool,$(INSTALL_TOOLS),$(eval $(call INSTALL_HOST_TOOL,$(tool))))
157-
158-
define INSTALL_HOST_LIB
159-
install-host-lib-$(1): \
160-
$$(foreach dep,$$(RUST_DEPS_$(1)),install-host-lib-$$(dep)) \
161-
$$(CSREQ$$(ISTAGE)_T_$$(CFG_BUILD)_H_$$(CFG_BUILD))
162-
$$(Q)$$(call INSTALL_LIB,$$(call CFG_LIB_GLOB_$$(CFG_BUILD),$(1)))
163-
endef
164-
165-
$(foreach lib,$(CRATES),$(eval $(call INSTALL_HOST_LIB,$(lib))))
166-
167-
install-targets: $(INSTALL_TARGET_RULES)
168-
169-
17053
HOST_LIB_FROM_HL_GLOB = \
17154
$(patsubst $(HL)/%,$(PHL)/%,$(wildcard $(HL)/$(1)))
17255

@@ -188,6 +71,10 @@ endef
18871

18972
$(foreach lib,$(CRATES),$(eval $(call UNINSTALL_LIB,$(lib))))
19073

74+
75+
# Android runtime setup
76+
# FIXME: This probably belongs somewhere else
77+
19178
# target platform specific variables
19279
# for arm-linux-androidabi
19380
define DEF_ADB_DEVICE_STATUS

0 commit comments

Comments
 (0)