]> git.proxmox.com Git - rustc.git/blame - mk/crates.mk
New upstream version 1.14.0+dfsg1
[rustc.git] / mk / crates.mk
CommitLineData
1a4d82fc
JJ
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
54a0048b
SL
52TARGET_CRATES := libc std term \
53 getopts collections test rand \
9e0c209e 54 compiler_builtins core alloc \
e9174d1e 55 rustc_unicode rustc_bitflags \
a7813a04
XL
56 alloc_system alloc_jemalloc \
57 panic_abort panic_unwind unwind
e9174d1e 58RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
d9579d0f 59 rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
3157f602 60 rustc_data_structures rustc_platform_intrinsics rustc_errors \
54a0048b 61 rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
c30ab7b3
SL
62 rustc_const_eval rustc_const_math rustc_incremental proc_macro
63HOST_CRATES := syntax syntax_ext proc_macro_tokens proc_macro_plugin syntax_pos $(RUSTC_CRATES) \
64 rustdoc fmt_macros flate arena graphviz log serialize
7453a54e 65TOOLS := compiletest rustdoc rustc rustbook error_index_generator
1a4d82fc
JJ
66
67DEPS_core :=
9e0c209e 68DEPS_compiler_builtins := core
b039eaaf
SL
69DEPS_alloc := core libc alloc_system
70DEPS_alloc_system := core libc
7453a54e 71DEPS_alloc_jemalloc := core libc native:jemalloc
b039eaaf 72DEPS_collections := core alloc rustc_unicode
1a4d82fc 73DEPS_libc := core
b039eaaf
SL
74DEPS_rand := core
75DEPS_rustc_bitflags := core
d9579d0f 76DEPS_rustc_unicode := core
a7813a04
XL
77DEPS_panic_abort := libc alloc
78DEPS_panic_unwind := libc alloc unwind
79DEPS_unwind := libc
80
9e0c209e
SL
81RUSTFLAGS_compiler_builtins := -lstatic=compiler-rt
82
a7813a04
XL
83# FIXME(stage0): change this to just `RUSTFLAGS_panic_abort := ...`
84RUSTFLAGS1_panic_abort := -C panic=abort
85RUSTFLAGS2_panic_abort := -C panic=abort
86RUSTFLAGS3_panic_abort := -C panic=abort
b039eaaf 87
9e0c209e 88DEPS_std := core libc rand alloc collections compiler_builtins rustc_unicode \
9cc50fc6 89 native:backtrace \
a7813a04 90 alloc_system panic_abort panic_unwind unwind
b039eaaf
SL
91DEPS_arena := std
92DEPS_glob := std
93DEPS_flate := std native:miniz
94DEPS_fmt_macros = std
95DEPS_getopts := std
1a4d82fc 96DEPS_graphviz := std
b039eaaf
SL
97DEPS_log := std
98DEPS_num := std
b039eaaf 99DEPS_serialize := std log
54a0048b
SL
100DEPS_term := std
101DEPS_test := std getopts term native:rust_test_helpers
b039eaaf 102
3157f602 103DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode rustc_errors syntax_pos
c30ab7b3 104DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros proc_macro
3157f602 105DEPS_syntax_pos := serialize
c30ab7b3
SL
106DEPS_proc_macro_tokens := syntax syntax_pos log
107DEPS_proc_macro_plugin := syntax syntax_pos rustc_plugin log proc_macro_tokens
b039eaaf 108
54a0048b
SL
109DEPS_rustc_const_math := std syntax log serialize
110DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
3157f602 111 rustc_back graphviz syntax_pos
54a0048b 112
9e0c209e 113DEPS_rustc := syntax fmt_macros flate arena serialize getopts \
a7813a04 114 log graphviz rustc_llvm rustc_back rustc_data_structures\
3157f602 115 rustc_const_math syntax_pos rustc_errors
54a0048b 116DEPS_rustc_back := std syntax flate log libc
3157f602 117DEPS_rustc_borrowck := rustc log graphviz syntax syntax_pos rustc_errors rustc_mir
9e0c209e 118DEPS_rustc_data_structures := std log serialize libc
1a4d82fc 119DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
e9174d1e 120 rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
9e0c209e 121 rustc_trans rustc_privacy rustc_lint rustc_plugin \
c30ab7b3 122 rustc_metadata syntax_ext proc_macro_plugin \
9e0c209e 123 rustc_passes rustc_save_analysis rustc_const_eval \
c30ab7b3 124 rustc_incremental syntax_pos rustc_errors proc_macro rustc_data_structures
3157f602
XL
125DEPS_rustc_errors := log libc serialize syntax_pos
126DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval
e9174d1e 127DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
c30ab7b3 128DEPS_proc_macro := std syntax
9e0c209e 129DEPS_rustc_metadata := rustc syntax syntax_pos rustc_errors rustc_const_math \
c30ab7b3 130 proc_macro syntax_ext
3157f602
XL
131DEPS_rustc_passes := syntax syntax_pos rustc core rustc_const_eval rustc_errors
132DEPS_rustc_mir := rustc syntax syntax_pos rustc_const_math rustc_const_eval rustc_bitflags
133DEPS_rustc_resolve := arena rustc log syntax syntax_pos rustc_errors
54a0048b 134DEPS_rustc_platform_intrinsics := std
3157f602
XL
135DEPS_rustc_plugin := rustc rustc_metadata syntax syntax_pos rustc_errors
136DEPS_rustc_privacy := rustc log syntax syntax_pos
137DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
54a0048b 138 log syntax serialize rustc_llvm rustc_platform_intrinsics \
3157f602 139 rustc_const_math rustc_const_eval rustc_incremental rustc_errors syntax_pos
9e0c209e 140DEPS_rustc_incremental := rustc syntax_pos serialize rustc_data_structures
3157f602
XL
141DEPS_rustc_save_analysis := rustc log syntax syntax_pos serialize
142DEPS_rustc_typeck := rustc syntax syntax_pos rustc_platform_intrinsics rustc_const_math \
143 rustc_const_eval rustc_errors
b039eaaf 144
9e0c209e
SL
145DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts test \
146 rustc_lint rustc_const_eval syntax_pos rustc_data_structures
1a4d82fc 147
a7813a04 148TOOL_DEPS_compiletest := test getopts log serialize
1a4d82fc
JJ
149TOOL_DEPS_rustdoc := rustdoc
150TOOL_DEPS_rustc := rustc_driver
85aaf69f 151TOOL_DEPS_rustbook := std rustdoc
7453a54e 152TOOL_DEPS_error_index_generator := rustdoc syntax serialize
a7813a04 153TOOL_SOURCE_compiletest := $(S)src/tools/compiletest/src/main.rs
1a4d82fc
JJ
154TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
155TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
54a0048b
SL
156TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
157TOOL_SOURCE_error_index_generator := $(S)src/tools/error_index_generator/main.rs
1a4d82fc 158
9e0c209e 159ONLY_RLIB_compiler_builtins := 1
1a4d82fc
JJ
160ONLY_RLIB_core := 1
161ONLY_RLIB_libc := 1
162ONLY_RLIB_alloc := 1
163ONLY_RLIB_rand := 1
164ONLY_RLIB_collections := 1
d9579d0f 165ONLY_RLIB_rustc_unicode := 1
85aaf69f 166ONLY_RLIB_rustc_bitflags := 1
e9174d1e 167ONLY_RLIB_alloc_system := 1
7453a54e 168ONLY_RLIB_alloc_jemalloc := 1
a7813a04
XL
169ONLY_RLIB_panic_unwind := 1
170ONLY_RLIB_panic_abort := 1
171ONLY_RLIB_unwind := 1
7453a54e
SL
172
173TARGET_SPECIFIC_alloc_jemalloc := 1
1a4d82fc 174
9346a6ac 175# Documented-by-default crates
d9579d0f
AL
176DOC_CRATES := std alloc collections core libc rustc_unicode
177
e9174d1e 178ifeq ($(CFG_DISABLE_JEMALLOC),)
7453a54e 179RUSTFLAGS_rustc_back := --cfg 'feature="jemalloc"'
e9174d1e
SL
180endif
181
1a4d82fc
JJ
182################################################################################
183# You should not need to edit below this line
184################################################################################
185
e9174d1e
SL
186CRATES := $(TARGET_CRATES) $(HOST_CRATES)
187
1a4d82fc
JJ
188# This macro creates some simple definitions for each crate being built, just
189# some munging of all of the parameters above.
190#
191# $(1) is the crate to generate variables for
192define RUST_CRATE
62682a34 193CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
1a4d82fc 194RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
1a4d82fc
JJ
195NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
196endef
197
198$(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))
199
7453a54e
SL
200# $(1) - crate
201# $(2) - target
202define RUST_CRATE_DEPS
203RUST_DEPS_$(1)_T_$(2) := $$(filter-out native:%,$$(DEPS_$(1)))
204endef
205
206$(foreach target,$(CFG_TARGET),\
207 $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE_DEPS,$(crate),$(target)))))
208
209# $(1) - target
210# $(2) - crate
211define DEFINE_TARGET_CRATES
212ifndef TARGET_SPECIFIC_$(2)
213TARGET_CRATES_$(1) += $(2)
214endif
215endef
216
217$(foreach target,$(CFG_TARGET),\
218 $(foreach crate,$(TARGET_CRATES),\
219 $(eval $(call DEFINE_TARGET_CRATES,$(target),$(crate)))))
220
1a4d82fc
JJ
221# Similar to the macro above for crates, this macro is for tools
222#
223# $(1) is the crate to generate variables for
224define RUST_TOOL
225TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
226endef
227
228$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
d9579d0f 229
92a42be0
SL
230CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
231RUSTFLAGS_libc := --cfg stdbuild