]> git.lizzy.rs Git - rust.git/blob - mk/crates.mk
Auto merge of #33786 - birkenfeld:make-fix, r=jseyfried
[rust.git] / mk / crates.mk
1 # Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11 ################################################################################
12 # Rust's standard distribution of crates and tools
13 #
14 # The crates outlined below are the standard distribution of libraries provided
15 # in a rust installation. These rules are meant to abstract over the
16 # dependencies (both native and rust) of crates and basically generate all the
17 # necessary makefile rules necessary to build everything.
18 #
19 # Here's an explanation of the variables below
20 #
21 #   TARGET_CRATES
22 #       This list of crates will be built for all targets, including
23 #       cross-compiled targets
24 #
25 #   HOST_CRATES
26 #       This list of crates will be compiled for only host targets. Note that
27 #       this set is explicitly *not* a subset of TARGET_CRATES, but rather it is
28 #       a disjoint set. Nothing in the TARGET_CRATES set can depend on crates in
29 #       the HOST_CRATES set, but the HOST_CRATES set can depend on target
30 #       crates.
31 #
32 #   TOOLS
33 #       A list of all tools which will be built as part of the compilation
34 #       process. It is currently assumed that most tools are built through
35 #       src/driver/driver.rs with a particular configuration (there's a
36 #       corresponding library providing the implementation)
37 #
38 #   DEPS_<crate>
39 #       These lists are the dependencies of the <crate> that is to be built.
40 #       Rust dependencies are listed bare (i.e. std) and native
41 #       dependencies have a "native:" prefix (i.e. native:hoedown). All deps
42 #       will be built before the crate itself is built.
43 #
44 #   TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
45 #       Similar to the DEPS variable, this is the library crate dependencies
46 #       list for tool as well as the source file for the specified tool
47 #
48 # You shouldn't need to modify much other than these variables. Crates are
49 # automatically generated for all stage/host/target combinations.
50 ################################################################################
51
52 TARGET_CRATES := libc std term \
53                  getopts collections test rand \
54                  core alloc \
55                  rustc_unicode rustc_bitflags \
56                  alloc_system alloc_jemalloc \
57                  panic_abort panic_unwind unwind
58 RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
59                 rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
60                 rustc_data_structures rustc_platform_intrinsics \
61                 rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
62                 rustc_const_eval rustc_const_math rustc_incremental
63 HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \
64                 flate arena graphviz rbml log serialize
65 TOOLS := compiletest rustdoc rustc rustbook error_index_generator
66
67 DEPS_core :=
68 DEPS_alloc := core libc alloc_system
69 DEPS_alloc_system := core libc
70 DEPS_alloc_jemalloc := core libc native:jemalloc
71 DEPS_collections := core alloc rustc_unicode
72 DEPS_libc := core
73 DEPS_rand := core
74 DEPS_rustc_bitflags := core
75 DEPS_rustc_unicode := core
76 DEPS_panic_abort := libc alloc
77 DEPS_panic_unwind := libc alloc unwind
78 DEPS_unwind := libc
79
80 # FIXME(stage0): change this to just `RUSTFLAGS_panic_abort := ...`
81 RUSTFLAGS1_panic_abort := -C panic=abort
82 RUSTFLAGS2_panic_abort := -C panic=abort
83 RUSTFLAGS3_panic_abort := -C panic=abort
84
85 DEPS_std := core libc rand alloc collections rustc_unicode \
86         native:backtrace \
87         alloc_system panic_abort panic_unwind unwind
88 DEPS_arena := std
89 DEPS_glob := std
90 DEPS_flate := std native:miniz
91 DEPS_fmt_macros = std
92 DEPS_getopts := std
93 DEPS_graphviz := std
94 DEPS_log := std
95 DEPS_num := std
96 DEPS_rbml := std log serialize
97 DEPS_serialize := std log
98 DEPS_term := std
99 DEPS_test := std getopts term native:rust_test_helpers
100
101 DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode
102 DEPS_syntax_ext := syntax fmt_macros
103
104 DEPS_rustc_const_math := std syntax log serialize
105 DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
106                                              rustc_back graphviz
107
108 DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml \
109               log graphviz rustc_llvm rustc_back rustc_data_structures\
110                           rustc_const_math
111 DEPS_rustc_back := std syntax flate log libc
112 DEPS_rustc_borrowck := rustc rustc_mir log graphviz syntax
113 DEPS_rustc_data_structures := std log serialize
114 DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
115                      rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
116                      rustc_trans rustc_privacy rustc_lint rustc_plugin \
117                      rustc_metadata syntax_ext rustc_passes rustc_save_analysis rustc_const_eval \
118                      rustc_incremental
119 DEPS_rustc_lint := rustc log syntax rustc_const_eval
120 DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
121 DEPS_rustc_metadata := rustc syntax rbml rustc_const_math
122 DEPS_rustc_passes := syntax rustc core rustc_const_eval
123 DEPS_rustc_mir := rustc syntax rustc_const_math rustc_const_eval rustc_bitflags
124 DEPS_rustc_resolve := arena rustc log syntax
125 DEPS_rustc_platform_intrinsics := std
126 DEPS_rustc_plugin := rustc rustc_metadata syntax rustc_mir
127 DEPS_rustc_privacy := rustc log syntax
128 DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
129                     log syntax serialize rustc_llvm rustc_platform_intrinsics \
130                     rustc_const_math rustc_const_eval rustc_incremental
131 DEPS_rustc_incremental := rbml rustc serialize rustc_data_structures
132 DEPS_rustc_save_analysis := rustc log syntax serialize
133 DEPS_rustc_typeck := rustc syntax rustc_platform_intrinsics rustc_const_math \
134                      rustc_const_eval
135
136 DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
137                 test rustc_lint rustc_const_eval
138
139
140 TOOL_DEPS_compiletest := test getopts log serialize
141 TOOL_DEPS_rustdoc := rustdoc
142 TOOL_DEPS_rustc := rustc_driver
143 TOOL_DEPS_rustbook := std rustdoc
144 TOOL_DEPS_error_index_generator := rustdoc syntax serialize
145 TOOL_SOURCE_compiletest := $(S)src/tools/compiletest/src/main.rs
146 TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
147 TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
148 TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
149 TOOL_SOURCE_error_index_generator := $(S)src/tools/error_index_generator/main.rs
150
151 ONLY_RLIB_core := 1
152 ONLY_RLIB_libc := 1
153 ONLY_RLIB_alloc := 1
154 ONLY_RLIB_rand := 1
155 ONLY_RLIB_collections := 1
156 ONLY_RLIB_rustc_unicode := 1
157 ONLY_RLIB_rustc_bitflags := 1
158 ONLY_RLIB_alloc_system := 1
159 ONLY_RLIB_alloc_jemalloc := 1
160 ONLY_RLIB_panic_unwind := 1
161 ONLY_RLIB_panic_abort := 1
162 ONLY_RLIB_unwind := 1
163
164 TARGET_SPECIFIC_alloc_jemalloc := 1
165
166 # Documented-by-default crates
167 DOC_CRATES := std alloc collections core libc rustc_unicode
168
169 ifeq ($(CFG_DISABLE_JEMALLOC),)
170 RUSTFLAGS_rustc_back := --cfg 'feature="jemalloc"'
171 endif
172
173 ################################################################################
174 # You should not need to edit below this line
175 ################################################################################
176
177 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
178
179 # This macro creates some simple definitions for each crate being built, just
180 # some munging of all of the parameters above.
181 #
182 # $(1) is the crate to generate variables for
183 define RUST_CRATE
184 CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
185 RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
186 NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
187 endef
188
189 $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
190
191 # $(1) - crate
192 # $(2) - target
193 define RUST_CRATE_DEPS
194 RUST_DEPS_$(1)_T_$(2) := $$(filter-out native:%,$$(DEPS_$(1)))
195 endef
196
197 $(foreach target,$(CFG_TARGET),\
198  $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE_DEPS,$(crate),$(target)))))
199
200 # $(1) - target
201 # $(2) - crate
202 define DEFINE_TARGET_CRATES
203 ifndef TARGET_SPECIFIC_$(2)
204 TARGET_CRATES_$(1) += $(2)
205 endif
206 endef
207
208 $(foreach target,$(CFG_TARGET),\
209  $(foreach crate,$(TARGET_CRATES),\
210   $(eval $(call DEFINE_TARGET_CRATES,$(target),$(crate)))))
211
212 # Similar to the macro above for crates, this macro is for tools
213 #
214 # $(1) is the crate to generate variables for
215 define RUST_TOOL
216 TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
217 endef
218
219 $(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
220
221 CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
222 RUSTFLAGS_libc := --cfg stdbuild