]> git.lizzy.rs Git - rust.git/commitdiff
add the option --enable-local-rust to pull rust from your environment
authorEvan McClanahan <evan@evanmcc.com>
Thu, 5 Apr 2012 22:40:34 +0000 (15:40 -0700)
committerEvan McClanahan <mcclanahan@gmail.com>
Wed, 11 Apr 2012 03:32:40 +0000 (20:32 -0700)
rather than the snapshots.

make sure to get all of the files.

update to add nmatsakis' requested feature of pointing to a
different rustc install root.

usage: --enable-local-rust to enable
--local-rust-root="/path/to/rustc/" to change the path, which defaults to
"/usr/local/"

Tested on OS X and Linux, likely broken on windows.

configure
mk/stage0.mk
src/etc/local_stage0.sh [new file with mode: 0755]

index ac05cc8b954d1dd4ee3e1cf7905b5e22b32fb283..06f385c1da338971b7a15620f4f409776e6a4098 100755 (executable)
--- a/configure
+++ b/configure
@@ -294,7 +294,9 @@ opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
 opt manage-submodules 1 "let the build manage the git submodules"
 opt mingw-cross 0 "cross-compile for win32 using mingw"
 opt clang 0 "prefer clang to gcc for building the runtime"
+opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
 valopt prefix "/usr/local" "set installation prefix"
+valopt local-rust-root "/usr/local" "set prefix for local rust binary"
 valopt llvm-root "" "set LLVM root"
 valopt host-triple "${DEFAULT_HOST_TRIPLE}" "LLVM host triple"
 valopt target-triples "${CFG_HOST_TRIPLE}" "LLVM target triples"
@@ -337,7 +339,6 @@ probe CFG_XETEX            xetex
 probe CFG_LUATEX           luatex
 probe CFG_NODE             nodejs node
 
-
 if [ ! -z "$CFG_PANDOC" ]
 then
     PV=$(pandoc --version | awk '/^pandoc/ {print $2}')
@@ -348,6 +349,14 @@ then
     fi
 fi
 
+if [ ! -z "$CFG_ENABLE_LOCAL_RUST" -a ! -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc ]
+then
+    err "no local rust to use"
+else
+    LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version`
+    step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: " $LRV
+fi
+
 if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
 then
     err "either clang or gcc is required"
@@ -716,7 +725,6 @@ do
     putvar $CFG_LLVM_INST_DIR
 done
 
-
 # Munge any paths that appear in config.mk back to posix-y
 perl -i.bak -p -e 's@ ([a-zA-Z]):[/\\]@ /\1/@go;' \
                -e 's@\\@/@go;' config.tmp
index b790c2f9f2de20f32608b7cb28369842bacd28d5..e55b9f70c8ff0134c727dab7fa99cb8d1931ba68 100644 (file)
@@ -1,12 +1,18 @@
 # Extract the snapshot host compiler
 
+
+
 $(HBIN0_H_$(CFG_HOST_TRIPLE))/rustc$(X):               \
                $(S)src/snapshots.txt                                   \
                $(S)src/etc/get-snapshot.py $(MKFILE_DEPS)
        @$(call E, fetch: $@)
 #   Note: the variable "SNAPSHOT_FILE" is generally not set, and so
 #   we generally only pass one argument to this script.  
+ifdef CFG_ENABLE_LOCAL_RUST
+       $(Q)$(S)src/etc/local_stage0.sh $(CFG_HOST_TRIPLE) $(CFG_LOCAL_RUST_ROOT)
+else 
        $(Q)$(S)src/etc/get-snapshot.py $(CFG_HOST_TRIPLE) $(SNAPSHOT_FILE)
+endif 
        $(Q)touch $@
 
 # Host libs will be extracted by the above rule
diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh
new file mode 100755 (executable)
index 0000000..e4d7b61
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+TARG_DIR=$1 
+PREFIX=$2
+
+BINDIR=bin
+LIBDIR=lib
+
+OS=`uname -s`
+case $OS in 
+    ("Linux"|"FreeBSD")
+       BIN_SUF=
+       LIB_SUF=.so
+       break
+       ;;
+    ("Darwin")
+       BIN_SUF=
+       LIB_SUF=.dylib
+       break
+       ;;
+    (*)
+       BIN_SUF=.exe
+       LIB_SUF=.dll
+       LIBDIR=bin
+       break
+       ;;
+esac
+
+if [ -z $PREFIX ]; then
+    echo "No local rust specified."
+    exit 1
+fi
+
+if [ ! -e ${PREFIX}/bin/rustc ]; then
+    echo "No local rust installed at ${PREFIX}"
+    exit 1
+fi
+
+if [ -z $TARG_DIR ]; then
+    echo "No target directory specified."
+    exit 1
+fi
+
+cp ${PREFIX}/bin/rustc ${TARG_DIR}/stage0/bin/
+cp ${PREFIX}/lib/rustc/${TARG_DIR}/${LIBDIR}/* ${TARG_DIR}/stage0/${LIBDIR}/
+cp ${PREFIX}/lib/librust*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
+cp ${PREFIX}/lib/libcore*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
+cp ${PREFIX}/lib/libstd*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/