]> git.lizzy.rs Git - rust.git/blob - mk/crates.mk
Auto merge of #28455 - nrc:span-bang, r=alexcrichton
[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 flate arena term \
53                  serialize getopts collections test rand \
54                  log graphviz core rbml alloc \
55                  rustc_unicode rustc_bitflags \
56                  alloc_system
57 RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
58                 rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
59                 rustc_data_structures rustc_front rustc_platform_intrinsics
60 HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
61 TOOLS := compiletest rustdoc rustc rustbook error-index-generator
62
63 DEPS_core :=
64 DEPS_libc := core
65 DEPS_rustc_unicode := core
66 DEPS_alloc := core libc alloc_system
67 DEPS_std := core libc rand alloc collections rustc_unicode \
68         native:rust_builtin native:backtrace \
69         alloc_system
70 DEPS_graphviz := std
71 DEPS_syntax := std term serialize log fmt_macros arena libc rustc_bitflags
72 DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
73                      rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
74                              rustc_trans rustc_privacy rustc_lint rustc_front
75
76 DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
77                         log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics
78 DEPS_rustc_mir := rustc rustc_front syntax
79 DEPS_rustc_typeck := rustc syntax rustc_front rustc_platform_intrinsics
80 DEPS_rustc_borrowck := rustc rustc_front log graphviz syntax
81 DEPS_rustc_resolve := rustc rustc_front log syntax
82 DEPS_rustc_privacy := rustc rustc_front log syntax
83 DEPS_rustc_lint := rustc log syntax
84 DEPS_rustc := syntax flate arena serialize getopts rbml \
85               log graphviz rustc_llvm rustc_back rustc_data_structures
86 DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
87 DEPS_rustc_platform_intrinsics := rustc rustc_llvm
88 DEPS_rustc_back := std syntax rustc_llvm rustc_front flate log libc
89 DEPS_rustc_front := std syntax log serialize
90 DEPS_rustc_data_structures := std log serialize
91 DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
92                 test rustc_lint rustc_front
93 DEPS_rustc_bitflags := core
94 DEPS_flate := std native:miniz
95 DEPS_arena := std
96 DEPS_graphviz := std
97 DEPS_glob := std
98 DEPS_serialize := std log
99 DEPS_rbml := std log serialize
100 DEPS_term := std log
101 DEPS_getopts := std
102 DEPS_collections := core alloc rustc_unicode
103 DEPS_num := std
104 DEPS_test := std getopts serialize rbml term native:rust_test_helpers
105 DEPS_rand := core
106 DEPS_log := std
107 DEPS_fmt_macros = std
108 DEPS_alloc_system := core libc
109
110 TOOL_DEPS_compiletest := test getopts
111 TOOL_DEPS_rustdoc := rustdoc
112 TOOL_DEPS_rustc := rustc_driver
113 TOOL_DEPS_rustbook := std rustdoc
114 TOOL_DEPS_error-index-generator := rustdoc syntax serialize
115 TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
116 TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
117 TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
118 TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs
119 TOOL_SOURCE_error-index-generator := $(S)src/error-index-generator/main.rs
120
121 ONLY_RLIB_core := 1
122 ONLY_RLIB_libc := 1
123 ONLY_RLIB_alloc := 1
124 ONLY_RLIB_rand := 1
125 ONLY_RLIB_collections := 1
126 ONLY_RLIB_rustc_unicode := 1
127 ONLY_RLIB_rustc_bitflags := 1
128 ONLY_RLIB_alloc_system := 1
129
130 # Documented-by-default crates
131 DOC_CRATES := std alloc collections core libc rustc_unicode
132
133 ifeq ($(CFG_DISABLE_JEMALLOC),)
134 TARGET_CRATES += alloc_jemalloc
135 DEPS_std += alloc_jemalloc
136 DEPS_alloc_jemalloc := core libc native:jemalloc
137 ONLY_RLIB_alloc_jemalloc := 1
138 else
139 RUSTFLAGS_rustc_back := --cfg disable_jemalloc
140 endif
141
142 ################################################################################
143 # You should not need to edit below this line
144 ################################################################################
145
146 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
147
148 # This macro creates some simple definitions for each crate being built, just
149 # some munging of all of the parameters above.
150 #
151 # $(1) is the crate to generate variables for
152 define RUST_CRATE
153 CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
154 RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
155 RUST_DEPS_$(1) := $$(filter-out native:%,$$(DEPS_$(1)))
156 NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
157 endef
158
159 $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
160
161 # Similar to the macro above for crates, this macro is for tools
162 #
163 # $(1) is the crate to generate variables for
164 define RUST_TOOL
165 TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
166 endef
167
168 $(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
169
170 ifdef CFG_DISABLE_ELF_TLS
171 RUSTFLAGS_std := --cfg no_elf_tls
172 endif