forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.mk
82 lines (68 loc) · 2.63 KB
/
host.mk
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
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
# Generic rule for copying any target crate to a host crate. This rule will also
# promote any dependent rust crates up to their host locations as well
#
# $(1) - the stage to copy from
# $(2) - the stage to copy to
# $(3) - the host triple
# $(4) - the target triple (same as $(3))
# $(5) - the name of the crate being processed
define CP_HOST_STAGE_N_CRATE
$$(HLIB$(2)_H_$(4))/stamp.$(5): \
$$(TLIB$(1)_T_$(3)_H_$(4))/stamp.$(5) \
$$(RUST_DEPS_$(5):%=$$(HLIB$(2)_H_$(4))/stamp.%) \
| $$(HLIB$(2)_H_$(4))/
@$$(call E, cp: $$(@D)/lib$(5))
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
$$(dir $$@)$$(call CFG_LIB_GLOB_$(3),$(5)))
$$(Q)cp $$< $$@
$$(Q)cp -R $$(TLIB$(1)_T_$(3)_H_$(4))/$$(call CFG_LIB_GLOB_$(3),$(5)) \
$$(HLIB$(2)_H_$(4))
$$(call LIST_ALL_OLD_GLOB_MATCHES,\
$$(dir $$@)$$(call CFG_LIB_GLOB_$(3),$(5)))
endef
# Same as the above macro, but for tools instead of crates
define CP_HOST_STAGE_N_TOOL
$$(HBIN$(2)_H_$(4))/$(5)$$(X_$(3)): \
$$(TBIN$(1)_T_$(3)_H_$(4))/$(5)$$(X_$(3)) \
$$(TOOL_DEPS_$(5):%=$$(HLIB$(2)_H_$(4))/stamp.%) \
| $$(HBIN$(2)_H_$(4))/
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
endef
# Miscellaneous rules for just making a few directories.
#
# $(1) - the stage to copy from
# $(2) - the stage to copy to
# $(3) - the target triple
# $(4) - the host triple (same as $(3))
define CP_HOST_STAGE_N
$$(HBIN$(2)_H_$(4))/:
@mkdir -p $$@
ifneq ($(CFG_LIBDIR_RELATIVE),bin)
$$(HLIB$(2)_H_$(4))/:
@mkdir -p $$@
endif
endef
$(foreach t,$(CFG_HOST), \
$(eval $(call CP_HOST_STAGE_N,0,1,$(t),$(t))) \
$(eval $(call CP_HOST_STAGE_N,1,2,$(t),$(t))) \
$(eval $(call CP_HOST_STAGE_N,2,3,$(t),$(t))))
$(foreach crate,$(CRATES), \
$(foreach t,$(CFG_HOST), \
$(eval $(call CP_HOST_STAGE_N_CRATE,0,1,$(t),$(t),$(crate))) \
$(eval $(call CP_HOST_STAGE_N_CRATE,1,2,$(t),$(t),$(crate))) \
$(eval $(call CP_HOST_STAGE_N_CRATE,2,3,$(t),$(t),$(crate)))))
$(foreach tool,$(TOOLS), \
$(foreach t,$(CFG_HOST), \
$(eval $(call CP_HOST_STAGE_N_TOOL,0,1,$(t),$(t),$(tool))) \
$(eval $(call CP_HOST_STAGE_N_TOOL,1,2,$(t),$(t),$(tool))) \
$(eval $(call CP_HOST_STAGE_N_TOOL,2,3,$(t),$(t),$(tool)))))