Merge remote-tracking branch 'origin/master'

This commit is contained in:
Andelf
2014-10-20 22:00:44 +08:00
+24 -21
View File
@@ -68,20 +68,20 @@ endif
RUSTDOC = rustdoc
# Extracts target from rustc.
TARGET = $(shell rustc --version 2> /dev/null | awk "/host:/ { print \$$2 }")
TARGET = $(shell rustc --version verbose 2> /dev/null | awk "/host:/ { print \$$2 }")
# TARGET = x86_64-unknown-linux-gnu
# TARGET = x86_64-apple-darwin
TARGET_LIB_DIR = target/$(TARGET)/lib/
TARGET_LIB_DIR = target/deps/
# Ask 'rustc' the file name of the library and use a dummy name if the source has not been created yet.
# The dummy file name is used to trigger the creation of the source first time.
# Next time 'rustc' will return the right file name.
RLIB_FILE = $(shell (rustc --crate-type=rlib --crate-file-name "$(LIB_ENTRY_FILE)" 2> /dev/null) || (echo "dummy.rlib"))
# You can't have quotes around paths because 'make' doesn't see it exists.
RLIB = target/$(TARGET)/lib/$(RLIB_FILE)
RLIB = target/$(RLIB_FILE)
DYLIB_FILE = $(shell (rustc --crate-type=dylib --crate-file-name "$(LIB_ENTRY_FILE)" 2> /dev/null) || (echo "dummy.dylib"))
DYLIB = target/$(TARGET)/lib/$(DYLIB_FILE)
DYLIB = target/$(DYLIB_FILE)
# Use 'VERBOSE=1' to echo all commands, for example 'make help VERBOSE=1'.
ifdef VERBOSE
@@ -93,7 +93,7 @@ endif
all: $(DEFAULT)
help:
$(Q)echo "--- rust-empty (0.5 007)"
$(Q)echo "--- rust-empty (0.6 003)"
$(Q)echo "make run - Runs executable"
$(Q)echo "make exe - Builds main executable"
$(Q)echo "make lib - Both static and dynamic library"
@@ -110,8 +110,8 @@ help:
$(Q)echo "make examples - Builds examples"
$(Q)echo "make cargo-lite-exe - Setup executable package"
$(Q)echo "make cargo-lite-lib - Setup library package"
$(Q)echo "make cargo-exe - EXPERIMENTAL: Setup executable package"
$(Q)echo "make cargo-lib - EXPERIMENTAL: Setup library package"
$(Q)echo "make cargo-exe - Setup executable package"
$(Q)echo "make cargo-lib - Setup library package"
$(Q)echo "make rust-ci-lib - Setup Travis CI Rust library"
$(Q)echo "make rust-ci-exe - Setup Travis CI Rust executable"
$(Q)echo "make rusti - Setup 'rusti.sh' for interactive Rust"
@@ -211,12 +211,12 @@ cargo-exe: $(EXE_ENTRY_FILE)
( \
name=$${PWD##/*/} ; \
readme=$$((test -e README.md && echo -e "readme = \"README.md\"") || ("")) ; \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[bin]]\n\nname = \"$$name\"\npath = \"$(EXE_ENTRY_FILE)\"\n" > Cargo.toml \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[bin]]\n\nname = \"$$name\"\npath = \"$(EXE_ENTRY_FILE)\"\n" > Cargo.toml \
&& echo "--- Created 'Cargo.toml' for executable" \
&& cat Cargo.toml \
)
cargo-lib: $(EXE_ENTRY_FILE)
cargo-lib: $(LIB_ENTRY_FILE)
$(Q)( \
test -e Cargo.toml \
&& echo "--- The file 'Cargo.toml' already exists" \
@@ -225,7 +225,7 @@ cargo-lib: $(EXE_ENTRY_FILE)
( \
name=$${PWD##/*/} ; \
readme=$$((test -e README.md && echo -e "readme = \"README.md\"") || ("")) ; \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[lib]]\n\nname = \"$$name\"\npath = \"$(LIB_ENTRY_FILE)\"\n" > Cargo.toml \
echo -e "[package]\n\nname = \"$$name\"\nversion = \"0.0.0\"\n$$readme\nauthors = [\"Your Name <your@email.com>\"]\ntags = []\n\n[[lib]]\n\nname = \"$$name\"\npath = \"$(LIB_ENTRY_FILE)\"\n" > Cargo.toml \
&& echo "--- Created 'Cargo.toml' for executable" \
&& cat Cargo.toml \
)
@@ -255,7 +255,7 @@ rust-ci-exe: $(EXE_ENTRY_FILE)
)
doc: $(SOURCE_FILES) | src/
$(Q)$(RUSTDOC) $(LIB_ENTRY_FILE) -L "target/$(TARGET)/lib" \
$(Q)$(RUSTDOC) $(LIB_ENTRY_FILE) -L "$(TARGET_LIB_DIR)" \
&& echo "--- Built documentation"
run: exe
@@ -267,7 +267,7 @@ target-dir: $(TARGET_LIB_DIR)
exe: bin/main | $(TARGET_LIB_DIR)
bin/main: $(SOURCE_FILES) | bin/ $(EXE_ENTRY_FILE)
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $(EXE_ENTRY_FILE) -o bin/main -L "target/$(TARGET)/lib" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $(EXE_ENTRY_FILE) -o bin/main -L "$(TARGET_LIB_DIR)" -L "target" \
&& echo "--- Built executable" \
&& echo "--- Type 'make run' to run executable"
@@ -280,7 +280,7 @@ test-external: bin/test-external
&& ./test-external
bin/test-external: $(SOURCE_FILES) | rlib bin/ src/test.rs
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test src/test.rs -o bin/test-external -L "target/$(TARGET)/lib" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test src/test.rs -o bin/test-external -L "$(TARGET_LIB_DIR)" -L "target" \
&& echo "--- Built external test runner"
test-internal: bin/test-internal
@@ -288,7 +288,7 @@ test-internal: bin/test-internal
&& ./test-internal
bin/test-internal: $(SOURCE_FILES) | rlib src/ bin/
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test $(LIB_ENTRY_FILE) -o bin/test-internal -L "target/$(TARGET)/lib" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --test $(LIB_ENTRY_FILE) -o bin/test-internal -L "$(TARGET_LIB_DIR)" -L "target" \
&& echo "--- Built internal test runner"
bench: bench-internal bench-external
@@ -305,13 +305,13 @@ lib: rlib dylib
rlib: $(RLIB)
$(RLIB): $(SOURCE_FILES) | $(LIB_ENTRY_FILE) $(TARGET_LIB_DIR)
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=rlib $(LIB_ENTRY_FILE) -L "target/$(TARGET)/lib" --out-dir "target/$(TARGET)/lib/" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=rlib $(LIB_ENTRY_FILE) -L "$(TARGET_LIB_DIR)" --out-dir "target" \
&& echo "--- Built rlib"
dylib: $(DYLIB)
$(DYLIB): $(SOURCE_FILES) | $(LIB_ENTRY_FILE) $(TARGET_LIB_DIR)
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=dylib $(LIB_ENTRY_FILE) -L "target/$(TARGET)/lib" --out-dir "target/$(TARGET)/lib/" \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) --crate-type=dylib $(LIB_ENTRY_FILE) -L "$(TARGET_LIB_DIR)" --out-dir "target/" \
&& echo "--- Built dylib"
bin/:
@@ -350,7 +350,7 @@ git-ignore:
examples: $(EXAMPLE_FILES)
$(EXAMPLE_FILES): lib examples-dir
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $@ -L "target/$(TARGET)/lib" --out-dir examples/ \
$(Q)$(COMPILER) --target "$(TARGET)" $(COMPILER_FLAGS) $@ -L "$(TARGET_LIB_DIR)" -L "target" --out-dir examples/ \
&& echo "--- Built '$@' (make $@)"
$(EXE_ENTRY_FILE): | src/
@@ -416,7 +416,7 @@ while true; do
echo -n "> "
read line
TMP="`mktemp r.XXXXXX`"
$(COMPILER) - -o $$TMP -L "target/$(TARGET)/lib/" <<EOF
$(COMPILER) - -o $$TMP -L "$(TARGET_LIB_DIR)" <<EOF
#![feature(globs, macro_rules, phase, struct_variant)]
extern crate arena;
extern crate collections;
@@ -585,7 +585,7 @@ function contains() {
i=0
function build_deps {
local current=$$(pwd)
for symlib in $$(find target/*/lib -type l) ; do
for symlib in $$(find $(TARGET_LIB_DIR) -type l) ; do
cd $$current
echo $$symlib
local original_file=$$(readlink $$symlib)
@@ -606,6 +606,7 @@ function build_deps {
# Remember git directory to not build it twice
git_dir[i]=$$current_git_dir
let i+=1
# Visit the symlinks and build the dependencies
build_deps
@@ -630,11 +631,13 @@ function build_deps {
&& $$MAKE clean \
&& $$MAKE \
)
let i+=1
done
cd $$current
}
# Mark main project as visited to avoid infinite loop.
git_dir[i]=$$(pwd)
let i+=1
if [ "$$1" == "deps" ]; then
build_deps
fi
@@ -675,7 +678,7 @@ loc:
# prints the commit hash with remote branches containing that commit.
symlink-info:
$(Q) current=$$(pwd) ; \
for symlib in $$(find target/*/lib -type l) ; do \
for symlib in $$(find $(TARGET_LIB_DIR) -type l) ; do \
cd $$current ; \
echo $$symlib ; \
original_file=$$(readlink $$symlib) ; \