Add rust 1.57.0

This commit is contained in:
Omar Brikaa 2022-02-21 20:49:09 +02:00
parent 6161997f49
commit a739cff448
14 changed files with 48 additions and 58 deletions

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
curl -OL "https://static.rust-lang.org/dist/rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz"
tar xzvf rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz
rm rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std
# Rust compiler needs to find the stdlib to link against
rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@"
chmod +x binary

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/rust-1.50.0-x86_64-unknown-linux-gnu/rustc/bin/:$PATH
export RUST_INSTALL_LOC=$PWD/rust-1.50.0-x86_64-unknown-linux-gnu

View File

@ -1,5 +0,0 @@
{
"language": "rust",
"version": "1.50.0",
"aliases": ["rs"]
}

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
shift
./binary "$@"

View File

@ -1,3 +0,0 @@
fn main() {
println!("OK");
}

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
curl -OL "https://static.rust-lang.org/dist/rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz"
tar xzvf rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz
rm rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std
# Rust compiler needs to find the stdlib to link against
rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@"
chmod +x binary

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/rust-1.56.1-x86_64-unknown-linux-gnu/rustc/bin/:$PATH
export RUST_INSTALL_LOC=$PWD/rust-1.56.1-x86_64-unknown-linux-gnu

View File

@ -1,7 +0,0 @@
{
"language": "rust",
"version": "1.56.1",
"aliases": [
"rs"
]
}

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
shift
./binary "$@"

View File

@ -1,3 +0,0 @@
fn main() {
println!("OK");
}

View File

@ -52,4 +52,5 @@ args: {
"yabasic" = import ./yabasic.nix args; "yabasic" = import ./yabasic.nix args;
"emacs" = import ./emacs.nix args; "emacs" = import ./emacs.nix args;
"gnat-ada" = import ./gnat-ada.nix args; "gnat-ada" = import ./gnat-ada.nix args;
"rust" = import ./rust.nix args;
} }

47
runtimes/rust.nix Normal file
View File

@ -0,0 +1,47 @@
{pkgs, piston, ...}:
let
gccPackage = pkgs.gcc; # gcc is required for the linker
pkg = pkgs.rustc;
in piston.mkRuntime {
language = "rust";
version = pkg.version;
aliases = [
"rs"
];
compile = ''
${pkg}/bin/rustc -o binary -C linker=${gccPackage}/bin/gcc $1
chmod +x binary
'';
run = ''
shift
./binary "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.rs" = ''
pub mod helper;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
helper::print_something(args[1].to_string());
}
'';
"helper.rs" = ''
pub fn print_something(what: String) -> () {
println!("{}", what);
}
'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.rs";
})
];
}