mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
* start renaming "package" to "module" (see #14307) - build system gains `main_mod_path` and `main_pkg_path` is still there but it is deprecated. * eliminate the object-oriented memory management style of what was previously `*Package`. Now it is `*Package.Module` and all pointers point to externally managed memory. * fixes to get the new Fetch.zig code working. The previous commit was work-in-progress. There are still two commented out code paths, the one that leads to `Compilation.create` and the one for `zig build` that fetches the entire dependency tree and creates the required modules for the build runner.
33 lines
1.2 KiB
Zig
33 lines
1.2 KiB
Zig
//! Corresponds to something that Zig source code can `@import`.
|
|
//! Not to be confused with src/Module.zig which should be renamed
|
|
//! to something else. https://github.com/ziglang/zig/issues/14307
|
|
|
|
/// Only files inside this directory can be imported.
|
|
root: Package.Path,
|
|
/// Relative to `root`. May contain path separators.
|
|
root_src_path: []const u8,
|
|
/// The dependency table of this module. Shared dependencies such as 'std',
|
|
/// 'builtin', and 'root' are not specified in every dependency table, but
|
|
/// instead only in the table of `main_pkg`. `Module.importFile` is
|
|
/// responsible for detecting these names and using the correct package.
|
|
deps: Deps = .{},
|
|
|
|
pub const Deps = std.StringHashMapUnmanaged(*Module);
|
|
|
|
pub const Tree = struct {
|
|
/// Each `Package` exposes a `Module` with build.zig as its root source file.
|
|
build_module_table: std.AutoArrayHashMapUnmanaged(MultiHashHexDigest, *Module),
|
|
};
|
|
|
|
pub fn create(allocator: Allocator, m: Module) Allocator.Error!*Module {
|
|
const new = try allocator.create(Module);
|
|
new.* = m;
|
|
return new;
|
|
}
|
|
|
|
const Module = @This();
|
|
const Package = @import("../Package.zig");
|
|
const std = @import("std");
|
|
const Allocator = std.mem.Allocator;
|
|
const MultiHashHexDigest = Package.Manifest.MultiHashHexDigest;
|