| author | |
| committer | |
| log | 5b580b86a3657415e5332119611b8eef56c98812 |
| tree | 4034f1d37d4362c27bde26333f90deff5b053fee |
| parent | ef9721811ce58c5bc6af737642a67bc6b996218c |
6 files changed, 16 insertions(+), 18 deletions(-)
deps.zig+1-1| ... | ... | @@ -249,7 +249,7 @@ pub const package_data = struct { |
| 249 | 249 | pub var _89ujp8gq842x = Package{ |
| 250 | 250 | .name = "zigmod", |
| 251 | 251 | .entry = "/../..//src/lib.zig", |
| 252 | .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_ocmr9rtohgcc, &_tnj3qf44tpeq, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm }, | |
| 252 | .deps = &[_]*Package{ &_g982zq6e8wsv, &_s84v9o48ucb0, &_2ta738wrqbaq, &_0npcrzfdlrvk, &_ejw82j2ipa0e, &_ocmr9rtohgcc, &_tnj3qf44tpeq, &_2ovav391ivak, &_c1xirp1ota5p, &_u7sysdckdymi, &_iecwp4b3bsfm, &_f7dubzb7cyqe }, | |
| 253 | 253 | }; |
| 254 | 254 | pub var _root = Package{ |
| 255 | 255 | }; |
src/common.zig+5-4| ... | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | const ansi = @import("ansi"); |
| 5 | const extras = @import("extras"); | |
| 5 | 6 | |
| 6 | 7 | const zigmod = @import("./lib.zig"); |
| 7 | 8 | const u = @import("./util/index.zig"); |
| ... | ... | @@ -243,7 +244,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 243 | 244 | error.ManifestNotFound => { |
| 244 | 245 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0 or d.keep) { |
| 245 | 246 | var mod_from = try zigmod.Module.from(options.alloc, d.*, modpath, options); |
| 246 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(modpath, cachepath)[1..]; | |
| 247 | if (d.type != .local) mod_from.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 247 | 248 | if (mod_from.is_for_this()) return mod_from; |
| 248 | 249 | return null; |
| 249 | 250 | } |
| ... | ... | @@ -257,7 +258,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 257 | 258 | d.*.name = tryname; |
| 258 | 259 | d.*.main = trymain.?; |
| 259 | 260 | var mod_from = try zigmod.Module.from(options.alloc, d.*, cachepath, options); |
| 260 | if (d.type != .local) mod_from.clean_path = u.trim_prefix(modpath, cachepath)[1..]; | |
| 261 | if (d.type != .local) mod_from.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 261 | 262 | if (mod_from.is_for_this()) return mod_from; |
| 262 | 263 | return null; |
| 263 | 264 | } |
| ... | ... | @@ -268,7 +269,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 268 | 269 | dd.dep = d.*; |
| 269 | 270 | dd.for_build = d.for_build; |
| 270 | 271 | const save = dd; |
| 271 | if (d.type != .local) dd.clean_path = u.trim_prefix(modpath, cachepath)[1..]; | |
| 272 | if (d.type != .local) dd.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | |
| 272 | 273 | if (dd.id.len == 0) dd.id = try u.random_string(options.alloc, 48); |
| 273 | 274 | if (d.name.len > 0) dd.name = d.name; |
| 274 | 275 | if (d.main.len > 0) dd.main = d.main; |
| ... | ... | @@ -306,7 +307,7 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name: |
| 306 | 307 | |
| 307 | 308 | const cwdpath = try std.fs.cwd().realpathAlloc(alloc, "."); |
| 308 | 309 | const mpath = try mdir.realpathAlloc(alloc, "."); |
| 309 | var fpath = u.trim_prefix(mpath, cwdpath); | |
| 310 | var fpath = extras.trimPrefix(mpath, cwdpath); | |
| 310 | 311 | if (fpath.len == 0) fpath = std.fs.path.sep_str; |
| 311 | 312 | |
| 312 | 313 | var cachedir = try std.fs.cwd().openDir(cachepath, .{}); |
src/util/dep.zig+4-3| ... | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | const yaml = @import("yaml"); |
| 5 | const extras = @import("extras"); | |
| 5 | 6 | |
| 6 | 7 | const zigmod = @import("../lib.zig"); |
| 7 | 8 | const u = @import("index.zig"); |
| ... | ... | @@ -36,9 +37,9 @@ pub const Dep = struct { |
| 36 | 37 | return if (self.path.len == 0) "../.." else self.path; |
| 37 | 38 | } |
| 38 | 39 | var p = self.path; |
| 39 | p = u.trim_prefix(p, "http://"); | |
| 40 | p = u.trim_prefix(p, "https://"); | |
| 41 | p = u.trim_prefix(p, "git://"); | |
| 40 | p = extras.trimPrefix(p, "http://"); | |
| 41 | p = extras.trimPrefix(p, "https://"); | |
| 42 | p = extras.trimPrefix(p, "git://"); | |
| 42 | 43 | p = u.trim_suffix(p, ".git"); |
| 43 | 44 | p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p }); |
| 44 | 45 | return p; |
src/util/funcs.zig+2-8| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | const extras = @import("extras"); | |
| 3 | 4 | |
| 4 | 5 | const u = @import("index.zig"); |
| 5 | 6 | |
| ... | ... | @@ -44,13 +45,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string { |
| 44 | 45 | return list.toOwnedSlice(); |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | pub fn trim_prefix(in: string, prefix: string) string { | |
| 48 | if (std.mem.startsWith(u8, in, prefix)) { | |
| 49 | return in[prefix.len..]; | |
| 50 | } | |
| 51 | return in; | |
| 52 | } | |
| 53 | ||
| 54 | 48 | pub fn does_file_exist(dir: ?std.fs.Dir, fpath: string) !bool { |
| 55 | 49 | const file = (dir orelse std.fs.cwd()).openFile(fpath, .{}) catch |e| switch (e) { |
| 56 | 50 | error.FileNotFound => return false, |
| ... | ... | @@ -255,7 +249,7 @@ pub fn detect_pkgname(alloc: std.mem.Allocator, override: string, dir: string) ! |
| 255 | 249 | const dpath = try std.fs.realpathAlloc(alloc, try std.fs.path.join(alloc, &.{ dir, "build.zig" })); |
| 256 | 250 | const splitP = try split(alloc, dpath, std.fs.path.sep_str); |
| 257 | 251 | var name = splitP[splitP.len - 2]; |
| 258 | name = trim_prefix(name, "zig-"); | |
| 252 | name = extras.trimPrefix(name, "zig-"); | |
| 259 | 253 | assert(name.len > 0, "package name must not be an empty string", .{}); |
| 260 | 254 | return name; |
| 261 | 255 | } |
src/util/module.zig+3-2| ... | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | const yaml = @import("yaml"); |
| 5 | const extras = @import("extras"); | |
| 5 | 6 | |
| 6 | 7 | const zigmod = @import("../lib.zig"); |
| 7 | 8 | const u = @import("index.zig"); |
| ... | ... | @@ -67,8 +68,8 @@ pub const Module = struct { |
| 67 | 68 | var file_list_2 = std.ArrayList(string).init(alloc); |
| 68 | 69 | defer file_list_2.deinit(); |
| 69 | 70 | for (file_list_1) |item| { |
| 70 | const _a = u.trim_prefix(item, cdpath); | |
| 71 | const _b = u.trim_prefix(_a, self.clean_path); | |
| 71 | const _a = extras.trimPrefix(item, cdpath); | |
| 72 | const _b = extras.trimPrefix(_a, self.clean_path); | |
| 72 | 73 | if (_b[0] == '.') continue; |
| 73 | 74 | try file_list_2.append(_b); |
| 74 | 75 | } |
zig.mod+1| ... | ... | @@ -16,6 +16,7 @@ dependencies: |
| 16 | 16 | - src: git https://github.com/nektro/zig-inquirer |
| 17 | 17 | - src: git https://github.com/nektro/arqv-ini |
| 18 | 18 | - src: git https://github.com/nektro/zig-time |
| 19 | - src: git https://github.com/nektro/zig-extras | |
| 19 | 20 | |
| 20 | 21 | root_dependencies: |
| 21 | 22 | - src: git https://github.com/marlersoft/zigwin32 |