| ... | ... | @@ -449,7 +449,33 @@ pub const Builder = struct { |
| 449 | 449 | return null; |
| 450 | 450 | }, |
| 451 | 451 | }, |
| 452 | | .Int => panic("TODO integer options to build script", .{}), |
| 452 | .Int => switch (entry.value.value) { |
| 453 | .Flag => { |
| 454 | warn("Expected -D{} to be an integer, but received a boolean.\n", .{name}); |
| 455 | self.markInvalidUserInput(); |
| 456 | return null; |
| 457 | }, |
| 458 | .Scalar => |s| { |
| 459 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { |
| 460 | error.Overflow => { |
| 461 | warn("-D{} value {} cannot fit into type {}.\n", .{ name, s, @typeName(T) }); |
| 462 | self.markInvalidUserInput(); |
| 463 | return null; |
| 464 | }, |
| 465 | else => { |
| 466 | warn("Expected -D{} to be an integer of type {}.\n", .{ name, @typeName(T) }); |
| 467 | self.markInvalidUserInput(); |
| 468 | return null; |
| 469 | }, |
| 470 | }; |
| 471 | return n; |
| 472 | }, |
| 473 | .List => { |
| 474 | warn("Expected -D{} to be an integer, but received a list.\n", .{name}); |
| 475 | self.markInvalidUserInput(); |
| 476 | return null; |
| 477 | }, |
| 478 | }, |
| 453 | 479 | .Float => panic("TODO float options to build script", .{}), |
| 454 | 480 | .Enum => switch (entry.value.value) { |
| 455 | 481 | .Flag => { |