crates.mk 7.7 KB
Newer Older
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
# Copyright 2014 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.

################################################################################
# Rust's standard distribution of crates and tools
#
# The crates outlined below are the standard distribution of libraries provided
# in a rust installation. These rules are meant to abstract over the
# dependencies (both native and rust) of crates and basically generate all the
# necessary makefile rules necessary to build everything.
#
# Here's an explanation of the variables below
#
#   TARGET_CRATES
#	This list of crates will be built for all targets, including
#	cross-compiled targets
#
#   HOST_CRATES
#	This list of crates will be compiled for only host targets. Note that
#	this set is explicitly *not* a subset of TARGET_CRATES, but rather it is
#	a disjoint set. Nothing in the TARGET_CRATES set can depend on crates in
#	the HOST_CRATES set, but the HOST_CRATES set can depend on target
#	crates.
#
#   TOOLS
#	A list of all tools which will be built as part of the compilation
#	process. It is currently assumed that most tools are built through
#	src/driver/driver.rs with a particular configuration (there's a
#	corresponding library providing the implementation)
#
#   DEPS_<crate>
#	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 43 44 45 46 47 48 49 50 51
#	will be built before the crate itself is built.
#
#   TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
#	Similar to the DEPS variable, this is the library crate dependencies
#	list for tool as well as the source file for the specified tool
#
# You shouldn't need to modify much other than these variables. Crates are
# automatically generated for all stage/host/target combinations.
################################################################################

52 53 54
TARGET_CRATES := libc std term \
                 getopts collections test rand \
                 core alloc \
55
                 rustc_unicode rustc_bitflags \
O
Oliver Schneider 已提交
56
		 alloc_system alloc_jemalloc rustc_const_eval
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
                rustc_plugin rustc_metadata rustc_passes
61 62
HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \
		flate arena graphviz rbml log serialize
63
TOOLS := compiletest rustdoc rustc rustbook error_index_generator
64

A
Alex Crichton 已提交
65
DEPS_core :=
N
Nick Cameron 已提交
66 67
DEPS_alloc := core libc alloc_system
DEPS_alloc_system := core libc
68
DEPS_alloc_jemalloc := core libc native:jemalloc
N
Nick Cameron 已提交
69
DEPS_collections := core alloc rustc_unicode
70
DEPS_libc := core
N
Nick Cameron 已提交
71 72
DEPS_rand := core
DEPS_rustc_bitflags := core
73
DEPS_rustc_unicode := core
N
Nick Cameron 已提交
74

75
DEPS_std := core libc rand alloc collections rustc_unicode \
76
	native:backtrace \
77
	alloc_system
N
Nick Cameron 已提交
78 79 80 81 82
DEPS_arena := std
DEPS_glob := std
DEPS_flate := std native:miniz
DEPS_fmt_macros = std
DEPS_getopts := std
83
DEPS_graphviz := std
N
Nick Cameron 已提交
84 85 86 87
DEPS_log := std
DEPS_num := std
DEPS_rbml := std log serialize
DEPS_serialize := std log
88 89
DEPS_term := std
DEPS_test := std getopts term native:rust_test_helpers
N
Nick Cameron 已提交
90

91
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode
92
DEPS_syntax_ext := syntax fmt_macros
N
Nick Cameron 已提交
93

O
Oliver Schneider 已提交
94 95
DEPS_rustc_const_eval := std syntax

96
DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml rustc_front\
O
Oliver Schneider 已提交
97 98
              log graphviz rustc_llvm rustc_back rustc_data_structures\
		  	  rustc_const_eval
N
Nick Cameron 已提交
99
DEPS_rustc_back := std syntax rustc_llvm rustc_front flate log libc
100
DEPS_rustc_borrowck := rustc rustc_front rustc_mir log graphviz syntax
N
Nick Cameron 已提交
101
DEPS_rustc_data_structures := std log serialize
102
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
103
                     rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
104
	             rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin \
105
                     rustc_metadata syntax_ext rustc_passes
