Establish 'core' library separate from 'std'.

This commit is contained in:
Graydon Hoare 2011-12-05 16:46:37 -08:00
parent b513a5a500
commit 447414f007
76 changed files with 114 additions and 30 deletions

View File

@ -104,6 +104,7 @@ endif
CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
CFG_CORELIB :=$(call CFG_LIB_NAME,core)
CFG_STDLIB :=$(call CFG_LIB_NAME,ruststd)
CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
@ -144,9 +145,9 @@ else
endif
ifeq ($(CFG_NATURALDOCS),)
$(info cfg: no naturaldocs found, omitting doc/std/index.html)
$(info cfg: no naturaldocs found, omitting library doc build)
else
DOCS += doc/std/index.html
DOCS += doc/core/index.html doc/std/index.html
endif
ifdef CFG_DISABLE_DOCS
@ -183,12 +184,21 @@ GENERATED :=
%:: s.%
%:: SCCS/s.%
######################################################################
# Core library variables
######################################################################
CORELIB_CRATE := $(S)src/libcore/core.rc
CORELIB_INPUTS := $(wildcard $(addprefix $(S)src/libcore/, \
core.rc *.rs */*.rs))
######################################################################
# Standard library variables
######################################################################
STDLIB_CRATE := $(S)src/lib/std.rc
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs))
STDLIB_CRATE := $(S)src/libstd/std.rc
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
std.rc *.rs */*.rs))
######################################################################
# rustc crate variables
@ -268,13 +278,21 @@ TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
# The name of the standard library used by rustc
# The name of the core and standard libraries used by rustc
ifdef CFG_DISABLE_SHAREDSTD
HCORELIB_DEFAULT$(1)_H_$(3) = \
$$(HLIB$(1)_H_$(3))/libcore.rlib
TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
$$(TLIB$(1)_T_$(2)_H_$(3))/libcore.rlib
HSTDLIB_DEFAULT$(1)_H_$(3) = \
$$(HLIB$(1)_H_$(3))/libstd.rlib
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
$$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
else
HCORELIB_DEFAULT$(1)_H_$(3) = \
$$(HLIB$(1)_H_$(3))/$(CFG_CORELIB)
TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB)
HSTDLIB_DEFAULT$(1)_H_$(3) = \
$$(HLIB$(1)_H_$(3))/$(CFG_STDLIB)
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
@ -286,6 +304,7 @@ HSREQ$(1)_H_$(3) = \
$$(HBIN$(1)_H_$(3))/rustc$$(X) \
$$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME) \
$$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLLVM) \
$$(HCORELIB_DEFAULT$(1)_H_$(3)) \
$$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
$$(MKFILE_DEPS)
@ -299,6 +318,7 @@ TSREQ$(1)_T_$(2)_H_$(3) = \
# Prerequisites for complete stageN targets
SREQ$(1)_T_$(2)_H_$(3) = \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB)
ifeq ($(1),0)

4
configure vendored
View File

@ -355,8 +355,8 @@ fi
step_msg "making directories"
for i in \
doc doc/std \
nd nd/std \
doc doc/core doc/std \
nd nd/core nd/std \
dl tmp
do
make_dir $i

8
doc/lib.css Normal file
View File

@ -0,0 +1,8 @@
/*
Custom styles for the library docs generated by naturaldocs
*/
p {
text-indent: 0;
margin-bottom: 1em;
}

View File

@ -1,8 +0,0 @@
/*
Custom styles for the standard library docs generated by naturaldocs
*/
p {
text-indent: 0;
margin-bottom: 1em;
}

View File

@ -46,6 +46,7 @@ PKG_FILES = \
$(PKG_3RDPARTY)) \
$(PKG_UV) \
$(COMPILER_INPUTS) \
$(CORELIB_INPUTS) \
$(STDLIB_INPUTS) \
$(ALL_TEST_INPUTS) \
$(FUZZER_CRATE) \

View File

@ -29,19 +29,25 @@ docsnap: doc/rust.pdf
@$(call E, snap: doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf)
$(Q)mv $< doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf
doc/std/index.html: nd/std/Languages.txt nd/std/Topics.txt nd/std/std.css \
$(STDLIB_CRATE) $(STDLIB_INPUTS)
@$(call E, naturaldocs: $@)
naturaldocs -i $(S)src/lib -o HTML doc/std -p nd/std -r -s Default std
define libdoc
doc/$(1)/index.html: nd/$(1)/Languages.txt nd/$(1)/Topics.txt \
nd/$(1)/lib.css $(2)
@$$(call E, naturaldocs: $$@)
naturaldocs -i $(S)src/lib$(1) -o HTML doc/$(1) -p nd/$(1) -r -s Default lib
nd/std/Languages.txt: $(S)doc/Languages.txt
@$(call E, cp: $@)
$(Q)cp $< $@
nd/$(1)/Languages.txt: $(S)doc/Languages.txt
@$$(call E, cp: $$@)
$(Q)cp $$< $$@
nd/std/Topics.txt: $(S)doc/Topics.txt
@$(call E, cp: $@)
$(Q)cp $< $@
nd/$(1)/Topics.txt: $(S)doc/Topics.txt
@$$(call E, cp: $$@)
$(Q)cp $$< $$@
nd/std/std.css: $(S)doc/std.css
@$(call E, cp: $@)
$(Q)cp $< $@
nd/$(1)/lib.css: $(S)doc/lib.css
@$$(call E, cp: $$@)
$(Q)cp $$< $$@
endef
$(eval $(call libdoc,core,$(CORELIB_CRATE) $(CORELIB_INPUTS)))
$(eval $(call libdoc,std,$(STDLIB_CRATE) $(STDLIB_INPUTS)))

