feature. See also
. The project being documented here (as the example) is the Zig library itself.
Compile.CliNamedModules
const CliNamedModules = struct
File
Code
const CliNamedModules = struct {
modules: std.array_hash_map.Auto(Configuration.Module.Index, void),
names: std.array_hash_map.String(void),
fn init(
arena: Allocator,
module_graph: *ModuleGraph,
compile_index: Configuration.Step.Index,
maker: *const Maker,
) Allocator.Error!CliNamedModules {
const conf = &maker.scanned_config.configuration;
const conf_compile = compile_index.ptr(conf).extended.get(conf.extra).compile;
var result: CliNamedModules = .{
.modules = .{},
.names = .{},
};
const modules = try getModuleList(arena, module_graph, conf_compile.root_module, conf);
{
assert(conf_compile.root_module == modules.keys()[0]);
try result.modules.put(arena, conf_compile.root_module, {});
try result.names.put(arena, "root", {});
}
for (modules.keys()[1..], modules.values()[1..]) |mod, orig_name| {
const orig_name_slice = orig_name.slice(conf);
var name: []const u8 = orig_name_slice;
var n: usize = 0;
while (true) {
const gop = try result.names.getOrPut(arena, name);
if (!gop.found_existing) {
try result.modules.putNoClobber(arena, mod, {});
break;
}
name = try arena.print("{s}{d}", .{ orig_name_slice, n });
n += 1;
}
}
return result;
}
}