106
DEPS_rustc_front := std syntax log serialize
107
DEPS_rustc_lint := rustc log syntax
108
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
O
Oliver Schneider 已提交
109
DEPS_rustc_metadata := rustc rustc_front syntax rbml rustc_const_eval
110
DEPS_rustc_passes := syntax rustc core rustc_front
O
Oliver Schneider 已提交
111
DEPS_rustc_mir := rustc rustc_front syntax rustc_const_eval
112
DEPS_rustc_resolve := arena rustc rustc_front log syntax
113
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
114
DEPS_rustc_plugin := rustc rustc_metadata syntax rustc_mir
N
Nick Cameron 已提交
115
DEPS_rustc_privacy := rustc rustc_front log syntax
N
Niko Matsakis 已提交
116
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
O
Oliver Schneider 已提交
117 118 119
                    log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics \
					rustc_const_eval
DEPS_rustc_typeck := rustc syntax rustc_front rustc_platform_intrinsics rustc_const_eval
N
Nick Cameron 已提交
120

121
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
122
                test rustc_lint rustc_front
N
Nick Cameron 已提交
123

124

A
Aaron Turon 已提交
125 126
TOOL_DEPS_compiletest := test getopts
TOOL_DEPS_rustdoc := rustdoc
127
TOOL_DEPS_rustc := rustc_driver
A
Alex Crichton 已提交
128
TOOL_DEPS_rustbook := std rustdoc
129
TOOL_DEPS_error_index_generator := rustdoc syntax serialize
130 131 132
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
133
TOOL_SOURCE_rustbook := $(S)src/tools/rustbook/main.rs
134
TOOL_SOURCE_error_index_generator := $(S)src/tools/error_index_generator/main.rs
135

A
Alex Crichton 已提交
136
ONLY_RLIB_core := 1
H
Huon Wilson 已提交
137
ONLY_RLIB_libc := 1
138
ONLY_RLIB_alloc := 1
A
Alex Crichton 已提交
139
ONLY_RLIB_rand := 1
140
ONLY_RLIB_collections := 1
141
ONLY_RLIB_rustc_unicode := 1
142
ONLY_RLIB_rustc_bitflags := 1
143
ONLY_RLIB_alloc_system := 1
144 145 146
ONLY_RLIB_alloc_jemalloc := 1

TARGET_SPECIFIC_alloc_jemalloc := 1
A
Alex Crichton 已提交
147

148
# Documented-by-default crates
149
DOC_CRATES := std alloc collections core libc rustc_unicode
150

151
ifeq ($(CFG_DISABLE_JEMALLOC),)
152
RUSTFLAGS_rustc_back := --cfg 'feature="jemalloc"'
153 154
endif

155 156 157 158
################################################################################
# You should not need to edit below this line
################################################################################

159 160
CRATES := $(TARGET_CRATES) $(HOST_CRATES)

161 162 163 164 165
# This macro creates some simple definitions for each crate being built, just
# some munging of all of the parameters above.
#
# $(1) is the crate to generate variables for
define RUST_CRATE
166
CRATEFILE_$(1) := $$(SREL)src/lib$(1)/lib.rs
167
RSINPUTS_$(1) := $$(call rwildcard,$(S)src/lib$(1)/,*.rs)
168 169 170 171 172
NATIVE_DEPS_$(1) := $$(patsubst native:%,%,$$(filter native:%,$$(DEPS_$(1))))
endef

$(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate))))

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
# $(1) - crate
# $(2) - target
define RUST_CRATE_DEPS
RUST_DEPS_$(1)_T_$(2) := $$(filter-out native:%,$$(DEPS_$(1)))
endef

$(foreach target,$(CFG_TARGET),\
 $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE_DEPS,$(crate),$(target)))))

# $(1) - target
# $(2) - crate
define DEFINE_TARGET_CRATES
ifndef TARGET_SPECIFIC_$(2)
TARGET_CRATES_$(1) += $(2)
endif
endef

$(foreach target,$(CFG_TARGET),\
 $(foreach crate,$(TARGET_CRATES),\
  $(eval $(call DEFINE_TARGET_CRATES,$(target),$(crate)))))

194 195 196 197
# Similar to the macro above for crates, this macro is for tools
#
# $(1) is the crate to generate variables for
define RUST_TOOL
198
TOOL_INPUTS_$(1) := $$(call rwildcard,$$(dir $$(TOOL_SOURCE_$(1))),*.rs)
199 200 201
endef

$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
202

A
Alex Crichton 已提交
203 204
CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
RUSTFLAGS_libc := --cfg stdbuild