View File

@ -15,6 +15,7 @@ $$(HBIN$(2)_H_$(4))/rustc$$(X): \
$$(TBIN$(1)_T_$(4)_H_$(3))/rustc$$(X) \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUSTLLVM) \
$$(HCORELIB_DEFAULT$(2)_H_$(4)) \
$$(HSTDLIB_DEFAULT$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
@ -25,6 +26,7 @@ $$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC) \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME) \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUSTLLVM) \
$$(HCORELIB_DEFAULT$(2)_H_$(3)) \
$$(HSTDLIB_DEFAULT$(2)_H_$(3))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
@ -34,14 +36,28 @@ $$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME): \
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(HLIB$(2)_H_$(4))/$$(CFG_CORELIB): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(HLIB$(2)_H_$(4))/$$(CFG_STDLIB): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(HLIB$(2)_H_$(4))/$$(CFG_CORELIB) \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(HLIB$(2)_H_$(4))/libcore.rlib: \
$$(TLIB$(1)_T_$(4)_H_$(3))/libcore.rlib \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(HLIB$(2)_H_$(4))/libstd.rlib: \
$$(TLIB$(1)_T_$(4)_H_$(3))/libstd.rlib \
$$(HLIB$(2)_H_$(4))/libcore.rlib \
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

View File

@ -33,6 +33,7 @@ PTL$(1)$(2) = $$(PTR$(1)$(2))/lib
install-target-$(1)-host-$(2): $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
$$(Q)mkdir -p $$(PTL$(1)$(2))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_CORELIB))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_STDLIB))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),intrinsics.bc)
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a)
@ -61,6 +62,7 @@ install-host: $(SREQ$(ISTAGE)_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE))
$(Q)mkdir -p $(PREFIX_ROOT)/share/man/man1
$(Q)$(call INSTALL,$(HB),$(PHB),rustc$(X))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_CORELIB))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_STDLIB))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM))
$(Q)$(call INSTALL,$(S)/man, \

View File

@ -2,7 +2,8 @@
ifdef PPFILES
PP_INPUTS_FILTERED := $(wildcard $(PPFILES))
else
PP_INPUTS = $(wildcard $(addprefix $(S)src/lib/,*.rs */*.rs)) \
PP_INPUTS = $(wildcard $(addprefix $(S)src/libcore/,*.rs */*.rs)) \
$(wildcard $(addprefix $(S)src/libstd/,*.rs */*.rs)) \
$(wildcard $(addprefix $(S)src/comp/,*.rs */*.rs */*/*.rs)) \
$(wildcard $(S)src/test/*/*.rs \
$(S)src/test/*/*/*.rs) \

View File

@ -13,6 +13,10 @@ $(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_RUNTIME): \
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
$(Q)touch $@
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_CORELIB): \
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
$(Q)touch $@
$(HLIB0_H_$(CFG_HOST_TRIPLE))/$(CFG_STDLIB): \
$(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X)
$(Q)touch $@
@ -38,6 +42,11 @@ $$(HLIB0_H_$(1))/$$(CFG_RUNTIME): \
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(HLIB0_H_$(1))/$(CFG_CORELIB): \
$$(TLIB$(2)_T_$(1)_H_$(3))/$$(CFG_CORELIB)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(HLIB0_H_$(1))/$(CFG_STDLIB): \
$$(TLIB$(2)_T_$(1)_H_$(3))/$$(CFG_STDLIB)
@$$(call E, cp: $$@)

View File

@ -22,8 +22,15 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
$$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
$$(TSREQ$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$<
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TSREQ$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$<

View File

@ -87,6 +87,8 @@ tidy:
$(wildcard $(S)src/etc/*.py) \
$(COMPILER_CRATE) \
$(COMPILER_INPUTS) \
$(CORELIB_CRATE) \
$(CORELIB_INPUTS) \
$(STDLIB_CRATE) \
$(STDLIB_INPUTS) \
$(COMPILETEST_CRATE) \
@ -475,4 +477,4 @@ endef
$(foreach stage,$(STAGES), \
$(eval $(call DEF_CHECK_FOR_STAGE,$(stage))))
check-fast: check-fast-H-$(CFG_HOST_TRIPLE)
check-fast: check-fast-H-$(CFG_HOST_TRIPLE)

View File

@ -19,6 +19,7 @@ define TOOLS_STAGE_N
$$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X): \
$$(FUZZER_CRATE) $$(FUZZER_INPUTS) \
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
@ -37,6 +38,7 @@ $$(HBIN$(2)_H_$(4))/fuzzer$$(X): \
$$(TBIN$(1)_T_$(4)_H_$(3))/compiletest$$(X): \
$$(COMPILETEST_CRATE) $$(COMPILETEST_INPUTS) \
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$<
@ -50,6 +52,7 @@ $$(HBIN$(2)_H_$(4))/compiletest$$(X): \
$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \
$$(CARGO_CRATE) $$(CARGO_INPUTS) \
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)

17
src/libcore/core.rc Normal file
View File

@ -0,0 +1,17 @@
#[link(name = "core",
vers = "0.1",
uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
url = "http://rust-lang.org/src/core")];
#[comment = "The Rust core library"];
#[license = "BSD"];
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End: