DoxigAlpha

init

Function parameters

Parameters

#
m:*Module
owner:*std.Build
value:union(enum) { options: CreateOptions, existing: *const Module }

Type definitions in this namespace

Types

#
CreateOptions
Unspecified options here will be inherited from parent `Module` when
Graph
Elements of `modules` and `names` are matched one-to-one.

Functions in this namespace

Functions

#
addImport
Adds an existing module to be used with `@import`.
addAnonymousImport
Creates a new module and adds it to be used with `@import`.
addOptions
Converts a set of key-value pairs into a Zig source file, and then inserts it into
addCSourceFiles
Handy when you have many non-Zig source files and want them all to have the same flags.
addWin32ResourceFile
Resource files must have the extension `.rc`.
addCMacro
Equvialent to the following C code, applied to all C source files owned by
getGraph
Intended to be used during the make phase only.

Source

Implementation

#
pub fn init(
    m: *Module,
    owner: *std.Build,
    value: union(enum) { options: CreateOptions, existing: *const Module },
) void {
    const allocator = owner.allocator;

    switch (value) {
        .options => |options| {
            m.* = .{
                .owner = owner,
                .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
                .import_table = .{},
                .resolved_target = options.target,
                .optimize = options.optimize,
                .link_libc = options.link_libc,
                .link_libcpp = options.link_libcpp,
                .dwarf_format = options.dwarf_format,
                .c_macros = .{},
                .include_dirs = .{},
                .lib_paths = .{},
                .rpaths = .{},
                .frameworks = .{},
                .link_objects = .{},
                .strip = options.strip,
                .unwind_tables = options.unwind_tables,
                .single_threaded = options.single_threaded,
                .stack_protector = options.stack_protector,
                .stack_check = options.stack_check,
                .sanitize_c = options.sanitize_c,
                .sanitize_thread = options.sanitize_thread,
                .fuzz = options.fuzz,
                .code_model = options.code_model,
                .valgrind = options.valgrind,
                .pic = options.pic,
                .red_zone = options.red_zone,
                .omit_frame_pointer = options.omit_frame_pointer,
                .error_tracing = options.error_tracing,
                .export_symbol_names = &.{},
                .no_builtin = options.no_builtin,
            };

            m.import_table.ensureUnusedCapacity(allocator, options.imports.len) catch @panic("OOM");
            for (options.imports) |dep| {
                m.import_table.putAssumeCapacity(dep.name, dep.module);
            }
        },
        .existing => |existing| {
            m.* = existing.*;
        },
    }
}