Skip to content

Commit

Permalink
library-ifying of tools - turning cargo, rustdoc, fuzzer, into librar…
Browse files Browse the repository at this point in the history
…ies, as per #3543
  • Loading branch information
Daniel Patterson authored and catamorphism committed Nov 4, 2012
1 parent 563aa0b commit 6c79d78
Show file tree
Hide file tree
Showing 45 changed files with 112 additions and 22 deletions.
9 changes: 9 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,24 @@ CFG_CORELIB :=$(call CFG_LIB_NAME,core)
CFG_STDLIB :=$(call CFG_LIB_NAME,std)
CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
CFG_LIBSYNTAX :=$(call CFG_LIB_NAME,syntax)
CFG_LIBFUZZER :=$(call CFG_LIB_NAME,fuzzer)
CFG_LIBCARGO :=$(call CFG_LIB_NAME,cargo)
CFG_LIBRUSTDOC :=$(call CFG_LIB_NAME,rustdoc)

STDLIB_GLOB :=$(call CFG_LIB_GLOB,std)
CORELIB_GLOB :=$(call CFG_LIB_GLOB,core)
LIBRUSTC_GLOB :=$(call CFG_LIB_GLOB,rustc)
LIBSYNTAX_GLOB :=$(call CFG_LIB_GLOB,syntax)
LIBFUZZER_GLOB :=$(call CFG_LIB_GLOB,fuzzer)
LIBCARGO_GLOB :=$(call CFG_LIB_GLOB,cargo)
LIBRUSTDOC_GLOB :=$(call CFG_LIB_GLOB,rustdoc)
STDLIB_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,std)
CORELIB_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,core)
LIBRUSTC_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,rustc)
LIBSYNTAX_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,syntax)
LIBFUZZER_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,fuzzer)
LIBCARGO_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,cargo)
LIBRUSTDOC_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,rustdoc)

# version-string calculation
CFG_GIT_DIR := $(CFG_SRC_DIR).git
Expand Down
12 changes: 12 additions & 0 deletions mk/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ clean$(1)_H_$(2):
$(Q)rm -f $$(HBIN$(1)_H_$(2))/cargo$(X)
$(Q)rm -f $$(HBIN$(1)_H_$(2))/serializer$(X)
$(Q)rm -f $$(HBIN$(1)_H_$(2))/rustdoc$(X)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBFUZZER)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBCARGO)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTDOC)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_RUNTIME)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_CORELIB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_STDLIB)
Expand All @@ -66,6 +69,9 @@ clean$(1)_H_$(2):
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(STDLIB_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTC_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBSYNTAX_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBFUZZER_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBCARGO_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTDOC_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_RUSTLLVM)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/libstd.rlib

Expand All @@ -83,6 +89,9 @@ clean$(1)_T_$(2)_H_$(3):
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/cargo$(X)
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/serializer$(X)
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustdoc$(X)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBFUZZER)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBCARGO)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOC)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB)
Expand All @@ -92,6 +101,9 @@ clean$(1)_T_$(2)_H_$(3):
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(STDLIB_GLOB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTC_GLOB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBSYNTAX_GLOB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBFUZZER_GLOB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBCARGO_GLOB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTDOC_GLOB)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM)
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
Expand Down
7 changes: 7 additions & 0 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ install-host: $(SREQ$(ISTAGE)_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE))
$(Q)mkdir -p $(PREFIX_LIB)
$(Q)mkdir -p $(PREFIX_ROOT)/share/man/man1
$(Q)$(call INSTALL,$(HB2),$(PHB),rustc$(X))
$(Q)$(call INSTALL,$(HB2),$(PHB),fuzzer$(X))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_LIBFUZZER))
$(Q)$(call INSTALL,$(HB2),$(PHB),cargo$(X))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_LIBCARGO))
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_LIBRUSTDOC))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME))
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(CORELIB_GLOB))
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(STDLIB_GLOB))
Expand All @@ -93,6 +97,9 @@ uninstall:
$(Q)rm -f $(PHB)/cargo$(X)
$(Q)rm -f $(PHB)/rustdoc$(X)
$(Q)rm -f $(PHL)/$(CFG_RUSTLLVM)
$(Q)rm -f $(PHL)/$(CFG_FUZZER)
$(Q)rm -f $(PHL)/$(CFG_CARGO)
$(Q)rm -f $(PHL)/$(CFG_RUSTDOC)
$(Q)rm -f $(PHL)/$(CFG_RUNTIME)
$(Q)for i in \
$(call HOST_LIB_FROM_HL_GLOB,$(CORELIB_GLOB)) \
Expand Down
2 changes: 1 addition & 1 deletion mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM): \
$$(Q)cp $$< $$@

