Skip to content

Commit f8c75e6

Browse files
committed
installed rust repl
1 parent 91c95bc commit f8c75e6

File tree

4 files changed

+140
-3
lines changed

4 files changed

+140
-3
lines changed

install_prerequisite.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,18 @@ else
131131
curl https://sh.rustup.rs -sSf | env RUSTUP_HOME=$RUSTUP_HOME CARGO_HOME=$CARGO_HOME sh -s -- --default-toolchain stable --profile default -y
132132
echo "export RUSTUP_HOME=$RUSTUP_HOME" | tee /etc/profile.d/rust.sh
133133
echo "export CARGO_HOME=$CARGO_HOME" | tee -a /etc/profile.d/rust.sh
134-
echo "export PATH=\$PATH:\$RUSTUP_HOME/bin" | tee -a /etc/profile.d/rust.sh
134+
echo ". \"$RUSTUP_HOME/env\"" | tee -a /etc/profile.d/rust.sh
135135
chmod +x /etc/profile.d/rust.sh
136136
bash -c 'echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/bash.bashrc'
137137
bash -c 'echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/profile'
138+
#evcxr install
139+
wget https://github.com/evcxr/evcxr/releases/download/v0.17.0/evcxr-v0.17.0-x86_64-unknown-linux-gnu.tar.gz
140+
tar -xvf evcxr-v0.17.0-x86_64-unknown-linux-gnu.tar.gz
141+
cp evcxr-v0.17.0-x86_64-unknown-linux-gnu/evcxr $RUSTUP_HOME/bin/evcxr
142+
chmod 755 $RUSTUP_HOME/bin/evcxr
143+
rm evcxr-v0.17.0-x86_64-unknown-linux-gnu.tar.gz
144+
rm -rf evcxr-v0.17.0-x86_64-unknown-linux-gnu
145+
. "$RUSTUP_HOME/env"
138146
fi
139147

140148

@@ -224,6 +232,7 @@ if [ $run_tests -eq 1 ]; then
224232
"echo 'puts [info patchlevel]' | tclsh"
225233
"rustc --version"
226234
"rust-gdb --version"
235+
"evcxr --version"
227236
)
228237

229238

src/resources/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ <h1 class="hero__title" itemprop="name" ><span class="hero__title_pre">Open</spa
235235
<option value="perli" data-editor="perl">Perl</option>
236236
<option value="bash" data-editor="sh">bash</option>
237237
<option value="tclsh" data-editor="tcl">Tcl</option>
238+
<option value="evcxr" data-editor="rust">Rust</option>
238239
</select>
239240

240241
<div class="widget" id="fork-widget" style="margin:7px;font-size:15px;height:25px;">
@@ -449,7 +450,7 @@ <h2>Welcome to <span class="go__color">Open</span>REPL</h2>
449450
<option value="rhtml" disabled>RHTML</option>
450451
<option value="rst" disabled>RST</option>
451452
<option value="ruby">Ruby</option>
452-
<option value="rust" disabled>Rust</option>
453+
<option value="rust">Rust</option>
453454
<option value="sass" disabled>SASS</option>
454455
<option value="scad" disabled>SCAD</option>
455456
<option value="scala" disabled>Scala</option>

src/resources/js/scribbler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,9 @@ $(function() {
13831383
'xml': 'xml',
13841384
'toml': 'toml',
13851385
'yaml': 'yaml',
1386-
'proto': 'protobuf'
1386+
'proto': 'protobuf',
1387+
'tcl': 'tcl',
1388+
'rs': 'rust'
13871389
};
13881390
const imageext = ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];
13891391
const archiveext = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];

