Skip to content

Commit

Permalink
installed rust repl
Browse files Browse the repository at this point in the history
  • Loading branch information
vickeykumar committed Jun 16, 2024
1 parent 91c95bc commit f8c75e6
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 3 deletions.
11 changes: 10 additions & 1 deletion install_prerequisite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,18 @@ else
curl https://sh.rustup.rs -sSf | env RUSTUP_HOME=$RUSTUP_HOME CARGO_HOME=$CARGO_HOME sh -s -- --default-toolchain stable --profile default -y
echo "export RUSTUP_HOME=$RUSTUP_HOME" | tee /etc/profile.d/rust.sh
echo "export CARGO_HOME=$CARGO_HOME" | tee -a /etc/profile.d/rust.sh
echo "export PATH=\$PATH:\$RUSTUP_HOME/bin" | tee -a /etc/profile.d/rust.sh
echo ". \"$RUSTUP_HOME/env\"" | tee -a /etc/profile.d/rust.sh
chmod +x /etc/profile.d/rust.sh
bash -c 'echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/bash.bashrc'
bash -c 'echo "if [ -f /etc/profile.d/rust.sh ]; then . /etc/profile.d/rust.sh; fi" >> /etc/profile'
#evcxr install
wget https://github.com/evcxr/evcxr/releases/download/v0.17.0/evcxr-v0.17.0-x86_64-unknown-linux-gnu.tar.gz
tar -xvf evcxr-v0.17.0-x86_64-unknown-linux-gnu.tar.gz
cp evcxr-v0.17.0-x86_64-unknown-linux-gnu/evcxr $RUSTUP_HOME/bin/evcxr
chmod 755 $RUSTUP_HOME/bin/evcxr
rm evcxr-v0.17.0-x86_64-unknown-linux-gnu.tar.gz
rm -rf evcxr-v0.17.0-x86_64-unknown-linux-gnu
. "$RUSTUP_HOME/env"
fi


Expand Down Expand Up @@ -224,6 +232,7 @@ if [ $run_tests -eq 1 ]; then
"echo 'puts [info patchlevel]' | tclsh"
"rustc --version"
"rust-gdb --version"
"evcxr --version"
)


Expand Down
3 changes: 2 additions & 1 deletion src/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ <h1 class="hero__title" itemprop="name" ><span class="hero__title_pre">Open</spa
<option value="perli" data-editor="perl">Perl</option>
<option value="bash" data-editor="sh">bash</option>
<option value="tclsh" data-editor="tcl">Tcl</option>
<option value="evcxr" data-editor="rust">Rust</option>
</select>

<div class="widget" id="fork-widget" style="margin:7px;font-size:15px;height:25px;">
Expand Down Expand Up @@ -449,7 +450,7 @@ <h2>Welcome to <span class="go__color">Open</span>REPL</h2>
<option value="rhtml" disabled>RHTML</option>
<option value="rst" disabled>RST</option>
<option value="ruby">Ruby</option>
<option value="rust" disabled>Rust</option>
<option value="rust">Rust</option>
<option value="sass" disabled>SASS</option>
<option value="scad" disabled>SCAD</option>
<option value="scala" disabled>Scala</option>
Expand Down
4 changes: 3 additions & 1 deletion src/resources/js/scribbler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,9 @@ $(function() {
'xml': 'xml',
'toml': 'toml',
'yaml': 'yaml',
'proto': 'protobuf'
'proto': 'protobuf',
'tcl': 'tcl',
'rs': 'rust'
};
const imageext = ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];
const archiveext = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];
Expand Down
125 changes: 125 additions & 0 deletions src/resources/meta/demos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,131 @@ if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
$COMPILER "$WORKDIR/$FILE" $@;
fi
printf "\n";
sleep 0.05
</Compiler>
</Demo>

<!-- rust demo -->
<Demo>
<Name>evcxr</Name>
<Github>https://github.com/evcxr/evcxr</Github>
<Doc>https://doc.rust-lang.org/book/title-page.html</Doc>
<Codes>
<Code>
<Prompt>&gt;&gt;</Prompt>
<Statement>println!("Hello, World!!");</Statement>
<Result>Hello, World!!</Result>
</Code>
<Code>
<Prompt>&gt;&gt;</Prompt>
<Statement>let x = 1;</Statement>
<Result>1</Result>
</Code>
</Codes>
<Codes>
<Code>
<Prompt>&gt;&gt;</Prompt>
<Statement>let mut x = 1;
while x &lt; 5 {
println!("Hello {}", x);
x += 1;
}</Statement>
<Result>Hello 1
Hello 2
Hello 3
Hello 4</Result>
</Code>
</Codes>
<Codes>
<Code>
<Prompt>&gt;&gt;</Prompt>
<Statement>for i in 0..10 {
println!("loop: {}", i);
}</Statement>
<Result>loop: 0
loop: 1
loop: 2
loop: 3
loop: 4
loop: 5
loop: 6
loop: 7
loop: 8
loop: 9</Result>
</Code>
</Codes>
<Codes>
<Code>
<Prompt>&gt;&gt;</Prompt>
<Statement> :help</Statement>
<Result>:allow_static_linking Set whether to allow static linking of dependencies (0/1)
:build_env Set environment variables when building code (key=value)
:cache Set cache size in MiB, or 0 to disable.
:clear Clear all state, keeping compilation cache
...
:doc show the documentation of a variable, keyword, type or module
:env Set an environment variable (key=value)
:explain Print explanation of last error
:help Print command help
...
</Result>
</Code>
</Codes>
<Usage>
<Command>:help</Command>
<Description>Print command help</Description>
</Usage>
<Usage>
<Command>:quit</Command>
<Description>Quit evaluation and exit</Description>
</Usage>
<Content>/* Welcome to OpenREPL! */
fn main() {
println!("Hello, World!");

let a = 5;
let b = 10;

let result = sum(a, b);

println!("The sum of {} and {} is {}", a, b, result);
}

fn sum(x: i32, y: i32) -> i32 {
x + y
}
</Content>
<Compiler>
COMPILER=rustc
FILE=test.rs
debug=false
WORKDIR=$HOME
if [ "$CompilerOption" = "debug" ]; then
debug=true;
fi
if [ "$IdeLang" = "rust" ] || [ "$IdeLang" = "evcxr" ]; then
COMPILER=rustc
fi
printf "\n";

if [ "$IdeFileName" != "" ]; then
WORKDIR=$(dirname "$IdeFileName");
FILE=$(basename "$IdeFileName");
else
echo $0|base64 --decode > "$WORKDIR/$FILE";
fi

cd $WORKDIR;
if [ $? -eq 0 ] &amp;&amp; [ -f "$WORKDIR/$FILE" ]; then
if $debug; then
$COMPILER -g -o "$FILE".o $FILE $@;
rust-gdb "$FILE".o $@;
else
$COMPILER $FILE -o "$FILE".o;
"$WORKDIR/$FILE".o $@;
fi
fi
printf "\n";
sleep 0.05
</Compiler>
</Demo>
Expand Down

0 comments on commit f8c75e6

Please sign in to comment.