aboutsummaryrefslogtreecommitdiff
path: root/src/Package/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-10-09 11:47:37 -0700
committerGitHub <noreply@github.com>2023-10-09 11:47:37 -0700
commitf7bc55c0136b91805bd046a8cc8ea745d7e7567d (patch)
tree8379c645854d3c513ebb18e7fbabc7ab5ed1a283 /src/Package/Module.zig
parent75b48ef503204d3ba005647ecce8fda4657a8588 (diff)
parent95907cb79578779108f3772cb93648d38354b9ec (diff)
downloadzig-f7bc55c0136b91805bd046a8cc8ea745d7e7567d.tar.gz
zig-f7bc55c0136b91805bd046a8cc8ea745d7e7567d.zip
Merge pull request #17392 from ziglang/fetch
rework package manager
Diffstat (limited to 'src/Package/Module.zig')
-rw-r--r--src/Package/Module.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Package/Module.zig b/src/Package/Module.zig
new file mode 100644
index 0000000000..7e6b518892
--- /dev/null
+++ b/src/Package/Module.zig
@@ -0,0 +1,34 @@
+//! 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,
+/// Name used in compile errors. Looks like "root.foo.bar".
+fully_qualified_name: []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_mod`. `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;