diff --git a/docs/zig.mod.md b/docs/zig.mod.md index a61d71773f48fb0f060461afc67f308d2749bbb1..60e3010691f98930c2b6aad7afe98971365b2b0f 100644 --- a/docs/zig.mod.md +++ b/docs/zig.mod.md @@ -99,5 +99,10 @@ This attribute specifies a way to filter when the dependency will be generated i - Example: `linux` This attribute specifies a way to filter when the dependency will be generated into the contents of `deps.zig`. `except_os` is an exlusive filter in which the dependency will only be in the output if the host target operating is \*not\* in the list specified or if the field is ommitted. +#### Dep `keep` +- Type: `string` +- Example: `true`|any +This attribute is a manual override for having an external repo that contains no Zig or C code but other files be managed through Zigmod and `deps.zig`. `true` is the only value which will enable this flag. + #### Dep Overrides There are a number of fields you can add to a `Dep` object that will override it's top-level value. This is most useful in the case where a project you want to use does not have a `zig.mod` manifest. You can then use overrides to define the values for them. The only top-level value you can not override is `dependencies`. diff --git a/src/common.zig b/src/common.zig index 93e294a4a8c1e13f8ba6c9c41c96fe3e26bceb2b..4cba6e3d1ebb2f069095cae2eb6bad754c9b1131 100644 --- a/src/common.zig +++ b/src/common.zig @@ -236,7 +236,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO else => { var dd = try collect_deps(cachepath, moddir, options) catch |e| switch (e) { error.FileNotFound => { - if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { + if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0 or d.keep) { var mod_from = try zigmod.Module.from(options.alloc, d.*, cachepath, options); if (d.type != .local) mod_from.clean_path = u.trim_prefix(modpath, cachepath)[1..]; if (mod_from.is_for_this()) return mod_from; @@ -329,6 +329,7 @@ pub fn add_files_package(alloc: *std.mem.Allocator, pkg_name: string, mdir: std. .version = "absolute", .yaml = null, .deps = &.{}, + .keep = false, }; var options = CollectOptions{ .log = false, @@ -372,6 +373,7 @@ pub fn parse_lockfile(alloc: *std.mem.Allocator, dir: std.fs.Dir) ![]const [4]st .main = "", .yaml = null, .deps = &.{}, + .keep = false, }; try list.append([4]string{ try asdep.clean_path(), diff --git a/src/util/dep.zig b/src/util/dep.zig index 53e87c99227e3eb8fdaa9cbf17a8d688b67bfc14..eaddf0801b5d3c16aaa1421cf28311a1bd386af4 100644 --- a/src/util/dep.zig +++ b/src/util/dep.zig @@ -26,6 +26,7 @@ pub const Dep = struct { except_os: []const string = &.{}, yaml: ?yaml.Mapping, deps: []zigmod.Dep, + keep: bool, pub fn clean_path(self: Dep) !string { if (self.type == .local) { diff --git a/src/util/modfile.zig b/src/util/modfile.zig index 102759e9d8e5ba91f8f43283973fb5090415fadf..440e8f56b873224d9b4e462f13b360bb6f6efbbc 100644 --- a/src/util/modfile.zig +++ b/src/util/modfile.zig @@ -125,6 +125,7 @@ pub const ModFile = struct { .except_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("except_os"), ","), ""), .yaml = item.mapping, .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}), + .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep")), }); } }