Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building rust with linked c libraries #218

Merged
merged 4 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/rust-ring/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust
# Edit at https://www.toptal.com/developers/gitignore?templates=rust

### Rust ###
# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# End of https://www.toptal.com/developers/gitignore/api/rust

9 changes: 9 additions & 0 deletions examples/rust-ring/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "rust-ring"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ring = "0.16.20"
5 changes: 5 additions & 0 deletions examples/rust-ring/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use ring as _;

fn main() {
println!("Hello from rust");
}
2 changes: 2 additions & 0 deletions src/providers/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ impl Provider for RustProvider {
setup_phase.add_file_dependency(toolchain_file);
}

setup_phase.add_apt_pkgs(vec!["musl-tools".to_string()]);

Ok(Some(setup_phase))
}

Expand Down
7 changes: 7 additions & 0 deletions tests/docker_run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ fn test_rust_custom_version() {
assert!(output.contains("cargo 1.56.0"));
}

#[test]
fn test_rust_ring() {
let name = simple_build("./examples/rust-ring");
let output = run_image(name, None);
assert!(output.contains("Hello from rust"));
}

#[test]
fn test_go() {
let name = simple_build("./examples/go");
Expand Down