| ... | @@ -1,3 +1,6 @@ | ... | @@ -1,3 +1,6 @@ |
| | 1 | const std = @import("std"); |
| | 2 | const gpa = std.heap.c_allocator; |
| | 3 | |
| 1 | const u = @import("./index.zig"); | 4 | const u = @import("./index.zig"); |
| 2 | | 5 | |
| 3 | // | 6 | // |
| ... | @@ -7,6 +10,7 @@ pub const DepType = enum { | ... | @@ -7,6 +10,7 @@ pub const DepType = enum { |
| 7 | system_lib, // std.build.LibExeObjStep.linkSystemLibrary | 10 | system_lib, // std.build.LibExeObjStep.linkSystemLibrary |
| 8 | git, // https://git-scm.com/ | 11 | git, // https://git-scm.com/ |
| 9 | hg, // https://www.mercurial-scm.org/ | 12 | hg, // https://www.mercurial-scm.org/ |
| | 13 | http, // https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol |
| 10 | | 14 | |
| 11 | pub fn pull(self: DepType, rpath: []const u8, dpath: []const u8) !void { | 15 | pub fn pull(self: DepType, rpath: []const u8, dpath: []const u8) !void { |
| 12 | switch (self) { | 16 | switch (self) { |
| ... | @@ -18,6 +22,24 @@ pub const DepType = enum { | ... | @@ -18,6 +22,24 @@ pub const DepType = enum { |
| 18 | .hg => { | 22 | .hg => { |
| 19 | _ = try u.run_cmd(null, &[_][]const u8{"hg", "clone", rpath, dpath}); | 23 | _ = try u.run_cmd(null, &[_][]const u8{"hg", "clone", rpath, dpath}); |
| 20 | }, | 24 | }, |
| | 25 | .http => { |
| | 26 | try u.mkdir_all(dpath); |
| | 27 | _ = try u.run_cmd(dpath, &[_][]const u8{"wget", rpath}); |
| | 28 | const f = rpath[std.mem.lastIndexOf(u8, rpath, "/").?+1..]; |
| | 29 | if (std.mem.endsWith(u8, f, ".zip")) { |
| | 30 | _ = try u.run_cmd(dpath, &[_][]const u8{"unzip", f, "-d", "."}); |
| | 31 | try std.fs.deleteFileAbsolute(try std.fs.path.join(gpa, &[_][]const u8{dpath, f})); |
| | 32 | } |
| | 33 | if ( |
| | 34 | std.mem.endsWith(u8, f, ".tar") |
| | 35 | or std.mem.endsWith(u8, f, ".tar.gz") |
| | 36 | or std.mem.endsWith(u8, f, ".tar.xz") |
| | 37 | or std.mem.endsWith(u8, f, ".tar.zst") |
| | 38 | ) { |
| | 39 | _ = try u.run_cmd(dpath, &[_][]const u8{"tar", "-xf", f, "-C", "."}); |
| | 40 | try std.fs.deleteFileAbsolute(try std.fs.path.join(gpa, &[_][]const u8{dpath, f})); |
| | 41 | } |
| | 42 | }, |
| 21 | } | 43 | } |
| 22 | } | 44 | } |
| 23 | | 45 | |
| ... | @@ -31,6 +53,9 @@ pub const DepType = enum { | ... | @@ -31,6 +53,9 @@ pub const DepType = enum { |
| 31 | .hg => { | 53 | .hg => { |
| 32 | _ = try u.run_cmd(dpath, &[_][]const u8{"hg", "pull"}); | 54 | _ = try u.run_cmd(dpath, &[_][]const u8{"hg", "pull"}); |
| 33 | }, | 55 | }, |
| | 56 | .http => { |
| | 57 | // |
| | 58 | }, |
| 34 | } | 59 | } |
| 35 | } | 60 | } |
| 36 | }; | 61 | }; |