Skip to content

Commit

Permalink
fixed compilation with zig 13.0
Browse files Browse the repository at this point in the history
fixed compilation with zig 13.0

upgraded to 0.13.0
  • Loading branch information
pierrelgol committed Jun 10, 2024
1 parent 4d25c7e commit aaed4af
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0
version: 0.13.0
- run: |
zig build ci --summary all
- if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*~
zig-cache/
.zig-cache/
zig-out/
/dep
/scratch
14 changes: 7 additions & 7 deletions test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub fn main() !u8 {
// NOTE: this test will eventually break when these builds are cleaned up,
// we should support downloading from bazel and use that instead since
// it should be more permanent
try runNoCapture(zigup_args ++ &[_][]const u8{ "0.12.0-dev.3639+9cfac4718" });
try runNoCapture(zigup_args ++ &[_][]const u8{ "0.14.0-dev.14+ec337051a" });

std.log.info("Success", .{});
return 0;
Expand Down Expand Up @@ -404,7 +404,7 @@ fn trailNl(s: []const u8) []const u8 {
return if (s.len == 0 or s[s.len - 1] != '\n') "\n" else "";
}

fn dumpExecResult(result: std.ChildProcess.RunResult) void {
fn dumpExecResult(result: std.process.Child.RunResult) void {
if (result.stdout.len > 0) {
std.debug.print("--- STDOUT ---\n{s}{s}--------------\n", .{ result.stdout, trailNl(result.stdout) });
}
Expand All @@ -420,28 +420,28 @@ fn runNoCapture(argv: []const []const u8) !void {
dumpExecResult(result);
try passOrThrow(result.term);
}
fn runCaptureOuts(allocator: std.mem.Allocator, argv: []const []const u8) !std.ChildProcess.RunResult {
fn runCaptureOuts(allocator: std.mem.Allocator, argv: []const []const u8) !std.process.Child.RunResult {
{
const cmd = try std.mem.join(allocator, " ", argv);
defer allocator.free(cmd);
std.log.info("RUN: {s}", .{cmd});
}
return try std.ChildProcess.run(.{ .allocator = allocator, .argv = argv, .env_map = &child_env_map });
return try std.process.Child.run(.{ .allocator = allocator, .argv = argv, .env_map = &child_env_map });
}
fn passOrThrow(term: std.ChildProcess.Term) error{ChildProcessFailed}!void {
fn passOrThrow(term: std.process.Child.Term) error{ChildProcessFailed}!void {
if (!execResultPassed(term)) {
std.log.err("child process failed with {}", .{term});
return error.ChildProcessFailed;
}
}
fn passOrDumpAndThrow(result: std.ChildProcess.RunResult) error{ChildProcessFailed}!void {
fn passOrDumpAndThrow(result: std.process.Child.RunResult) error{ChildProcessFailed}!void {
if (!execResultPassed(result.term)) {
dumpExecResult(result);
std.log.err("child process failed with {}", .{result.term});
return error.ChildProcessFailed;
}
}
fn execResultPassed(term: std.ChildProcess.Term) bool {
fn execResultPassed(term: std.process.Child.Term) bool {
switch (term) {
.Exited => |code| return code == 0,
else => return false,
Expand Down
6 changes: 3 additions & 3 deletions win32exelink.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export var zig_exe_string: [exe_marker_len + std.fs.MAX_PATH_BYTES + 1]u8 =
("!!!THIS MARKS THE zig_exe_string MEMORY!!#" ++ ([1]u8{0} ** (std.fs.MAX_PATH_BYTES + 1))).*;

const global = struct {
var child: std.ChildProcess = undefined;
var child: std.process.Child = undefined;
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const arena = arena_instance.allocator();
};
Expand Down Expand Up @@ -42,8 +42,8 @@ pub fn main() !u8 {
}
args[0] = zig_exe;

// NOTE: create the ChildProcess before calling SetConsoleCtrlHandler because it uses it
global.child = std.ChildProcess.init(args, global.arena);
// NOTE: create the process.child before calling SetConsoleCtrlHandler because it uses it
global.child = std.process.Child.init(args, global.arena);

if (0 == win32.SetConsoleCtrlHandler(consoleCtrlHandler, 1)) {
log.err("SetConsoleCtrlHandler failed, error={}", .{win32.GetLastError()});
Expand Down
6 changes: 3 additions & 3 deletions zigup.zig
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub fn runCompiler(allocator: Allocator, args: []const []const u8) !u8 {
try argv.appendSlice(args[1..]);

// TODO: use "execve" if on linux
var proc = std.ChildProcess.init(argv.items, allocator);
var proc = std.process.Child.init(argv.items, allocator);
const ret_val = try proc.spawnAndWait();
switch (ret_val) {
.Exited => |code| return code,
Expand Down Expand Up @@ -1038,9 +1038,9 @@ fn installCompiler(allocator: Allocator, compiler_dir: []const u8, url: []const
try loggyRenameAbsolute(installing_dir, compiler_dir);
}

pub fn run(allocator: Allocator, argv: []const []const u8) !std.ChildProcess.Term {
pub fn run(allocator: Allocator, argv: []const []const u8) !std.process.Child.Term {
try logRun(allocator, argv);
var proc = std.ChildProcess.init(argv, allocator);
var proc = std.process.Child.init(argv, allocator);
return proc.spawnAndWait();
}

Expand Down

0 comments on commit aaed4af

Please sign in to comment.