all: use snake_case for package names and build CLI flags #1157

Open
opened 2024-02-10 00:07:20 +00:00 by emidoots · 0 comments
emidoots commented 2024-02-10 00:07:20 +00:00 (Migrated from github.com)

Point 1: use snake_case for all package names in build.zig.zon

If build.zig.zon contains .name = "mach-dxcompiler" then zig fetch --save will produce an entry like this using @"" syntax:

.dependencies = .{
    .@"mach-dxcompiler" = .{ ... }
},

Rather than the nicer form:

.dependencies = .{
    .mach_dxcompiler = .{ ... }
},

We can control this using the name parameter to zig fetch --save, of course, but it'd be nice to be able to rely on the defaults and get good names by default.

Point 2: use snake_case for build.zig CLI flags always

In build.zig, CLI option flags are often defined as e.g.:

const debug_symbols = b.option(bool, "debug-symbols", "Whether to produce detailed debug symbols (g0) or not.") orelse false;

And would be used via zig build -Ddebug-symbols=true. However, they are also specified when using the package in Zig code:

    const mach_dxcompiler = b.dependency("mach_dxcompiler", .{
        .@"debug-symbols" = false,
    });

Again, it would be nice to avoid @"" syntax - so we will use debug_symbols instead (.debug_symbols = false, and -Ddebug_symbols=true as the CLI flag.)

### Point 1: use snake_case for all package names in build.zig.zon If `build.zig.zon` contains `.name = "mach-dxcompiler"` then `zig fetch --save` will produce an entry like this using `@""` syntax: ``` .dependencies = .{ .@"mach-dxcompiler" = .{ ... } }, ``` Rather than the nicer form: ``` .dependencies = .{ .mach_dxcompiler = .{ ... } }, ``` We can control this using the name parameter to `zig fetch --save`, of course, but it'd be nice to be able to rely on the defaults and get good names by default. ### Point 2: use snake_case for build.zig CLI flags always In build.zig, CLI option flags are often defined as e.g.: ``` const debug_symbols = b.option(bool, "debug-symbols", "Whether to produce detailed debug symbols (g0) or not.") orelse false; ``` And would be used via `zig build -Ddebug-symbols=true`. However, they are also specified when using the package in Zig code: ``` const mach_dxcompiler = b.dependency("mach_dxcompiler", .{ .@"debug-symbols" = false, }); ``` Again, it would be nice to avoid `@""` syntax - so we will use `debug_symbols` instead (`.debug_symbols = false,` and `-Ddebug_symbols=true` as the CLI flag.)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1157
No description provided.