src/resources/meta/demos.xml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,131 @@ if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
19071907
$COMPILER "$WORKDIR/$FILE" $@;
19081908
fi
19091909
printf "\n";
1910+
sleep 0.05
1911+
</Compiler>
1912+
</Demo>
1913+
1914+
<!-- rust demo -->
1915+
<Demo>
1916+
<Name>evcxr</Name>
1917+
<Github>https://github.com/evcxr/evcxr</Github>
1918+
<Doc>https://doc.rust-lang.org/book/title-page.html</Doc>
1919+
<Codes>
1920+
<Code>
1921+
<Prompt>&gt;&gt;</Prompt>
1922+
<Statement>println!("Hello, World!!");</Statement>
1923+
<Result>Hello, World!!</Result>
1924+
</Code>
1925+
<Code>
1926+
<Prompt>&gt;&gt;</Prompt>
1927+
<Statement>let x = 1;</Statement>
1928+
<Result>1</Result>
1929+
</Code>
1930+
</Codes>
1931+
<Codes>
1932+
<Code>
1933+
<Prompt>&gt;&gt;</Prompt>
1934+
<Statement>let mut x = 1;
1935+
while x &lt; 5 {
1936+
println!("Hello {}", x);
1937+
x += 1;
1938+
}</Statement>
1939+
<Result>Hello 1
1940+
Hello 2
1941+
Hello 3
1942+
Hello 4</Result>
1943+
</Code>
1944+
</Codes>
1945+
<Codes>
1946+
<Code>
1947+
<Prompt>&gt;&gt;</Prompt>
1948+
<Statement>for i in 0..10 {
1949+
println!("loop: {}", i);
1950+
}</Statement>
1951+
<Result>loop: 0
1952+
loop: 1
1953+
loop: 2
1954+
loop: 3
1955+
loop: 4
1956+
loop: 5
1957+
loop: 6
1958+
loop: 7
1959+
loop: 8
1960+
loop: 9</Result>
1961+
</Code>
1962+
</Codes>
1963+
<Codes>
1964+
<Code>
1965+
<Prompt>&gt;&gt;</Prompt>
1966+
<Statement> :help</Statement>
1967+
<Result>:allow_static_linking Set whether to allow static linking of dependencies (0/1)
1968+
:build_env Set environment variables when building code (key=value)
1969+
:cache Set cache size in MiB, or 0 to disable.
1970+
:clear Clear all state, keeping compilation cache
1971+
...
1972+
:doc show the documentation of a variable, keyword, type or module
1973+
:env Set an environment variable (key=value)
1974+
:explain Print explanation of last error
1975+
:help Print command help
1976+
...
1977+
</Result>
1978+
</Code>
1979+
</Codes>
1980+
<Usage>
1981+
<Command>:help</Command>
1982+
<Description>Print command help</Description>
1983+
</Usage>
1984+
<Usage>
1985+
<Command>:quit</Command>
1986+
<Description>Quit evaluation and exit</Description>
1987+
</Usage>
1988+
<Content>/* Welcome to OpenREPL! */
1989+
fn main() {
1990+
println!("Hello, World!");
1991+
1992+
let a = 5;
1993+
let b = 10;
1994+
1995+
let result = sum(a, b);
1996+
1997+
println!("The sum of {} and {} is {}", a, b, result);
1998+
}
1999+
2000+
fn sum(x: i32, y: i32) -> i32 {
2001+
x + y
2002+
}
2003+
</Content>
2004+
<Compiler>
2005+
COMPILER=rustc
2006+
FILE=test.rs
2007+
debug=false
2008+
WORKDIR=$HOME
2009+
if [ "$CompilerOption" = "debug" ]; then
2010+
debug=true;
2011+
fi
2012+
if [ "$IdeLang" = "rust" ] || [ "$IdeLang" = "evcxr" ]; then
2013+
COMPILER=rustc
2014+
fi
2015+
printf "\n";
2016+
2017+
if [ "$IdeFileName" != "" ]; then
2018+
WORKDIR=$(dirname "$IdeFileName");
2019+
FILE=$(basename "$IdeFileName");
2020+
else
2021+
echo $0|base64 --decode > "$WORKDIR/$FILE";
2022+
fi
2023+
2024+
cd $WORKDIR;
2025+
if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
2026+
if $debug; then
2027+
$COMPILER -g -o "$FILE".o $FILE $@;
2028+
rust-gdb "$FILE".o $@;
2029+
else
2030+
$COMPILER $FILE -o "$FILE".o;
2031+
"$WORKDIR/$FILE".o $@;
2032+
fi
2033+
fi
2034+
printf "\n";
19102035
sleep 0.05
19112036
</Compiler>
19122037
</Demo>

0 commit comments

Comments
 (0)