$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X): \
$$(RUSTC_INPUTS) \
$$(RUSTC_INPUTS) \
$$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$<
Expand Down
79 changes: 61 additions & 18 deletions mk/tools.mk
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
# Rules for non-core tools built with the compiler, both for target
# and host architectures

FUZZER_CRATE := $(S)src/fuzzer/fuzzer.rc
FUZZER_INPUTS := $(wildcard $(addprefix $(S)src/fuzzer/, *.rs))
TOOL_DRIVER := $(S)src/driver/driver.rs

FUZZER_LIB := $(S)src/libfuzzer/fuzzer.rc
FUZZER_INPUTS := $(wildcard $(addprefix $(S)src/libfuzzer/, *.rs))

# The test runner that runs the cfail/rfail/rpass and bench tests
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rc
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*rs)

# Cargo, the package manager
CARGO_CRATE := $(S)src/cargo/cargo.rc
CARGO_LIB := $(S)src/libcargo/cargo.rc
CARGO_INPUTS := $(wildcard $(S)src/cargo/*rs)

# Rustdoc, the documentation tool
RUSTDOC_CRATE := $(S)src/rustdoc/rustdoc.rc
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rc
RUSTDOC_INPUTS := $(wildcard $(S)src/rustdoc/*.rs)

# FIXME: These are only built for the host arch. Eventually we'll
# have tools that need to built for other targets.
define TOOLS_STAGE_N

$$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X): \
$$(FUZZER_CRATE) $$(FUZZER_INPUTS) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBFUZZER): \
$$(FUZZER_LIB) $$(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: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$<
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X): \
$$(TOOL_DRIVER) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBFUZZER)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg fuzzer -o $$@ $$<

# Promote the stageN target to stageN+1 host
# FIXME: Shouldn't need to depend on host/librustc.so once
# rpath is working
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBFUZZER): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBFUZZER) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC) \
$$(HSREQ$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

$$(HBIN$(2)_H_$(4))/fuzzer$$(X): \
$$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBFUZZER) \
$$(HSREQ$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
Expand All @@ -53,32 +68,60 @@ $$(HBIN$(2)_H_$(4))/compiletest$$(X): \
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \
$$(CARGO_CRATE) $$(CARGO_INPUTS) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO): \
$$(CARGO_LIB) $$(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_CORELIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$<
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \
$$(TOOL_DRIVER) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg cargo -o $$@ $$<

$$(HLIB$(2)_H_$(4))/$$(CFG_LIBCARGO): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC) \
$$(HSREQ$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

$$(HBIN$(2)_H_$(4))/cargo$$(X): \
$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBCARGO) \
$$(HSREQ$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X): \
$$(RUSTDOC_CRATE) $$(RUSTDOC_INPUTS) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC): \
$$(RUSTDOC_LIB) $$(RUSTDOC_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_CORELIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$<
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X): \
$$(TOOL_DRIVER) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg rustdoc -o $$@ $$<

$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTDOC): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC) \
$$(HSREQ$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

$$(HBIN$(2)_H_$(4))/rustdoc$$(X): \
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X) \
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTDOC) \
$$(HSREQ$(2)_H_$(4))
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
Expand Down
13 changes: 13 additions & 0 deletions src/driver/driver.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[no_core];
extern mod core(vers = "0.5");

#[cfg(cargo)]
extern mod self(name = "cargo", vers = "0.5");

#[cfg(fuzzer)]
extern mod self(name = "fuzzer", vers = "0.5");

#[cfg(rustdoc)]
extern mod self(name = "rustdoc", vers = "0.5");

fn main() { self::main() }
2 changes: 1 addition & 1 deletion src/cargo/cargo.rc → src/libcargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
uuid = "9ff87a04-8fed-4295-9ff8-f99bb802650b",
url = "https://github.com/mozilla/rust/tree/master/src/cargo")];

#[crate_type = "bin"];
#[crate_type = "lib"];

#[no_core];
#[legacy_exports];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 7 additions & 1 deletion src/fuzzer/fuzzer.rc → src/libfuzzer/fuzzer.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// -*- rust -*-

#[crate_type = "bin"];
#[link(name = "fuzzer",
vers = "0.5",
uuid = "d6418797-2736-4833-bd82-d3c684b7c1b0",
url = "https://github.com/mozilla/rust/tree/master/src/libfuzzer")];

#[comment = "The Rust fuzzer library"];
#[license = "MIT"];
#[crate_type = "lib"];
#[no_core];

#[legacy_modes];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rustdoc/rustdoc.rc → src/librustdoc/rustdoc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#[comment = "The Rust documentation generator"];
#[license = "MIT"];
#[crate_type = "bin"];
#[crate_type = "lib"];

#[no_core];
#[legacy_modes];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6c79d78

Please sign in to comment.