| ... | @@ -71,7 +71,7 @@ pub fn main() !void { | ... | @@ -71,7 +71,7 @@ pub fn main() !void { |
| 71 | const args = try process.argsAlloc(arena); | 71 | const args = try process.argsAlloc(arena); |
| 72 | | 72 | |
| 73 | if (args.len <= 1) { | 73 | if (args.len <= 1) { |
| 74 | std.debug.warn("expected command argument\n\n{}", .{usage}); | 74 | std.debug.print("expected command argument\n\n{}", .{usage}); |
| 75 | process.exit(1); | 75 | process.exit(1); |
| 76 | } | 76 | } |
| 77 | | 77 | |
| ... | @@ -91,14 +91,14 @@ pub fn main() !void { | ... | @@ -91,14 +91,14 @@ pub fn main() !void { |
| 91 | return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, info.target); | 91 | return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, info.target); |
| 92 | } else if (mem.eql(u8, cmd, "version")) { | 92 | } else if (mem.eql(u8, cmd, "version")) { |
| 93 | // Need to set up the build script to give the version as a comptime value. | 93 | // Need to set up the build script to give the version as a comptime value. |
| 94 | std.debug.warn("TODO version command not implemented yet\n", .{}); | 94 | std.debug.print("TODO version command not implemented yet\n", .{}); |
| 95 | return error.Unimplemented; | 95 | return error.Unimplemented; |
| 96 | } else if (mem.eql(u8, cmd, "zen")) { | 96 | } else if (mem.eql(u8, cmd, "zen")) { |
| 97 | try io.getStdOut().writeAll(info_zen); | 97 | try io.getStdOut().writeAll(info_zen); |
| 98 | } else if (mem.eql(u8, cmd, "help")) { | 98 | } else if (mem.eql(u8, cmd, "help")) { |
| 99 | try io.getStdOut().writeAll(usage); | 99 | try io.getStdOut().writeAll(usage); |
| 100 | } else { | 100 | } else { |
| 101 | std.debug.warn("unknown command: {}\n\n{}", .{ args[1], usage }); | 101 | std.debug.print("unknown command: {}\n\n{}", .{ args[1], usage }); |
| 102 | process.exit(1); | 102 | process.exit(1); |
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| ... | @@ -191,6 +191,7 @@ fn buildOutputType( | ... | @@ -191,6 +191,7 @@ fn buildOutputType( |
| 191 | var emit_zir: Emit = .no; | 191 | var emit_zir: Emit = .no; |
| 192 | var target_arch_os_abi: []const u8 = "native"; | 192 | var target_arch_os_abi: []const u8 = "native"; |
| 193 | var target_mcpu: ?[]const u8 = null; | 193 | var target_mcpu: ?[]const u8 = null; |
| | 194 | var target_c_standard: ?Module.CStandard = null; |
| 194 | var target_dynamic_linker: ?[]const u8 = null; | 195 | var target_dynamic_linker: ?[]const u8 = null; |
| 195 | | 196 | |
| 196 | var system_libs = std.ArrayList([]const u8).init(gpa); | 197 | var system_libs = std.ArrayList([]const u8).init(gpa); |
| ... | @@ -206,7 +207,7 @@ fn buildOutputType( | ... | @@ -206,7 +207,7 @@ fn buildOutputType( |
| 206 | process.exit(0); | 207 | process.exit(0); |
| 207 | } else if (mem.eql(u8, arg, "--color")) { | 208 | } else if (mem.eql(u8, arg, "--color")) { |
| 208 | if (i + 1 >= args.len) { | 209 | if (i + 1 >= args.len) { |
| 209 | std.debug.warn("expected [auto|on|off] after --color\n", .{}); | 210 | std.debug.print("expected [auto|on|off] after --color\n", .{}); |
| 210 | process.exit(1); | 211 | process.exit(1); |
| 211 | } | 212 | } |
| 212 | i += 1; | 213 | i += 1; |
| ... | @@ -218,12 +219,12 @@ fn buildOutputType( | ... | @@ -218,12 +219,12 @@ fn buildOutputType( |
| 218 | } else if (mem.eql(u8, next_arg, "off")) { | 219 | } else if (mem.eql(u8, next_arg, "off")) { |
| 219 | color = .Off; | 220 | color = .Off; |
| 220 | } else { | 221 | } else { |
| 221 | std.debug.warn("expected [auto|on|off] after --color, found '{}'\n", .{next_arg}); | 222 | std.debug.print("expected [auto|on|off] after --color, found '{}'\n", .{next_arg}); |
| 222 | process.exit(1); | 223 | process.exit(1); |
| 223 | } | 224 | } |
| 224 | } else if (mem.eql(u8, arg, "--mode")) { | 225 | } else if (mem.eql(u8, arg, "--mode")) { |
| 225 | if (i + 1 >= args.len) { | 226 | if (i + 1 >= args.len) { |
| 226 | std.debug.warn("expected [Debug|ReleaseSafe|ReleaseFast|ReleaseSmall] after --mode\n", .{}); | 227 | std.debug.print("expected [Debug|ReleaseSafe|ReleaseFast|ReleaseSmall] after --mode\n", .{}); |
| 227 | process.exit(1); | 228 | process.exit(1); |
| 228 | } | 229 | } |
| 229 | i += 1; | 230 | i += 1; |
| ... | @@ -237,52 +238,64 @@ fn buildOutputType( | ... | @@ -237,52 +238,64 @@ fn buildOutputType( |
| 237 | } else if (mem.eql(u8, next_arg, "ReleaseSmall")) { | 238 | } else if (mem.eql(u8, next_arg, "ReleaseSmall")) { |
| 238 | build_mode = .ReleaseSmall; | 239 | build_mode = .ReleaseSmall; |
| 239 | } else { | 240 | } else { |
| 240 | std.debug.warn("expected [Debug|ReleaseSafe|ReleaseFast|ReleaseSmall] after --mode, found '{}'\n", .{next_arg}); | 241 | std.debug.print("expected [Debug|ReleaseSafe|ReleaseFast|ReleaseSmall] after --mode, found '{}'\n", .{next_arg}); |
| 241 | process.exit(1); | 242 | process.exit(1); |
| 242 | } | 243 | } |
| 243 | } else if (mem.eql(u8, arg, "--name")) { | 244 | } else if (mem.eql(u8, arg, "--name")) { |
| 244 | if (i + 1 >= args.len) { | 245 | if (i + 1 >= args.len) { |
| 245 | std.debug.warn("expected parameter after --name\n", .{}); | 246 | std.debug.print("expected parameter after --name\n", .{}); |
| 246 | process.exit(1); | 247 | process.exit(1); |
| 247 | } | 248 | } |
| 248 | i += 1; | 249 | i += 1; |
| 249 | provided_name = args[i]; | 250 | provided_name = args[i]; |
| 250 | } else if (mem.eql(u8, arg, "--library")) { | 251 | } else if (mem.eql(u8, arg, "--library")) { |
| 251 | if (i + 1 >= args.len) { | 252 | if (i + 1 >= args.len) { |
| 252 | std.debug.warn("expected parameter after --library\n", .{}); | 253 | std.debug.print("expected parameter after --library\n", .{}); |
| 253 | process.exit(1); | 254 | process.exit(1); |
| 254 | } | 255 | } |
| 255 | i += 1; | 256 | i += 1; |
| 256 | try system_libs.append(args[i]); | 257 | try system_libs.append(args[i]); |
| 257 | } else if (mem.eql(u8, arg, "--version")) { | 258 | } else if (mem.eql(u8, arg, "--version")) { |
| 258 | if (i + 1 >= args.len) { | 259 | if (i + 1 >= args.len) { |
| 259 | std.debug.warn("expected parameter after --version\n", .{}); | 260 | std.debug.print("expected parameter after --version\n", .{}); |
| 260 | process.exit(1); | 261 | process.exit(1); |
| 261 | } | 262 | } |
| 262 | i += 1; | 263 | i += 1; |
| 263 | version = std.builtin.Version.parse(args[i]) catch |err| { | 264 | version = std.builtin.Version.parse(args[i]) catch |err| { |
| 264 | std.debug.warn("unable to parse --version '{}': {}\n", .{ args[i], @errorName(err) }); | 265 | std.debug.print("unable to parse --version '{}': {}\n", .{ args[i], @errorName(err) }); |
| 265 | process.exit(1); | 266 | process.exit(1); |
| 266 | }; | 267 | }; |
| 267 | } else if (mem.eql(u8, arg, "-target")) { | 268 | } else if (mem.eql(u8, arg, "-target")) { |
| 268 | if (i + 1 >= args.len) { | 269 | if (i + 1 >= args.len) { |
| 269 | std.debug.warn("expected parameter after -target\n", .{}); | 270 | std.debug.print("expected parameter after -target\n", .{}); |
| 270 | process.exit(1); | 271 | process.exit(1); |
| 271 | } | 272 | } |
| 272 | i += 1; | 273 | i += 1; |
| 273 | target_arch_os_abi = args[i]; | 274 | target_arch_os_abi = args[i]; |
| 274 | } else if (mem.eql(u8, arg, "-mcpu")) { | 275 | } else if (mem.eql(u8, arg, "-mcpu")) { |
| 275 | if (i + 1 >= args.len) { | 276 | if (i + 1 >= args.len) { |
| 276 | std.debug.warn("expected parameter after -mcpu\n", .{}); | 277 | std.debug.print("expected parameter after -mcpu\n", .{}); |
| 277 | process.exit(1); | 278 | process.exit(1); |
| 278 | } | 279 | } |
| 279 | i += 1; | 280 | i += 1; |
| 280 | target_mcpu = args[i]; | 281 | target_mcpu = args[i]; |
| | 282 | } else if (mem.eql(u8, arg, "--c-standard")) { |
| | 283 | if (i + 1 >= args.len) { |
| | 284 | std.debug.print("expected parameter after --c-standard\n", .{}); |
| | 285 | process.exit(1); |
| | 286 | } |
| | 287 | i += 1; |
| | 288 | if (std.meta.stringToEnum(Module.CStandard, args[i])) |cstd| { |
| | 289 | target_c_standard = cstd; |
| | 290 | } else { |
| | 291 | std.debug.print("Invalid C standard: {}\n", .{args[i]}); |
| | 292 | process.exit(1); |
| | 293 | } |
| 281 | } else if (mem.startsWith(u8, arg, "-mcpu=")) { | 294 | } else if (mem.startsWith(u8, arg, "-mcpu=")) { |
| 282 | target_mcpu = arg["-mcpu=".len..]; | 295 | target_mcpu = arg["-mcpu=".len..]; |
| 283 | } else if (mem.eql(u8, arg, "--dynamic-linker")) { | 296 | } else if (mem.eql(u8, arg, "--dynamic-linker")) { |
| 284 | if (i + 1 >= args.len) { | 297 | if (i + 1 >= args.len) { |
| 285 | std.debug.warn("expected parameter after --dynamic-linker\n", .{}); | 298 | std.debug.print("expected parameter after --dynamic-linker\n", .{}); |
| 286 | process.exit(1); | 299 | process.exit(1); |
| 287 | } | 300 | } |
| 288 | i += 1; | 301 | i += 1; |
| ... | @@ -324,56 +337,61 @@ fn buildOutputType( | ... | @@ -324,56 +337,61 @@ fn buildOutputType( |
| 324 | } else if (mem.startsWith(u8, arg, "-l")) { | 337 | } else if (mem.startsWith(u8, arg, "-l")) { |
| 325 | try system_libs.append(arg[2..]); | 338 | try system_libs.append(arg[2..]); |
| 326 | } else { | 339 | } else { |
| 327 | std.debug.warn("unrecognized parameter: '{}'", .{arg}); | 340 | std.debug.print("unrecognized parameter: '{}'", .{arg}); |
| 328 | process.exit(1); | 341 | process.exit(1); |
| 329 | } | 342 | } |
| 330 | } else if (mem.endsWith(u8, arg, ".s") or mem.endsWith(u8, arg, ".S")) { | 343 | } else if (mem.endsWith(u8, arg, ".s") or mem.endsWith(u8, arg, ".S")) { |
| 331 | std.debug.warn("assembly files not supported yet", .{}); | 344 | std.debug.print("assembly files not supported yet", .{}); |
| 332 | process.exit(1); | 345 | process.exit(1); |
| 333 | } else if (mem.endsWith(u8, arg, ".o") or | 346 | } else if (mem.endsWith(u8, arg, ".o") or |
| 334 | mem.endsWith(u8, arg, ".obj") or | 347 | mem.endsWith(u8, arg, ".obj") or |
| 335 | mem.endsWith(u8, arg, ".a") or | 348 | mem.endsWith(u8, arg, ".a") or |
| 336 | mem.endsWith(u8, arg, ".lib")) | 349 | mem.endsWith(u8, arg, ".lib")) |
| 337 | { | 350 | { |
| 338 | std.debug.warn("object files and static libraries not supported yet", .{}); | 351 | std.debug.print("object files and static libraries not supported yet", .{}); |
| 339 | process.exit(1); | 352 | process.exit(1); |
| 340 | } else if (mem.endsWith(u8, arg, ".c") or | 353 | } else if (mem.endsWith(u8, arg, ".c") or |
| 341 | mem.endsWith(u8, arg, ".cpp")) | 354 | mem.endsWith(u8, arg, ".cpp")) |
| 342 | { | 355 | { |
| 343 | std.debug.warn("compilation of C and C++ source code requires LLVM extensions which are not implemented yet", .{}); | 356 | std.debug.print("compilation of C and C++ source code requires LLVM extensions which are not implemented yet", .{}); |
| 344 | process.exit(1); | 357 | process.exit(1); |
| 345 | } else if (mem.endsWith(u8, arg, ".so") or | 358 | } else if (mem.endsWith(u8, arg, ".so") or |
| 346 | mem.endsWith(u8, arg, ".dylib") or | 359 | mem.endsWith(u8, arg, ".dylib") or |
| 347 | mem.endsWith(u8, arg, ".dll")) | 360 | mem.endsWith(u8, arg, ".dll")) |
| 348 | { | 361 | { |
| 349 | std.debug.warn("linking against dynamic libraries not yet supported", .{}); | 362 | std.debug.print("linking against dynamic libraries not yet supported", .{}); |
| 350 | process.exit(1); | 363 | process.exit(1); |
| 351 | } else if (mem.endsWith(u8, arg, ".zig") or mem.endsWith(u8, arg, ".zir")) { | 364 | } else if (mem.endsWith(u8, arg, ".zig") or mem.endsWith(u8, arg, ".zir")) { |
| 352 | if (root_src_file) |other| { | 365 | if (root_src_file) |other| { |
| 353 | std.debug.warn("found another zig file '{}' after root source file '{}'", .{ arg, other }); | 366 | std.debug.print("found another zig file '{}' after root source file '{}'", .{ arg, other }); |
| 354 | process.exit(1); | 367 | process.exit(1); |
| 355 | } else { | 368 | } else { |
| 356 | root_src_file = arg; | 369 | root_src_file = arg; |
| 357 | } | 370 | } |
| 358 | } else { | 371 | } else { |
| 359 | std.debug.warn("unrecognized file extension of parameter '{}'", .{arg}); | 372 | std.debug.print("unrecognized file extension of parameter '{}'", .{arg}); |
| 360 | } | 373 | } |
| 361 | } | 374 | } |
| 362 | } | 375 | } |
| 363 | | 376 | |
| | 377 | if (target_c_standard != null and output_mode != .Obj) { |
| | 378 | std.debug.print("The C backend must be used with build-obj\n", .{}); |
| | 379 | process.exit(1); |
| | 380 | } |
| | 381 | |
| 364 | const root_name = if (provided_name) |n| n else blk: { | 382 | const root_name = if (provided_name) |n| n else blk: { |
| 365 | if (root_src_file) |file| { | 383 | if (root_src_file) |file| { |
| 366 | const basename = fs.path.basename(file); | 384 | const basename = fs.path.basename(file); |
| 367 | var it = mem.split(basename, "."); | 385 | var it = mem.split(basename, "."); |
| 368 | break :blk it.next() orelse basename; | 386 | break :blk it.next() orelse basename; |
| 369 | } else { | 387 | } else { |
| 370 | std.debug.warn("--name [name] not provided and unable to infer\n", .{}); | 388 | std.debug.print("--name [name] not provided and unable to infer\n", .{}); |
| 371 | process.exit(1); | 389 | process.exit(1); |
| 372 | } | 390 | } |
| 373 | }; | 391 | }; |
| 374 | | 392 | |
| 375 | if (system_libs.items.len != 0) { | 393 | if (system_libs.items.len != 0) { |
| 376 | std.debug.warn("linking against system libraries not yet supported", .{}); | 394 | std.debug.print("linking against system libraries not yet supported", .{}); |
| 377 | process.exit(1); | 395 | process.exit(1); |
| 378 | } | 396 | } |
| 379 | | 397 | |
| ... | @@ -385,17 +403,17 @@ fn buildOutputType( | ... | @@ -385,17 +403,17 @@ fn buildOutputType( |
| 385 | .diagnostics = &diags, | 403 | .diagnostics = &diags, |
| 386 | }) catch |err| switch (err) { | 404 | }) catch |err| switch (err) { |
| 387 | error.UnknownCpuModel => { | 405 | error.UnknownCpuModel => { |
| 388 | std.debug.warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ | 406 | std.debug.print("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ |
| 389 | diags.cpu_name.?, | 407 | diags.cpu_name.?, |
| 390 | @tagName(diags.arch.?), | 408 | @tagName(diags.arch.?), |
| 391 | }); | 409 | }); |
| 392 | for (diags.arch.?.allCpuModels()) |cpu| { | 410 | for (diags.arch.?.allCpuModels()) |cpu| { |
| 393 | std.debug.warn(" {}\n", .{cpu.name}); | 411 | std.debug.print(" {}\n", .{cpu.name}); |
| 394 | } | 412 | } |
| 395 | process.exit(1); | 413 | process.exit(1); |
| 396 | }, | 414 | }, |
| 397 | error.UnknownCpuFeature => { | 415 | error.UnknownCpuFeature => { |
| 398 | std.debug.warn( | 416 | std.debug.print( |
| 399 | \\Unknown CPU feature: '{}' | 417 | \\Unknown CPU feature: '{}' |
| 400 | \\Available CPU features for architecture '{}': | 418 | \\Available CPU features for architecture '{}': |
| 401 | \\ | 419 | \\ |
| ... | @@ -404,7 +422,7 @@ fn buildOutputType( | ... | @@ -404,7 +422,7 @@ fn buildOutputType( |
| 404 | @tagName(diags.arch.?), | 422 | @tagName(diags.arch.?), |
| 405 | }); | 423 | }); |
| 406 | for (diags.arch.?.allFeaturesList()) |feature| { | 424 | for (diags.arch.?.allFeaturesList()) |feature| { |
| 407 | std.debug.warn(" {}: {}\n", .{ feature.name, feature.description }); | 425 | std.debug.print(" {}: {}\n", .{ feature.name, feature.description }); |
| 408 | } | 426 | } |
| 409 | process.exit(1); | 427 | process.exit(1); |
| 410 | }, | 428 | }, |
| ... | @@ -416,21 +434,22 @@ fn buildOutputType( | ... | @@ -416,21 +434,22 @@ fn buildOutputType( |
| 416 | if (target_info.cpu_detection_unimplemented) { | 434 | if (target_info.cpu_detection_unimplemented) { |
| 417 | // TODO We want to just use detected_info.target but implementing | 435 | // TODO We want to just use detected_info.target but implementing |
| 418 | // CPU model & feature detection is todo so here we rely on LLVM. | 436 | // CPU model & feature detection is todo so here we rely on LLVM. |
| 419 | std.debug.warn("CPU features detection is not yet available for this system without LLVM extensions\n", .{}); | 437 | std.debug.print("CPU features detection is not yet available for this system without LLVM extensions\n", .{}); |
| 420 | process.exit(1); | 438 | process.exit(1); |
| 421 | } | 439 | } |
| 422 | | 440 | |
| 423 | const src_path = root_src_file orelse { | 441 | const src_path = root_src_file orelse { |
| 424 | std.debug.warn("expected at least one file argument", .{}); | 442 | std.debug.print("expected at least one file argument", .{}); |
| 425 | process.exit(1); | 443 | process.exit(1); |
| 426 | }; | 444 | }; |
| 427 | | 445 | |
| 428 | const bin_path = switch (emit_bin) { | 446 | const bin_path = switch (emit_bin) { |
| 429 | .no => { | 447 | .no => { |
| 430 | std.debug.warn("-fno-emit-bin not supported yet", .{}); | 448 | std.debug.print("-fno-emit-bin not supported yet", .{}); |
| 431 | process.exit(1); | 449 | process.exit(1); |
| 432 | }, | 450 | }, |
| 433 | .yes_default_path => try std.zig.binNameAlloc(arena, root_name, target_info.target, output_mode, link_mode), | 451 | .yes_default_path => try std.fmt.allocPrint(arena, "{}.c", .{root_name}), |
| | 452 | |
| 434 | .yes => |p| p, | 453 | .yes => |p| p, |
| 435 | }; | 454 | }; |
| 436 | | 455 | |
| ... | @@ -460,6 +479,7 @@ fn buildOutputType( | ... | @@ -460,6 +479,7 @@ fn buildOutputType( |
| 460 | .object_format = object_format, | 479 | .object_format = object_format, |
| 461 | .optimize_mode = build_mode, | 480 | .optimize_mode = build_mode, |
| 462 | .keep_source_files_loaded = zir_out_path != null, | 481 | .keep_source_files_loaded = zir_out_path != null, |
| | 482 | .c_standard = target_c_standard, |
| 463 | }); | 483 | }); |
| 464 | defer module.deinit(); | 484 | defer module.deinit(); |
| 465 | | 485 | |
| ... | @@ -506,7 +526,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo | ... | @@ -506,7 +526,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo |
| 506 | | 526 | |
| 507 | if (errors.list.len != 0) { | 527 | if (errors.list.len != 0) { |
| 508 | for (errors.list) |full_err_msg| { | 528 | for (errors.list) |full_err_msg| { |
| 509 | std.debug.warn("{}:{}:{}: error: {}\n", .{ | 529 | std.debug.print("{}:{}:{}: error: {}\n", .{ |
| 510 | full_err_msg.src_path, | 530 | full_err_msg.src_path, |
| 511 | full_err_msg.line + 1, | 531 | full_err_msg.line + 1, |
| 512 | full_err_msg.column + 1, | 532 | full_err_msg.column + 1, |
| ... | @@ -583,7 +603,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -583,7 +603,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 583 | process.exit(0); | 603 | process.exit(0); |
| 584 | } else if (mem.eql(u8, arg, "--color")) { | 604 | } else if (mem.eql(u8, arg, "--color")) { |
| 585 | if (i + 1 >= args.len) { | 605 | if (i + 1 >= args.len) { |
| 586 | std.debug.warn("expected [auto|on|off] after --color\n", .{}); | 606 | std.debug.print("expected [auto|on|off] after --color\n", .{}); |
| 587 | process.exit(1); | 607 | process.exit(1); |
| 588 | } | 608 | } |
| 589 | i += 1; | 609 | i += 1; |
| ... | @@ -595,7 +615,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -595,7 +615,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 595 | } else if (mem.eql(u8, next_arg, "off")) { | 615 | } else if (mem.eql(u8, next_arg, "off")) { |
| 596 | color = .Off; | 616 | color = .Off; |
| 597 | } else { | 617 | } else { |
| 598 | std.debug.warn("expected [auto|on|off] after --color, found '{}'\n", .{next_arg}); | 618 | std.debug.print("expected [auto|on|off] after --color, found '{}'\n", .{next_arg}); |
| 599 | process.exit(1); | 619 | process.exit(1); |
| 600 | } | 620 | } |
| 601 | } else if (mem.eql(u8, arg, "--stdin")) { | 621 | } else if (mem.eql(u8, arg, "--stdin")) { |
| ... | @@ -603,7 +623,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -603,7 +623,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 603 | } else if (mem.eql(u8, arg, "--check")) { | 623 | } else if (mem.eql(u8, arg, "--check")) { |
| 604 | check_flag = true; | 624 | check_flag = true; |
| 605 | } else { | 625 | } else { |
| 606 | std.debug.warn("unrecognized parameter: '{}'", .{arg}); | 626 | std.debug.print("unrecognized parameter: '{}'", .{arg}); |
| 607 | process.exit(1); | 627 | process.exit(1); |
| 608 | } | 628 | } |
| 609 | } else { | 629 | } else { |
| ... | @@ -614,7 +634,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -614,7 +634,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 614 | | 634 | |
| 615 | if (stdin_flag) { | 635 | if (stdin_flag) { |
| 616 | if (input_files.items.len != 0) { | 636 | if (input_files.items.len != 0) { |
| 617 | std.debug.warn("cannot use --stdin with positional arguments\n", .{}); | 637 | std.debug.print("cannot use --stdin with positional arguments\n", .{}); |
| 618 | process.exit(1); | 638 | process.exit(1); |
| 619 | } | 639 | } |
| 620 | | 640 | |
| ... | @@ -624,7 +644,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -624,7 +644,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 624 | defer gpa.free(source_code); | 644 | defer gpa.free(source_code); |
| 625 | | 645 | |
| 626 | const tree = std.zig.parse(gpa, source_code) catch |err| { | 646 | const tree = std.zig.parse(gpa, source_code) catch |err| { |
| 627 | std.debug.warn("error parsing stdin: {}\n", .{err}); | 647 | std.debug.print("error parsing stdin: {}\n", .{err}); |
| 628 | process.exit(1); | 648 | process.exit(1); |
| 629 | }; | 649 | }; |
| 630 | defer tree.deinit(); | 650 | defer tree.deinit(); |
| ... | @@ -647,7 +667,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -647,7 +667,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 647 | } | 667 | } |
| 648 | | 668 | |
| 649 | if (input_files.items.len == 0) { | 669 | if (input_files.items.len == 0) { |
| 650 | std.debug.warn("expected at least one source file argument\n", .{}); | 670 | std.debug.print("expected at least one source file argument\n", .{}); |
| 651 | process.exit(1); | 671 | process.exit(1); |
| 652 | } | 672 | } |
| 653 | | 673 | |
| ... | @@ -664,7 +684,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -664,7 +684,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 664 | for (input_files.span()) |file_path| { | 684 | for (input_files.span()) |file_path| { |
| 665 | // Get the real path here to avoid Windows failing on relative file paths with . or .. in them. | 685 | // Get the real path here to avoid Windows failing on relative file paths with . or .. in them. |
| 666 | const real_path = fs.realpathAlloc(gpa, file_path) catch |err| { | 686 | const real_path = fs.realpathAlloc(gpa, file_path) catch |err| { |
| 667 | std.debug.warn("unable to open '{}': {}\n", .{ file_path, err }); | 687 | std.debug.print("unable to open '{}': {}\n", .{ file_path, err }); |
| 668 | process.exit(1); | 688 | process.exit(1); |
| 669 | }; | 689 | }; |
| 670 | defer gpa.free(real_path); | 690 | defer gpa.free(real_path); |
| ... | @@ -702,7 +722,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_ | ... | @@ -702,7 +722,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_ |
| 702 | fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) { | 722 | fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) { |
| 703 | error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path), | 723 | error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path), |
| 704 | else => { | 724 | else => { |
| 705 | std.debug.warn("unable to format '{}': {}\n", .{ file_path, err }); | 725 | std.debug.print("unable to format '{}': {}\n", .{ file_path, err }); |
| 706 | fmt.any_error = true; | 726 | fmt.any_error = true; |
| 707 | return; | 727 | return; |
| 708 | }, | 728 | }, |
| ... | @@ -733,7 +753,7 @@ fn fmtPathDir( | ... | @@ -733,7 +753,7 @@ fn fmtPathDir( |
| 733 | try fmtPathDir(fmt, full_path, check_mode, dir, entry.name); | 753 | try fmtPathDir(fmt, full_path, check_mode, dir, entry.name); |
| 734 | } else { | 754 | } else { |
| 735 | fmtPathFile(fmt, full_path, check_mode, dir, entry.name) catch |err| { | 755 | fmtPathFile(fmt, full_path, check_mode, dir, entry.name) catch |err| { |
| 736 | std.debug.warn("unable to format '{}': {}\n", .{ full_path, err }); | 756 | std.debug.print("unable to format '{}': {}\n", .{ full_path, err }); |
| 737 | fmt.any_error = true; | 757 | fmt.any_error = true; |
| 738 | return; | 758 | return; |
| 739 | }; | 759 | }; |
| ... | @@ -784,7 +804,7 @@ fn fmtPathFile( | ... | @@ -784,7 +804,7 @@ fn fmtPathFile( |
| 784 | if (check_mode) { | 804 | if (check_mode) { |
| 785 | const anything_changed = try std.zig.render(fmt.gpa, io.null_out_stream, tree); | 805 | const anything_changed = try std.zig.render(fmt.gpa, io.null_out_stream, tree); |
| 786 | if (anything_changed) { | 806 | if (anything_changed) { |
| 787 | std.debug.warn("{}\n", .{file_path}); | 807 | std.debug.print("{}\n", .{file_path}); |
| 788 | fmt.any_error = true; | 808 | fmt.any_error = true; |
| 789 | } | 809 | } |
| 790 | } else { | 810 | } else { |
| ... | @@ -800,7 +820,7 @@ fn fmtPathFile( | ... | @@ -800,7 +820,7 @@ fn fmtPathFile( |
| 800 | | 820 | |
| 801 | try af.file.writeAll(fmt.out_buffer.items); | 821 | try af.file.writeAll(fmt.out_buffer.items); |
| 802 | try af.finish(); | 822 | try af.finish(); |
| 803 | std.debug.warn("{}\n", .{file_path}); | 823 | std.debug.print("{}\n", .{file_path}); |
| 804 | } | 824 | } |
| 805 | } | 825 | } |
| 806 | | 826 | |