1+ const std = @import ("std" );
2+ const gpa = std .heap .c_allocator ;
3+
14const u = @import ("./index.zig" );
25
36//
@@ -7,6 +10,7 @@ pub const DepType = enum {
710 system_lib , // std.build.LibExeObjStep.linkSystemLibrary
811 git , // https://git-scm.com/
912 hg , // https://www.mercurial-scm.org/
13+ http , // https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
1014
1115 pub fn pull (self : DepType , rpath : []const u8 , dpath : []const u8 ) ! void {
1216 switch (self ) {
@@ -18,6 +22,24 @@ pub const DepType = enum {
1822 .hg = > {
1923 _ = try u .run_cmd (null , &[_ ][]const u8 {"hg" , "clone" , rpath , dpath });
2024 },
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+ },
2143 }
2244 }
2345
@@ -31,6 +53,9 @@ pub const DepType = enum {
3153 .hg = > {
3254 _ = try u .run_cmd (dpath , &[_ ][]const u8 {"hg" , "pull" });
3355 },
56+ .http = > {
57+ //
58+ },
3459 }
3560 }
3661};
0 commit comments