mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Merge remote/main into upgrade branch
This commit is contained in:
parent
dc3aa06d61
commit
f4451722e8
17 changed files with 55 additions and 39 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -126,3 +126,5 @@ crates/glue/tests/fixtures/*/test_glue/
|
||||||
|
|
||||||
# ignore the zig glue files copied into test platforms
|
# ignore the zig glue files copied into test platforms
|
||||||
**/*platform/glue/*
|
**/*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
4
Cargo.lock
generated
|
@ -473,8 +473,8 @@ name = "cli_test_utils"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"copy_zig_glue",
|
|
||||||
"const_format",
|
"const_format",
|
||||||
|
"copy_zig_glue",
|
||||||
"criterion",
|
"criterion",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"regex",
|
"regex",
|
||||||
|
@ -2408,6 +2408,7 @@ dependencies = [
|
||||||
"clap 4.4.6",
|
"clap 4.4.6",
|
||||||
"cli_test_utils",
|
"cli_test_utils",
|
||||||
"const_format",
|
"const_format",
|
||||||
|
"copy_zig_glue",
|
||||||
"criterion",
|
"criterion",
|
||||||
"distance",
|
"distance",
|
||||||
"errno",
|
"errno",
|
||||||
|
@ -4373,6 +4374,7 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"cli_test_utils",
|
"cli_test_utils",
|
||||||
|
"copy_zig_glue",
|
||||||
"indoc",
|
"indoc",
|
||||||
"roc_build",
|
"roc_build",
|
||||||
"roc_command_utils",
|
"roc_command_utils",
|
||||||
|
|
|
@ -65,6 +65,7 @@ roc_reporting = { path = "../reporting" }
|
||||||
roc_target = { path = "../compiler/roc_target" }
|
roc_target = { path = "../compiler/roc_target" }
|
||||||
roc_tracing = { path = "../tracing" }
|
roc_tracing = { path = "../tracing" }
|
||||||
roc_wasm_interp = { path = "../wasm_interp", optional = true }
|
roc_wasm_interp = { path = "../wasm_interp", optional = true }
|
||||||
|
copy_zig_glue = { path = "../copy_zig_glue" }
|
||||||
|
|
||||||
ven_pretty = { path = "../vendor/pretty" }
|
ven_pretty = { path = "../vendor/pretty" }
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,8 @@ mod cli_tests {
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
// tea = The Elm Architecture
|
// tea = The Elm Architecture
|
||||||
fn terminal_ui_tea() {
|
fn terminal_ui_tea() {
|
||||||
|
copy_zig_glue::initialize_zig_test_platforms();
|
||||||
|
|
||||||
let cli_build = ExecCli::new(
|
let cli_build = ExecCli::new(
|
||||||
CMD_BUILD,
|
CMD_BUILD,
|
||||||
file_from_root("crates/cli/tests/test-projects/tui", "main.roc"),
|
file_from_root("crates/cli/tests/test-projects/tui", "main.roc"),
|
||||||
|
@ -266,6 +268,8 @@ mod cli_tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn multiple_exposed() {
|
fn multiple_exposed() {
|
||||||
|
copy_zig_glue::initialize_zig_test_platforms();
|
||||||
|
|
||||||
let cli_build = ExecCli::new(
|
let cli_build = ExecCli::new(
|
||||||
CMD_BUILD,
|
CMD_BUILD,
|
||||||
file_from_root(
|
file_from_root(
|
||||||
|
@ -461,6 +465,8 @@ mod cli_tests {
|
||||||
/// Build the platform host once for all tests in this module
|
/// Build the platform host once for all tests in this module
|
||||||
fn build_platform_host() {
|
fn build_platform_host() {
|
||||||
BUILD_PLATFORM_HOST.call_once(|| {
|
BUILD_PLATFORM_HOST.call_once(|| {
|
||||||
|
copy_zig_glue::initialize_zig_test_platforms();
|
||||||
|
|
||||||
let cli_build = ExecCli::new(
|
let cli_build = ExecCli::new(
|
||||||
CMD_BUILD,
|
CMD_BUILD,
|
||||||
file_from_root(
|
file_from_root(
|
||||||
|
@ -800,6 +806,8 @@ mod cli_tests {
|
||||||
/// Build the platform host once for all tests in this module
|
/// Build the platform host once for all tests in this module
|
||||||
fn build_platform_host() {
|
fn build_platform_host() {
|
||||||
BUILD_PLATFORM_HOST.call_once(|| {
|
BUILD_PLATFORM_HOST.call_once(|| {
|
||||||
|
copy_zig_glue::initialize_zig_test_platforms();
|
||||||
|
|
||||||
let cli_build = ExecCli::new(
|
let cli_build = ExecCli::new(
|
||||||
CMD_BUILD,
|
CMD_BUILD,
|
||||||
file_from_root(
|
file_from_root(
|
||||||
|
|
|
@ -24,7 +24,7 @@ const DEBUG: bool = false;
|
||||||
|
|
||||||
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
|
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
var ptr = malloc(size);
|
const ptr = malloc(size);
|
||||||
const stdout = std.io.getStdOut().writer();
|
const stdout = std.io.getStdOut().writer();
|
||||||
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
|
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const str = @import("glue").str;
|
const str = @import("glue/str.zig");
|
||||||
const RocStr = str.RocStr;
|
const RocStr = str.RocStr;
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const expectEqual = testing.expectEqual;
|
const expectEqual = testing.expectEqual;
|
||||||
|
@ -25,7 +25,7 @@ extern fn roc__mainForHost_0_result_size() i64;
|
||||||
fn allocate_model(allocator: *Allocator) MutModel {
|
fn allocate_model(allocator: *Allocator) MutModel {
|
||||||
const size = roc__mainForHost_0_result_size();
|
const size = roc__mainForHost_0_result_size();
|
||||||
const raw_output = allocator.alignedAlloc(u8, @alignOf(u64), @as(usize, @intCast(size))) catch unreachable;
|
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;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ const DEBUG: bool = false;
|
||||||
|
|
||||||
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
|
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
var ptr = malloc(size);
|
const ptr = malloc(size);
|
||||||
const stdout = std.io.getStdOut().writer();
|
const stdout = std.io.getStdOut().writer();
|
||||||
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
|
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -158,13 +158,13 @@ fn roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_
|
||||||
|
|
||||||
comptime {
|
comptime {
|
||||||
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
|
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
|
||||||
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
|
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .strong });
|
||||||
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong });
|
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .strong });
|
||||||
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong });
|
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .strong });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builtin.os.tag == .windows) {
|
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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ bitvec.workspace = true
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
static_assertions.workspace = true
|
static_assertions.workspace = true
|
||||||
|
|
||||||
soa.workspace = true
|
soa = { path = "../../soa" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
|
|
|
@ -17,4 +17,4 @@ im.workspace = true
|
||||||
wyhash.workspace = true
|
wyhash.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
|
|
||||||
soa.workspace = true
|
soa = { path = "../../soa" }
|
||||||
|
|
|
@ -16,7 +16,6 @@ roc_parse = { path = "../parse" }
|
||||||
roc_problem = { path = "../problem" }
|
roc_problem = { path = "../problem" }
|
||||||
roc_region = { path = "../region" }
|
roc_region = { path = "../region" }
|
||||||
roc_types = { path = "../types" }
|
roc_types = { path = "../types" }
|
||||||
|
soa = { path = "../../soa" }
|
||||||
|
|
||||||
arrayvec.workspace = true
|
arrayvec.workspace = true
|
||||||
|
|
||||||
soa.workspace = true
|
|
||||||
|
|
|
@ -15,8 +15,7 @@ roc_collections = { path = "../collections" }
|
||||||
roc_module = { path = "../module" }
|
roc_module = { path = "../module" }
|
||||||
roc_region = { path = "../region" }
|
roc_region = { path = "../region" }
|
||||||
roc_error_macros = { path = "../../error_macros" }
|
roc_error_macros = { path = "../../error_macros" }
|
||||||
|
soa = { path = "../../soa" }
|
||||||
soa.workspace = true
|
|
||||||
|
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
encode_unicode.workspace = true
|
encode_unicode.workspace = true
|
||||||
|
|
|
@ -23,11 +23,11 @@ roc_solve_problem = { path = "../solve_problem" }
|
||||||
roc_solve_schema = { path = "../solve_schema" }
|
roc_solve_schema = { path = "../solve_schema" }
|
||||||
roc_types = { path = "../types" }
|
roc_types = { path = "../types" }
|
||||||
roc_unify = { path = "../unify" }
|
roc_unify = { path = "../unify" }
|
||||||
|
soa = { path = "../../soa" }
|
||||||
|
|
||||||
arrayvec.workspace = true
|
arrayvec.workspace = true
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
|
|
||||||
soa.workspace = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
roc_builtins = { path = "../builtins" }
|
roc_builtins = { path = "../builtins" }
|
||||||
|
|
|
@ -15,10 +15,9 @@ roc_module = { path = "../module" }
|
||||||
roc_region = { path = "../region" }
|
roc_region = { path = "../region" }
|
||||||
roc_serialize = { path = "../serialize" }
|
roc_serialize = { path = "../serialize" }
|
||||||
roc_parse = { path = "../parse" }
|
roc_parse = { path = "../parse" }
|
||||||
|
soa = { path = "../../soa" }
|
||||||
|
|
||||||
ven_pretty = { path = "../../vendor/pretty" }
|
ven_pretty = { path = "../../vendor/pretty" }
|
||||||
|
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
static_assertions.workspace = true
|
static_assertions.workspace = true
|
||||||
|
|
||||||
soa.workspace = true
|
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::Once;
|
||||||
use std::{fs, io};
|
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.
|
/// 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_builtins_source_dir = workspace_dir.join("crates/compiler/builtins/bitcode/src");
|
||||||
|
|
||||||
let zig_test_platforms_dirs: Vec<PathBuf> = vec![
|
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/test-projects/platform_requires_pkg/platform/glue"),
|
||||||
workspace_dir.join("crates/cli/tests/algorithms/fibonacci-platform/glue"),
|
workspace_dir.join("crates/cli/tests/test-projects/algorithms/fibonacci-platform/glue"),
|
||||||
workspace_dir.join("crates/cli/tests/algorithms/quicksort-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/benchmarks/platform/glue"),
|
||||||
workspace_dir.join("crates/cli/tests/expects/zig-platform/glue"),
|
workspace_dir.join("crates/valgrind_tests/zig-platform/glue"),
|
||||||
workspace_dir.join("crates/cli/tests/fixtures/multi-dep-str/platform/glue"),
|
workspace_dir.join("crates/cli/tests/test-projects/test-platform-effects-zig/glue"),
|
||||||
workspace_dir.join("crates/cli/tests/fixtures/multi-dep-thunk/platform/glue"),
|
workspace_dir.join("crates/cli/tests/test-projects/test-platform-simple-zig/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("examples/platform-switching/zig-platform/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 {
|
for target_dir in zig_test_platforms_dirs {
|
||||||
|
|
|
@ -15,6 +15,7 @@ roc_load = { path = "../compiler/load" }
|
||||||
roc_mono = { path = "../compiler/mono" }
|
roc_mono = { path = "../compiler/mono" }
|
||||||
roc_packaging = { path = "../packaging" }
|
roc_packaging = { path = "../packaging" }
|
||||||
roc_reporting = { path = "../reporting" }
|
roc_reporting = { path = "../reporting" }
|
||||||
|
copy_zig_glue = { path = "../copy_zig_glue" }
|
||||||
|
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
|
|
|
@ -61,6 +61,8 @@ fn build_host() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn valgrind_test(source: &str) {
|
fn valgrind_test(source: &str) {
|
||||||
|
copy_zig_glue::initialize_zig_test_platforms();
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
valgrind_test_linux(source)
|
valgrind_test_linux(source)
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
hosted Effect
|
|
||||||
exposes [putLine!, getLine!]
|
|
||||||
imports []
|
|
||||||
|
|
||||||
putLine! : Str => {}
|
|
||||||
|
|
||||||
getLine! : {} => Str
|
|
6
flake.lock
generated
6
flake.lock
generated
|
@ -89,11 +89,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727490462,
|
"lastModified": 1731378398,
|
||||||
"narHash": "sha256-OrrPiNBiikv9BR464XTT75FzOq7tKAvMbMi7YOKVIeg=",
|
"narHash": "sha256-a0QWaiX8+AJ9/XBLGMDy6c90GD7HzpxKVdlFwCke5Pw=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "11a13e50debafae4ae802f1d6b8585101516dd93",
|
"rev": "0ae9fc2f2fe5361837d59c0bdebbda176427111e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue