10000 Merge pull request #26 from d3m3vilurr/feature/download-sourcecode · javanile/r@e873727 · GitHub
[go: up one dir, main page]

Skip to content

Commit e873727

Browse files
committed
Merge pull request sdepold#26 from d3m3vilurr/feature/download-sourcecode
rsvm.sh: New suboption `--with-rustc-source` for `install` command
2 parents 3688989 + dde7055 commit e873727

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

rsvm.fish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ function rsvm_mod_env
7070
rsvm_set_path DYLD_LIBRARY_PATH $p[2..-1]
7171
else if test $p[1] = MANPATH
7272
rsvm_set_path MANPATH $p[2..-1]
73+
else if test $p[1] = RUST_SRC_PATH
74+
rsvm_set_path RUST_SRC_PATH $p[2..-1]
7375
end
7476
end
7577

rsvm.sh

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export PATH=$(rsvm_append_path $PATH $RSVM_DIR/current/dist/bin)
8383
export LD_LIBRARY_PATH=$(rsvm_append_path $LD_LIBRARY_PATH $RSVM_DIR/current/dist/lib)
8484
export DYLD_LIBRARY_PATH=$(rsvm_append_path $DYLD_LIBRARY_PATH $RSVM_DIR/current/dist/lib)
8585
export MANPATH=$(rsvm_append_path $MANPATH $RSVM_DIR/current/dist/share/man)
86+
export RUST_SRC_PATH=$(rsvm_append_path $RUST_SRC_PATH $RSVM_DIR/current/src/rustc-source/src)
8687

8788
rsvm_use()
8889
{
@@ -153,6 +154,7 @@ rsvm_install()
153154
{
154155
local CURRENT_DIR=`pwd`
155156
local target=$1
157+
local with_rustc_source=$2
156158
local dirname
157159
local url_prefix
158160
local LAST_VERSION
@@ -207,6 +209,23 @@ rsvm_install()
207209
echo "done"
208210
fi
209211

212+
if [ "$with_rustc_source" = true ]
213+
then
214+
echo "Downloading sources for rustc sourcecode $dirname ... "
215+
rsvm_file_download \
216+
"https://static.rust-lang.org/dist$url_prfix/rustc-$target-src.tar.gz" \
217+
"rustc-$target-src.tar.gz" \
218+
true
219+
if [ -e "rustc-source" ]
220+
then
221+
echo "Sources for rustc $dirname already extracted ..."
222+
else
223+
echo -n "Extracting source ... "
224+
tar -xzf "rustc-$target-src.tar.gz"
225+
mv "rustc-$target" "rustc-source"
226+
fi
227+
fi
228+
210229
if [ ! -f $SRC/rust-$target/bin/cargo ] && [ ! -f $SRC/rust-$target/cargo/bin/cargo ]
211230
then
212231
echo "Downloading sources for cargo nightly ... "
@@ -366,13 +385,25 @@ rsvm()
366385
echo " rsvm install 0.12.0"
367386
elif ([[ "$2" =~ ^$RSVM_VERSION_PATTERN$ ]])
368387
then
369-
if [ "$3" = "--dry" ]
370-
then
371-
echo "Would install rust $2"
372-
RSVM_LAST_INSTALLED_VERSION=$2
373-
else
374-
rsvm_install "$2"
375-
fi
388+
local version=$2
389+
local with_rustc_source=false
390+
for i in ${@:3:${#@}}
391+
do
392+
case $i in
393+
--dry)
394+
echo "Would install rust $version"
395+
RSVM_LAST_INSTALLED_VERSION=$version
396+
rsvm_use $RSVM_LAST_INSTALLED_VERSION
397+
exit
398+
;;
399+
--with-rustc-source)
400+
with_rustc_source=true
401+
;;
402+
*)
403+
;;
404+
esac
405+
done
406+
rsvm_install "$version" "$with_rustc_source"
376407
rsvm_use $RSVM_LAST_INSTALLED_VERSION
377408
else
378409
# the version was defined in a the wrong format.

0 commit comments

Comments
 (0)
0