Skip to content

Commit

Permalink
hopefully fix glue platform exit code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bhansconnect committed Nov 30, 2023
1 parent 88106d1 commit eefbd30
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 70 deletions.
7 changes: 5 additions & 2 deletions crates/glue/tests/fixture-templates/rust/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// So you probably don't want to modify it by hand! Instead, modify the
// file with the same name in the fixture-templates/ directory.

extern int rust_main();
extern void rust_main();

int main() { return rust_main(); }
int main() {
rust_main();
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use indoc::indoc;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -34,9 +34,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/arguments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
let answer = roc_app::mainForHost(42i64);

println!("Answer was: {:?}", answer); // Debug

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/basic-record/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand All @@ -28,9 +28,6 @@ pub extern "C" fn rust_main() -> i32 {
assert_eq!(set.len(), 1);

println!("Record was: {:?}", record); // Debug

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/basic-recursive-union/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use roc_app::{self, Expr};
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -39,9 +39,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/closures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
let closure = roc_app::mainForHost(42i64);

println!("Answer was: {:?}", closure.force_thunk()); // Debug

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/enumeration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -32,9 +32,6 @@ pub extern "C" fn rust_main() -> i32 {
roc_app::MyEnum::Bar,
roc_app::MyEnum::Baz,
); // Debug

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/list-recursive-union/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use roc_app::Rbt;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -34,9 +34,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/multiple-modules/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -32,9 +32,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/nested-record/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;

let outer = roc_app::mainForHost();
Expand Down Expand Up @@ -30,9 +30,6 @@ pub extern "C" fn rust_main() -> i32 {
}

println!("Record was: {:?}", outer);

// Exit code
std::process::exit(0);
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/nonnullable-unwrapped/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {
}

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -47,9 +47,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/nullable-unwrapped/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use roc_app::StrConsList;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -39,9 +39,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/nullable-wrapped/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {
}

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -58,9 +58,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/option/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
let string = roc_app::mainForHost(true);
println!("Answer was: {:?}", string.unwrap_Some()); // Debug
//
let integer = roc_app::mainForHost(false);
println!("Answer was: {:?}", integer.discriminant()); // Debug

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/rocresult/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ use roc_app;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
let string = roc_app::mainForHost(true);
println!("Answer was: {:?}", string); // Debug
//
let integer = roc_app::mainForHost(false);
println!("Answer was: {:?}", integer); // Debug

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/single-tag-union/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use roc_app::SingleTagUnion;
use roc_std::RocStr;

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -34,9 +34,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/union-with-padding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {
}

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -39,9 +39,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down
5 changes: 1 addition & 4 deletions crates/glue/tests/fixtures/union-without-padding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern "C" {
}

#[no_mangle]
pub extern "C" fn rust_main() -> i32 {
pub extern "C" fn rust_main() {
use std::cmp::Ordering;
use std::collections::hash_set::HashSet;

Expand Down Expand Up @@ -36,9 +36,6 @@ pub extern "C" fn rust_main() -> i32 {
set.insert(tag_union);

assert_eq!(set.len(), 1);

// Exit code
0
}

// Externs required by roc_std and by the Roc app
Expand Down

0 comments on commit eefbd30

Please sign in to comment.