From: Evan McClanahan Date: Thu, 5 Apr 2012 22:40:34 +0000 (-0700) Subject: add the option --enable-local-rust to pull rust from your environment X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=2c93b1b2df6500ca52bd2f1ffb179acc0bf368c4;p=rust.git add the option --enable-local-rust to pull rust from your environment 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. --- diff --git a/configure b/configure index ac05cc8b954..06f385c1da3 100755 --- 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 diff --git a/mk/stage0.mk b/mk/stage0.mk index b790c2f9f2d..e55b9f70c8f 100644 --- a/mk/stage0.mk +++ b/mk/stage0.mk @@ -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 index 00000000000..e4d7b61c4a3 --- /dev/null +++ b/src/etc/local_stage0.sh @@ -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}/