8000 Merge pull request #39 from d3m3vilurr/support-rustup-command · javanile/r@b5d99a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b5d99a0

Browse files
authored
Merge pull request sdepold#39 from d3m3vilurr/support-rustup-command
Improve rustup and cargo support
2 parents 52d739b + 953f836 commit b5d99a0

File tree

2 files changed

+81
-3
lines changed

2 files changed

+81
-3
lines changed

rsvm.fish

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ function rsvm_set_path
3434
end
3535
end
3636

37-
set p (rsvm_find_paths $r | head -n1)
38-
set newpath $p $newpath
37+
for p in (rsvm_find_paths $r)
38+
set newpath $p $newpath
39+
end
3940
rsvm_set $k $newpath
4041
end
4142

@@ -74,6 +75,10 @@ function rsvm_mod_env
7475
rsvm_set_path MANPATH $p[2..-1]
7576
else if test $p[1] = RUST_SRC_PATH
7677
rsvm_set RUST_SRC_PATH $p[2..-1]
78+
else if test $p[1] = CARGO_HOME
79+
rsvm_set CARGO_HOME $p[2..-1]
80+
else if test $p[1] = RUSTUP_HOME
81+
rsvm_set RUSTUP_HOME $p[2..-1]
7782
end
7883
end
7984

rsvm.sh

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ rsvm_file_download()
101101
OPTS='-s'
102102
fi
103103

104+
#echo $1 $2
105+
104106
if [ $(rsvm_check_etag $1 $2) = 0 ]
105107
then
106108
# not match etag; new download
@@ -124,7 +126,6 @@ rsvm_append_path()
124126
echo $newpath
125127
}
126128

127-
export PATH=$(rsvm_append_path $PATH "$RSVM_DIR/current/dist/bin")
128129
export LD_LIBRARY_PATH=$(rsvm_append_path $LD_LIBRARY_PATH "$RSVM_DIR/current/dist/lib")
129130
export DYLD_LIBRARY_PATH=$(rsvm_append_path $DYLD_LIBRARY_PATH "$RSVM_DIR/current/dist/lib")
130131
export MANPATH=$(rsvm_append_path $MANPATH "$RSVM_DIR/current/dist/share/man")
@@ -135,6 +136,11 @@ then
135136
else
136137
unset RUST_SRC_PATH
137138
fi
139+
export CARGO_HOME="$RSVM_DIR/current/cargo"
140+
export RUSTUP_HOME="$RSVM_DIR/current/rustup"
141+
142+
export PATH=$(rsvm_append_path $PATH "$RSVM_DIR/current/dist/bin")
143+
export PATH=$(rsvm_append_path $PATH "$CARGO_HOME/bin")
138144

139145
rsvm_use()
140146
{
@@ -209,6 +215,7 @@ rsvm_install()
209215
local dirname
210216
local url_prefix
211217
local LAST_VERSION
218+
local RUSTUP_CHANNEL
212219

213220
if [ ${1: -3} = '-rc' ]
214221
then
@@ -228,13 +235,22 @@ rsvm_install()
228235
else
229236
dirname=$1.`date "+%Y%m%d%H%M%S"`
230237
fi
238+
if [[ $1 = "nightly" ]]
239+
then
240+
RUSTUP_CHANNEL=$1
241+
else
242+
RUSTUP_CHANNEL="beta"
243+
fi
231244
else
232245
dirname=$1
246+
RUSTUP_CHANNEL=$1
233247
fi
234248

235249
rsvm_init_folder_structure $dirname
236250
local SRC="$RSVM_DIR/versions/$dirname/src"
237251
local DIST="$RSVM_DIR/versions/$dirname/dist"
252+
local CARGO="$RSVM_DIR/versions/$dirname/cargo"
253+
local RUSTUP="$RSVM_DIR/versions/$dirname/rustup"
238254

239255
cd $SRC
240256

@@ -297,6 +313,63 @@ rsvm_install()
297313
cd "$SRC/rust-$target"
298314
sh install.sh --prefix=$DIST
299315

316+
if [ ! -f $DIST/lib/rustlib/multirust-channel-manifest.toml ]
317+
then
318+
echo "Downloading channel manifest ... "
319+
rsvm_file_download \
320+
"https://static.rust-lang.org/dist/channel-rust-${RUSTUP_CHANNEL}.toml" \
321+
"multirust-channel-manifest.toml"
322+
echo "done"
323+
324+
cp multirust-channel-manifest.toml $DIST/lib/rustlib/multirust-channel-manifest.toml
325+
fi
326+
327+
if [ ! -f $DIST/lib/rustlib/multirust-config.toml ]
328+
then
329+
cat << EOF > $DIST/lib/rustlib/multirust-config.toml
330+
config_version = "1"
331+
332+
[[components]]
333+
pkg = "rustc"
334+
target = "$RSVM_PLATFORM"
335+
336+
[[components]]
337+
pkg = "rust-std"
338+
target = "$RSVM_PLATFORM"
339+
340+
[[components]]
341+
pkg = "cargo"
342+
target = "$RSVM_PLATFORM"
343+
344+
[[components]]
345+
pkg = "rust-docs"
346+
target = "$RSVM_PLATFORM"
347+
EOF
348+
fi
349+
350+
if [ ! -f $DIST/bin/rustup ]
351+
then
352+
echo "Downloading rustup ... "
353+
rsvm_file_download \
354+
"https://static.rust-lang.org/rustup/dist/$RSVM_PLATFORM/rustup-init" \
355+
"rustup"
356+
echo "done"
357+
358+
cp rustup $DIST/bin/rustup
359+
chmod +x $DIST/bin/rustup
360+
fi
361+
362+
mkdir -p $RUSTUP/toolchains
363+
ln -s $DIST $RUSTUP/toolchains/${RUSTUP_CHANNEL}-${RSVM_PLATFORM}
364+
cat << EOF > $RUSTUP/settings.toml
365+
default_host_triple = "x86_64-unknown-linux-gnu"
366+
default_toolchain = "nightly-x86_64-unknown-linux-gnu"
367+
telemetry = false
368+
version = "12"
369+
370+
[overrides]
371+
EOF
372+
300373
echo ""
301374
echo "And we are done. Have fun using rust $dirname."
302375

0 commit comments

Comments
 (0)
0