Merge remote/main into upgrade branch

This commit is contained in:
Luke Boswell 2024-11-13 09:02:37 +11:00
parent dc3aa06d61
commit f4451722e8
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
17 changed files with 55 additions and 39 deletions

2
.gitignore vendored
View file

@ -126,3 +126,5 @@ crates/glue/tests/fixtures/*/test_glue/
# ignore the zig glue files copied into test platforms
**/*platform/glue/*
crates/cli/tests/test-projects/test-platform-effects-zig/glue
crates/cli/tests/test-projects/test-platform-simple-zig/glue

4
Cargo.lock generated
View file

@ -473,8 +473,8 @@ name = "cli_test_utils"
version = "0.0.1"
dependencies = [
"bumpalo",
"copy_zig_glue",
"const_format",
"copy_zig_glue",
"criterion",
"lazy_static",
"regex",
@ -2408,6 +2408,7 @@ dependencies = [
"clap 4.4.6",
"cli_test_utils",
"const_format",
"copy_zig_glue",
"criterion",
"distance",
"errno",
@ -4373,6 +4374,7 @@ version = "0.0.1"
dependencies = [
"bumpalo",
"cli_test_utils",
"copy_zig_glue",
"indoc",
"roc_build",
"roc_command_utils",

View file

@ -65,6 +65,7 @@ roc_reporting = { path = "../reporting" }
roc_target = { path = "../compiler/roc_target" }
roc_tracing = { path = "../tracing" }
roc_wasm_interp = { path = "../wasm_interp", optional = true }
copy_zig_glue = { path = "../copy_zig_glue" }
ven_pretty = { path = "../vendor/pretty" }

View file

@ -184,6 +184,8 @@ mod cli_tests {
#[cfg_attr(windows, ignore)]
// tea = The Elm Architecture
fn terminal_ui_tea() {
copy_zig_glue::initialize_zig_test_platforms();
let cli_build = ExecCli::new(
CMD_BUILD,
file_from_root("crates/cli/tests/test-projects/tui", "main.roc"),
@ -266,6 +268,8 @@ mod cli_tests {
#[test]
#[cfg_attr(windows, ignore)]
fn multiple_exposed() {
copy_zig_glue::initialize_zig_test_platforms();
let cli_build = ExecCli::new(
CMD_BUILD,
file_from_root(
@ -461,6 +465,8 @@ mod cli_tests {
/// Build the platform host once for all tests in this module
fn build_platform_host() {
BUILD_PLATFORM_HOST.call_once(|| {
copy_zig_glue::initialize_zig_test_platforms();
let cli_build = ExecCli::new(
CMD_BUILD,
file_from_root(
@ -800,6 +806,8 @@ mod cli_tests {
/// Build the platform host once for all tests in this module
fn build_platform_host() {
BUILD_PLATFORM_HOST.call_once(|| {
copy_zig_glue::initialize_zig_test_platforms();
let cli_build = ExecCli::new(
CMD_BUILD,
file_from_root(

View file

@ -24,7 +24,7 @@ const DEBUG: bool = false;
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
if (DEBUG) {
var ptr = malloc(size);
const ptr = malloc(size);
const stdout = std.io.getStdOut().writer();
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
return ptr;

View file

@ -1,6 +1,6 @@
const std = @import("std");
const builtin = @import("builtin");
const str = @import("glue").str;
const str = @import("glue/str.zig");
const RocStr = str.RocStr;
const testing = std.testing;
const expectEqual = testing.expectEqual;
@ -25,7 +25,7 @@ extern fn roc__mainForHost_0_result_size() i64;
fn allocate_model(allocator: *Allocator) MutModel {
const size = roc__mainForHost_0_result_size();
const raw_output = allocator.alignedAlloc(u8, @alignOf(u64), @as(usize, @intCast(size))) catch unreachable;
var output = @as([*]u8, @ptrCast(raw_output));
const output = @as([*]u8, @ptrCast(raw_output));
return output;
}
@ -86,7 +86,7 @@ const DEBUG: bool = false;
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
if (DEBUG) {
var ptr = malloc(size);
const ptr = malloc(size);
const stdout = std.io.getStdOut().writer();
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
return ptr;
@ -158,13 +158,13 @@ fn roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_
comptime {
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong });
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong });
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .strong });
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .strong });
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .strong });
}
if (builtin.os.tag == .windows) {
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong });
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .strong });
}
}

View file

@ -24,7 +24,7 @@ bitvec.workspace = true
bumpalo.workspace = true
static_assertions.workspace = true
soa.workspace = true
soa = { path = "../../soa" }
[dev-dependencies]
indoc.workspace = true

View file

@ -17,4 +17,4 @@ im.workspace = true
wyhash.workspace = true
smallvec.workspace = true
soa.workspace = true
soa = { path = "../../soa" }

View file

@ -16,7 +16,6 @@ roc_parse = { path = "../parse" }
roc_problem = { path = "../problem" }
roc_region = { path = "../region" }
roc_types = { path = "../types" }
soa = { path = "../../soa" }
arrayvec.workspace = true
soa.workspace = true

View file

@ -15,8 +15,7 @@ roc_collections = { path = "../collections" }
roc_module = { path = "../module" }
roc_region = { path = "../region" }
roc_error_macros = { path = "../../error_macros" }
soa.workspace = true
soa = { path = "../../soa" }
bumpalo.workspace = true
encode_unicode.workspace = true

View file

@ -23,11 +23,11 @@ roc_solve_problem = { path = "../solve_problem" }
roc_solve_schema = { path = "../solve_schema" }
roc_types = { path = "../types" }
roc_unify = { path = "../unify" }
soa = { path = "../../soa" }
arrayvec.workspace = true
bumpalo.workspace = true
soa.workspace = true
[dev-dependencies]
roc_builtins = { path = "../builtins" }

View file

@ -15,10 +15,9 @@ roc_module = { path = "../module" }
roc_region = { path = "../region" }
roc_serialize = { path = "../serialize" }
roc_parse = { path = "../parse" }
soa = { path = "../../soa" }
ven_pretty = { path = "../../vendor/pretty" }
bumpalo.workspace = true
static_assertions.workspace = true
soa.workspace = true

View file

@ -1,7 +1,19 @@
use std::path::Path;
use std::path::PathBuf;
use std::sync::Once;
use std::{fs, io};
use std::path::PathBuf;
static ZIG_PLATFORM_COPY_GLUE_ONCE: Once = Once::new();
/// Copies the glue source files for zig platforms from the roc builtins
/// this is only temporary, see comments in crates/copy_zig_glue/src/main.rs
pub fn initialize_zig_test_platforms() {
ZIG_PLATFORM_COPY_GLUE_ONCE.call_once(|| {
dbg!("ZIG_PLATFORM_COPY_GLUE_ONCE");
// initialization code here
copy_zig_glue();
});
}
/// Copy the zig builtins source files into each of the test platform folders.
///
@ -16,18 +28,16 @@ pub fn copy_zig_glue() {
let zig_builtins_source_dir = workspace_dir.join("crates/compiler/builtins/bitcode/src");
let zig_test_platforms_dirs: Vec<PathBuf> = vec![
workspace_dir.join("crates/cli/tests/platform_requires_pkg/platform/glue"),
workspace_dir.join("crates/cli/tests/algorithms/fibonacci-platform/glue"),
workspace_dir.join("crates/cli/tests/algorithms/quicksort-platform/glue"),
workspace_dir.join("crates/cli/tests/test-projects/platform_requires_pkg/platform/glue"),
workspace_dir.join("crates/cli/tests/test-projects/algorithms/fibonacci-platform/glue"),
workspace_dir.join("crates/cli/tests/test-projects/algorithms/quicksort-platform/glue"),
workspace_dir.join("crates/cli/tests/benchmarks/platform/glue"),
workspace_dir.join("crates/cli/tests/expects/zig-platform/glue"),
workspace_dir.join("crates/cli/tests/fixtures/multi-dep-str/platform/glue"),
workspace_dir.join("crates/cli/tests/fixtures/multi-dep-thunk/platform/glue"),
workspace_dir.join("crates/cli/tests/fixtures/packages/platform/glue"),
workspace_dir.join("crates/valgrind/zig-platform/glue"),
workspace_dir.join("examples/cli/effects-platform/glue"),
workspace_dir.join("examples/cli/tui-platform/glue"),
workspace_dir.join("crates/valgrind_tests/zig-platform/glue"),
workspace_dir.join("crates/cli/tests/test-projects/test-platform-effects-zig/glue"),
workspace_dir.join("crates/cli/tests/test-projects/test-platform-simple-zig/glue"),
workspace_dir.join("examples/platform-switching/zig-platform/glue"),
workspace_dir.join("crates/cli/tests/test-projects/multiple_exposed/platform/glue"),
workspace_dir.join("crates/cli/tests/test-projects/tui/platform/glue"),
];
for target_dir in zig_test_platforms_dirs {

View file

@ -15,6 +15,7 @@ roc_load = { path = "../compiler/load" }
roc_mono = { path = "../compiler/mono" }
roc_packaging = { path = "../packaging" }
roc_reporting = { path = "../reporting" }
copy_zig_glue = { path = "../copy_zig_glue" }
bumpalo.workspace = true
indoc.workspace = true

View file

@ -61,6 +61,8 @@ fn build_host() {
}
fn valgrind_test(source: &str) {
copy_zig_glue::initialize_zig_test_platforms();
#[cfg(target_os = "linux")]
{
valgrind_test_linux(source)

View file

@ -1,7 +0,0 @@
hosted Effect
exposes [putLine!, getLine!]
imports []
putLine! : Str => {}
getLine! : {} => Str

6
flake.lock generated
View file

@ -89,11 +89,11 @@
]
},
"locked": {
"lastModified": 1727490462,
"narHash": "sha256-OrrPiNBiikv9BR464XTT75FzOq7tKAvMbMi7YOKVIeg=",
"lastModified": 1731378398,
"narHash": "sha256-a0QWaiX8+AJ9/XBLGMDy6c90GD7HzpxKVdlFwCke5Pw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "11a13e50debafae4ae802f1d6b8585101516dd93",
"rev": "0ae9fc2f2fe5361837d59c0bdebbda176427111e",
"type": "github"
},
"original": {