Compare commits

..

No commits in common. "074db7f4f6a61e4e9847c76a51ebc6669b5f6ed2" and "70c6cea59112f90c9732f97abe11c1de8bf5598e" have entirely different histories.

5 changed files with 13 additions and 25 deletions

View File

@ -1,11 +1,11 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target: std.Build.ResolvedTarget = b.standardTargetOptions(.{});
const target: std.zig.CrossTarget = b.standardTargetOptions(.{});
const optimize: std.builtin.Mode = b.standardOptimizeOption(.{});
const noclip = b.addModule("noclip", .{
.root_source_file = .{ .path = "source/noclip.zig" },
.source_file = .{ .path = "source/noclip.zig" },
});
demo(b, noclip, target, optimize);
@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void {
fn demo(
b: *std.Build,
noclip: *std.Build.Module,
target: std.Build.ResolvedTarget,
target: std.zig.CrossTarget,
optimize: std.builtin.Mode,
) void {
const demo_step = b.step("demo", "Build and install CLI demo program");
@ -35,7 +35,7 @@ fn demo(
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("noclip", noclip);
exe.addModule("noclip", noclip);
const install_demo = b.addInstallArtifact(exe, .{});
demo_step.dependOn(&install_demo.step);

View File

@ -1,11 +0,0 @@
.{
.name = "NOCLIP",
.version = "0.1.0-pre",
.dependencies = .{},
.paths = .{
"source",
"build.zig",
"build.zig.zon",
"license",
},
}

View File

@ -372,9 +372,7 @@ pub fn CommandBuilder(comptime UserContext: type) type {
// global tags and env_vars would conflict, which is less common.
if (param.short_tag) |short|
tag_fields = tag_fields ++ &[_]StructField{.{
// this goofy construct coerces the comptime []const u8 to
// [:0]const u8.
.name = short ++ "",
.name = short,
.type = void,
.default_value = null,
.is_comptime = false,
@ -383,7 +381,7 @@ pub fn CommandBuilder(comptime UserContext: type) type {
if (param.long_tag) |long|
tag_fields = tag_fields ++ &[_]StructField{.{
.name = long ++ "",
.name = long,
.type = void,
.default_value = null,
.is_comptime = false,
@ -392,7 +390,7 @@ pub fn CommandBuilder(comptime UserContext: type) type {
if (param.env_var) |env_var|
env_var_fields = env_var_fields ++ &[_]StructField{.{
.name = env_var ++ "",
.name = env_var,
.type = void,
.default_value = null,
.is_comptime = false,
@ -437,7 +435,7 @@ pub fn CommandBuilder(comptime UserContext: type) type {
const default = if (param.default) |def| &@as(FieldType, def) else @as(?*const anyopaque, null);
fields = fields ++ &[_]StructField{.{
.name = param.name ++ "",
.name = param.name,
.type = FieldType,
.default_value = @ptrCast(default),
.is_comptime = false,
@ -507,7 +505,7 @@ pub fn CommandBuilder(comptime UserContext: type) type {
?PType.G.IntermediateType();
fields = &(@as([fields.len]StructField, fields[0..fields.len].*) ++ [1]StructField{.{
.name = param.name ++ "",
.name = param.name,
.type = FieldType,
.default_value = @ptrCast(&@as(
FieldType,

View File

@ -210,7 +210,7 @@ pub fn MutatingZSplitter(comptime T: type) type {
pub fn copyStruct(comptime T: type, source: T, field_overrides: anytype) T {
var result: T = undefined;
comptime for (@typeInfo(@TypeOf(field_overrides)).Struct.fields) |field| {
comptime inline for (@typeInfo(@TypeOf(field_overrides)).Struct.fields) |field| {
if (!@hasField(T, field.name)) @compileError("override contains bad field" ++ field);
};
@ -254,8 +254,9 @@ pub const TupleBuilder = struct {
comptime {
var fields: [self.types.len]StructField = undefined;
for (self.types, 0..) |Type, idx| {
var num_buf: [128]u8 = undefined;
fields[idx] = .{
.name = std.fmt.comptimePrint("{d}", .{idx}),
.name = std.fmt.bufPrint(&num_buf, "{d}", .{idx}) catch @compileError("failed to write field"),
.type = Type,
.default_value = null,
// TODO: is this the right thing to do?

View File

@ -160,7 +160,7 @@ pub fn Parser(comptime command: anytype, comptime callback: anytype) type {
pub fn execute(self: *@This(), context: UserContext) anyerror!void {
const args = try std.process.argsAlloc(self.allocator);
const env = try std.process.getEnvMap(self.allocator);
var env = try std.process.getEnvMap(self.allocator);
if (args.len < 1) return ParseError.EmptyArgs;