mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:04:43 +01:00
update tests and tools to new main API
This commit is contained in:
parent
9009ab2495
commit
f9585ad01f
11 changed files with 33 additions and 106 deletions
|
|
@ -11,16 +11,8 @@
|
|||
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
const arena = arena_state.allocator();
|
||||
defer arena_state.deinit();
|
||||
|
||||
try run(arena);
|
||||
}
|
||||
|
||||
fn run(allocator: std.mem.Allocator) !void {
|
||||
var args = try std.process.argsWithAllocator(allocator);
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
var args = try init.args.iterateAllocator(init.arena);
|
||||
defer args.deinit();
|
||||
_ = args.next() orelse unreachable; // skip binary name
|
||||
|
||||
|
|
|
|||
|
|
@ -13,16 +13,8 @@
|
|||
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
const arena = arena_state.allocator();
|
||||
defer arena_state.deinit();
|
||||
|
||||
try run(arena);
|
||||
}
|
||||
|
||||
fn run(allocator: std.mem.Allocator) !void {
|
||||
var args = try std.process.argsWithAllocator(allocator);
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
var args = try init.args.iterateAllocator(init.arena);
|
||||
defer args.deinit();
|
||||
_ = args.next() orelse unreachable; // skip binary name
|
||||
|
||||
|
|
|
|||
|
|
@ -8,16 +8,8 @@
|
|||
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
const arena = arena_state.allocator();
|
||||
defer arena_state.deinit();
|
||||
|
||||
try run(arena);
|
||||
}
|
||||
|
||||
fn run(allocator: std.mem.Allocator) !void {
|
||||
var args = try std.process.argsWithAllocator(allocator);
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
var args = try init.args.iterateAllocator(init.arena);
|
||||
defer args.deinit();
|
||||
_ = args.next() orelse unreachable; // skip binary name
|
||||
|
||||
|
|
|
|||
|
|
@ -8,20 +8,11 @@ const Path = std.Build.Cache.Path;
|
|||
const assert = std.debug.assert;
|
||||
const SeenPcsHeader = std.Build.abi.fuzz.SeenPcsHeader;
|
||||
|
||||
pub fn main() !void {
|
||||
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
|
||||
defer _ = debug_allocator.deinit();
|
||||
const gpa = debug_allocator.allocator();
|
||||
|
||||
var arena_instance: std.heap.ArenaAllocator = .init(gpa);
|
||||
defer arena_instance.deinit();
|
||||
const arena = arena_instance.allocator();
|
||||
|
||||
var threaded: Io.Threaded = .init(gpa, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
const args = try std.process.argsAlloc(arena);
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const gpa = init.gpa;
|
||||
const arena = init.arena;
|
||||
const io = init.io;
|
||||
const args = try init.args.toSlice(arena);
|
||||
|
||||
const target_query_str = switch (args.len) {
|
||||
3 => "native",
|
||||
|
|
|
|||
|
|
@ -66,12 +66,9 @@ const usage =
|
|||
\\-h, --help Print this help and exit
|
||||
;
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
var arena = std.heap.ArenaAllocator.init(gpa);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
const args = try std.process.argsAlloc(allocator);
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const allocator = init.arena;
|
||||
const args = try init.args.toSlice(allocator);
|
||||
|
||||
var argv = std.array_list.Managed([]const u8).init(allocator);
|
||||
var sysroot: ?[]const u8 = null;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,6 @@ const info = std.log.info;
|
|||
const fatal = std.process.fatal;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const gpa = general_purpose_allocator.allocator();
|
||||
|
||||
const usage =
|
||||
\\gen_macos_headers_c [dir]
|
||||
\\
|
||||
|
|
@ -16,16 +13,11 @@ const usage =
|
|||
\\-h, --help Print this help and exit
|
||||
;
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(gpa);
|
||||
defer arena_allocator.deinit();
|
||||
const arena = arena_allocator.allocator();
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const arena = init.arena;
|
||||
const io = init.io;
|
||||
|
||||
var threaded: Io.Threaded = .init(gpa, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
const args = try std.process.argsAlloc(arena);
|
||||
const args = try init.args.toSlice(arena);
|
||||
if (args.len == 1) fatal("no command or option specified", .{});
|
||||
|
||||
var positionals = std.array_list.Managed([]const u8).init(arena);
|
||||
|
|
|
|||
|
|
@ -11,14 +11,9 @@ const AtomicOp = enum {
|
|||
ldset,
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena_instance.deinit();
|
||||
const arena = arena_instance.allocator();
|
||||
|
||||
var threaded: std.Io.Threaded = .init(arena, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const arena = init.arena;
|
||||
const io = init.io;
|
||||
|
||||
//const args = try std.process.argsAlloc(arena);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,9 @@
|
|||
const std = @import("std");
|
||||
const Io = std.Io;
|
||||
|
||||
pub fn main() !void {
|
||||
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
|
||||
var allocator = gpa.allocator();
|
||||
|
||||
var threaded: std.Io.Threaded = .init(allocator, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const allocator = init.gpa;
|
||||
const io = init.io;
|
||||
|
||||
var stdout_buffer: [2000]u8 = undefined;
|
||||
var stdout_writer = Io.File.stdout().writerStreaming(io, &stdout_buffer);
|
||||
|
|
|
|||
|
|
@ -28,22 +28,15 @@ fn cName(ty: std.Target.CType) []const u8 {
|
|||
|
||||
var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;
|
||||
|
||||
pub fn main() !void {
|
||||
const gpa = general_purpose_allocator.allocator();
|
||||
defer std.debug.assert(general_purpose_allocator.deinit() == .ok);
|
||||
|
||||
const args = try std.process.argsAlloc(gpa);
|
||||
defer std.process.argsFree(gpa, args);
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const args = try init.args.toSlice(init.arena);
|
||||
const io = init.io;
|
||||
|
||||
if (args.len != 2) {
|
||||
std.debug.print("Usage: {s} [target_triple]\n", .{args[0]});
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
||||
var threaded: std.Io.Threaded = .init(gpa, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
const query = try std.Target.Query.parse(.{ .arch_os_abi = args[1] });
|
||||
const target = try std.zig.system.resolveTargetQuery(io, query);
|
||||
|
||||
|
|
|
|||
|
|
@ -170,14 +170,9 @@ const architectures: []const Arch = &.{
|
|||
// .{ .@"var" = "Microblaze", .table = .{ .specific = "arch/microblaze/kernel/syscalls/syscall.tbl" } },
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
const gpa = arena.allocator();
|
||||
|
||||
var threaded: Io.Threaded = .init(gpa, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const gpa = init.gpa;
|
||||
const io = init.io;
|
||||
|
||||
const args = try std.process.argsAlloc(gpa);
|
||||
if (args.len < 2 or mem.eql(u8, args[1], "--help")) {
|
||||
|
|
|
|||
|
|
@ -27,18 +27,10 @@ fn logImpl(
|
|||
);
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
const fatal = std.process.fatal;
|
||||
|
||||
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena_instance.deinit();
|
||||
const arena = arena_instance.allocator();
|
||||
|
||||
const gpa = arena;
|
||||
|
||||
var threaded: Io.Threaded = .init(gpa, .{});
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
const arena = init.arena;
|
||||
const io = init.io;
|
||||
|
||||
var opt_zig_exe: ?[]const u8 = null;
|
||||
var opt_input_file_name: ?[]const u8 = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue