Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 1 addition & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,10 @@ pub fn build(b: *std.Build) !void {
optimization_modes,
enable_macos_sdk,
enable_ios_sdk,
false,
enable_symlinks_windows,
));
test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, false, enable_symlinks_windows));
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
test_step.dependOn(tests.addStackTraceTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addCliTests(b));
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filters, optimization_modes));
Expand Down
15 changes: 15 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// The Zig compiler is not intended to be consumed as a package.
// The sole purpose of this manifest file is to test the compiler.
.{
.name = "zig",
.version = "0.0.0",
.dependencies = .{
.standalone_test_cases = .{
.path = "test/standalone",
},
.link_test_cases = .{
.path = "test/link",
},
},
.paths = .{""},
}
21 changes: 1 addition & 20 deletions lib/std/Build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1973,25 +1973,6 @@ pub fn dependencyFromBuildZig(
debug.panic("'{}' is not a build.zig struct of a dependecy in '{s}'", .{ build_zig, full_path });
}

pub fn anonymousDependency(
b: *Build,
/// The path to the directory containing the dependency's build.zig file,
/// relative to the current package's build.zig.
relative_build_root: []const u8,
/// A direct `@import` of the build.zig of the dependency.
comptime build_zig: type,
args: anytype,
) *Dependency {
const arena = b.allocator;
const build_root = b.build_root.join(arena, &.{relative_build_root}) catch @panic("OOM");
const name = arena.dupe(u8, relative_build_root) catch @panic("OOM");
for (name) |*byte| switch (byte.*) {
'/', '\\' => byte.* = '.',
else => continue,
};
return dependencyInner(b, name, build_root, build_zig, "anonymous", &.{}, args);
}

fn userValuesAreSame(lhs: UserValue, rhs: UserValue) bool {
switch (lhs) {
.flag => {},
Expand Down Expand Up @@ -2039,7 +2020,7 @@ fn userValuesAreSame(lhs: UserValue, rhs: UserValue) bool {
return true;
}

pub fn dependencyInner(
fn dependencyInner(
b: *Build,
name: []const u8,
build_root_string: []const u8,
Expand Down
94 changes: 0 additions & 94 deletions test/link.zig

This file was deleted.

54 changes: 54 additions & 0 deletions test/link/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const std = @import("std");
const builtin = @import("builtin");
const link = @import("link.zig");

pub fn build(b: *std.Build) void {
const step = b.step("test", "Run link test cases");
b.default_step = step;

const enable_ios_sdk = b.option(bool, "enable_ios_sdk", "Run tests requiring presence of iOS SDK and frameworks") orelse false;
const enable_macos_sdk = b.option(bool, "enable_macos_sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse enable_ios_sdk;
const enable_symlinks_windows = b.option(bool, "enable_symlinks_windows", "Run tests requiring presence of symlinks on Windows") orelse false;
const omit_symlinks = builtin.os.tag == .windows and !enable_symlinks_windows;

const build_opts: link.BuildOptions = .{
.has_ios_sdk = enable_ios_sdk,
.has_macos_sdk = enable_macos_sdk,
.has_symlinks_windows = omit_symlinks,
};
step.dependOn(@import("elf.zig").testAll(b, build_opts));
step.dependOn(@import("macho.zig").testAll(b, build_opts));

add_dep_steps: for (b.available_deps) |available_dep| {
const dep_name, const dep_hash = available_dep;

const all_pkgs = @import("root").dependencies.packages;
inline for (@typeInfo(all_pkgs).Struct.decls) |decl| {
const pkg_hash = decl.name;
if (std.mem.eql(u8, dep_hash, pkg_hash)) {
const pkg = @field(all_pkgs, pkg_hash);
if (!@hasDecl(pkg, "build_zig")) {
std.debug.panic("link test case '{s}' is missing a 'build.zig' file", .{dep_name});
}
const requires_ios_sdk = @hasDecl(pkg.build_zig, "requires_ios_sdk") and
pkg.build_zig.requires_ios_sdk;
const requires_macos_sdk = @hasDecl(pkg.build_zig, "requires_macos_sdk") and
pkg.build_zig.requires_macos_sdk;
const requires_symlinks = @hasDecl(pkg.build_zig, "requires_symlinks") and
pkg.build_zig.requires_symlinks;
if ((requires_symlinks and omit_symlinks) or
(requires_macos_sdk and !enable_macos_sdk) or
(requires_ios_sdk and !enable_ios_sdk))
{
continue :add_dep_steps;
}
break;
}
} else unreachable;

const dep = b.dependency(dep_name, .{});
const dep_step = dep.builder.default_step;
dep_step.name = b.fmt("link_test_cases.{s}", .{dep_name});
step.dependOn(dep_step);
}
}
69 changes: 69 additions & 0 deletions test/link/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.{
.name = "link_test_cases",
.version = "0.0.0",
.dependencies = .{
.bss = .{
.path = "bss",
},
.common_symbols_alignment = .{
.path = "common_symbols_alignment",
},
.interdependent_static_c_libs = .{
.path = "interdependent_static_c_libs",
},
.static_libs_from_object_files = .{
.path = "static_libs_from_object_files",
},
.glibc_compat = .{
.path = "glibc_compat",
},
// WASM Cases
.wasm_archive = .{
.path = "wasm/archive",
},
.wasm_basic_features = .{
.path = "wasm/basic-features",
},
.wasm_bss = .{
.path = "wasm/bss",
},
.wasm_export = .{
.path = "wasm/export",
},
.wasm_export_data = .{
.path = "wasm/export-data",
},
.wasm_extern = .{
.path = "wasm/extern",
},
.wasm_extern_mangle = .{
.path = "wasm/extern-mangle",
},
.wasm_function_table = .{
.path = "wasm/function-table",
},
.wasm_infer_features = .{
.path = "wasm/infer-features",
},
.wasm_producers = .{
.path = "wasm/producers",
},
.wasm_segments = .{
.path = "wasm/segments",
},
.wasm_shared_memory = .{
.path = "wasm/shared-memory",
},
.wasm_stack_pointer = .{
.path = "wasm/stack_pointer",
},
.wasm_type = .{
.path = "wasm/type",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"link.zig",
},
}
Loading