| author | |
| committer | |
| log | 8e57f30531510eea3ba45e7e5f2fc789b7c40ba9 |
| tree | 829321cbb91179ed99c31fe4447e0c5ccdf06bc2 |
| parent | 34951666f74f8b91b68d6f6435b4b618fd8da60a |
7 files changed, 171 insertions(+), 55 deletions(-)
.gitignore-1| ... | ... | @@ -1,3 +1,2 @@ |
| 1 | 1 | /zig-cache |
| 2 | /deps.zig | |
| 3 | 2 | /.zigmod |
README.md+2| ... | ... | @@ -24,6 +24,8 @@ A package manager for the Zig programming language. |
| 24 | 24 | Initially, |
| 25 | 25 | ``` |
| 26 | 26 | $ git clone https://github.com/nektro/zigmod --recursive |
| 27 | $ zig build -Dbootstrap | |
| 28 | $ ./zig-cache/bin/zigmod fetch | |
| 27 | 29 | ``` |
| 28 | 30 | |
| 29 | 31 | To build, |
build.zig+29-24| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const Builder = std.build.Builder; |
| 3 | 3 | const builtin = std.builtin; |
| 4 | const deps = @import("./deps.zig"); | |
| 4 | 5 | |
| 5 | 6 | pub fn build(b: *Builder) void { |
| 6 | 7 | const target = b.standardTargetOptions(.{}); |
| ... | ... | @@ -16,30 +17,34 @@ pub fn build(b: *Builder) void { |
| 16 | 17 | exe.setTarget(target); |
| 17 | 18 | exe.setBuildMode(mode); |
| 18 | 19 | exe.addBuildOption([]const u8, "version", b.option([]const u8, "tag", "") orelse "dev"); |
| 19 | ||
| 20 | exe.linkLibC(); | |
| 21 | ||
| 22 | exe.addIncludeDir("./libs/yaml/include"); | |
| 23 | exe.addCSourceFile("./libs/yaml/src/api.c", &[_][]const u8{ | |
| 24 | // taken from https://github.com/yaml/libyaml/blob/0.2.5/CMakeLists.txt#L5-L8 | |
| 25 | "-DYAML_VERSION_MAJOR=0", | |
| 26 | "-DYAML_VERSION_MINOR=2", | |
| 27 | "-DYAML_VERSION_PATCH=5", | |
| 28 | "-DYAML_VERSION_STRING=\"0.2.5\"", | |
| 29 | "-DYAML_DECLARE_STATIC=1", | |
| 30 | }); | |
| 31 | exe.addCSourceFile("./libs/yaml/src/dumper.c", &[_][]const u8{}); | |
| 32 | exe.addCSourceFile("./libs/yaml/src/emitter.c", &[_][]const u8{}); | |
| 33 | exe.addCSourceFile("./libs/yaml/src/loader.c", &[_][]const u8{}); | |
| 34 | exe.addCSourceFile("./libs/yaml/src/parser.c", &[_][]const u8{}); | |
| 35 | exe.addCSourceFile("./libs/yaml/src/reader.c", &[_][]const u8{}); | |
| 36 | exe.addCSourceFile("./libs/yaml/src/scanner.c", &[_][]const u8{}); | |
| 37 | exe.addCSourceFile("./libs/yaml/src/writer.c", &[_][]const u8{}); | |
| 38 | ||
| 39 | exe.addPackagePath("known-folders", "./libs/zig-known-folders/known-folders.zig"); | |
| 40 | exe.addPackagePath("ansi", "./libs/zig-ansi/src/lib.zig"); | |
| 41 | exe.addPackagePath("zuri", "./libs/zuri/src/zuri.zig"); | |
| 42 | exe.addPackagePath("iguanatls", "./libs/iguanatls/src/main.zig"); | |
| 20 | const bootstrap = b.option(bool, "bootstrap", "bootstrapping with just the zig compiler"); | |
| 21 | exe.addBuildOption(bool, "bootstrap", bootstrap != null); | |
| 22 | ||
| 23 | if (bootstrap != null) { | |
| 24 | exe.linkLibC(); | |
| 25 | ||
| 26 | exe.addIncludeDir("./libs/yaml/include"); | |
| 27 | exe.addCSourceFile("./libs/yaml/src/api.c", &[_][]const u8{ | |
| 28 | // taken from https://github.com/yaml/libyaml/blob/0.2.5/CMakeLists.txt#L5-L8 | |
| 29 | "-DYAML_VERSION_MAJOR=0", | |
| 30 | "-DYAML_VERSION_MINOR=2", | |
| 31 | "-DYAML_VERSION_PATCH=5", | |
| 32 | "-DYAML_VERSION_STRING=\"0.2.5\"", | |
| 33 | "-DYAML_DECLARE_STATIC=1", | |
| 34 | }); | |
| 35 | exe.addCSourceFile("./libs/yaml/src/dumper.c", &[_][]const u8{}); | |
| 36 | exe.addCSourceFile("./libs/yaml/src/emitter.c", &[_][]const u8{}); | |
| 37 | exe.addCSourceFile("./libs/yaml/src/loader.c", &[_][]const u8{}); | |
| 38 | exe.addCSourceFile("./libs/yaml/src/parser.c", &[_][]const u8{}); | |
| 39 | exe.addCSourceFile("./libs/yaml/src/reader.c", &[_][]const u8{}); | |
| 40 | exe.addCSourceFile("./libs/yaml/src/scanner.c", &[_][]const u8{}); | |
| 41 | exe.addCSourceFile("./libs/yaml/src/writer.c", &[_][]const u8{}); | |
| 42 | ||
| 43 | exe.addPackagePath("ansi", "./libs/zig-ansi/src/lib.zig"); | |
| 44 | } | |
| 45 | else { | |
| 46 | deps.addAllTo(exe); | |
| 47 | } | |
| 43 | 48 | |
| 44 | 49 | exe.install(); |
| 45 | 50 |
deps.zig created+94| ... | ... | @@ -0,0 +1,94 @@ |
| 1 | const std = @import("std"); | |
| 2 | const build = std.build; | |
| 3 | ||
| 4 | pub const cache = ".zigmod/deps"; | |
| 5 | ||
| 6 | pub fn addAllTo(exe: *build.LibExeObjStep) void { | |
| 7 | @setEvalBranchQuota(1_000_000); | |
| 8 | for (packages) |pkg| { | |
| 9 | exe.addPackage(pkg); | |
| 10 | } | |
| 11 | if (c_include_dirs.len > 0 or c_source_files.len > 0) { | |
| 12 | exe.linkLibC(); | |
| 13 | } | |
| 14 | for (c_include_dirs) |dir| { | |
| 15 | exe.addIncludeDir(dir); | |
| 16 | } | |
| 17 | inline for (c_source_files) |fpath| { | |
| 18 | exe.addCSourceFile(fpath[1], @field(c_source_flags, fpath[0])); | |
| 19 | } | |
| 20 | for (system_libs) |lib| { | |
| 21 | exe.linkSystemLibrary(lib); | |
| 22 | } | |
| 23 | } | |
| 24 | ||
| 25 | fn get_flags(comptime index: usize) []const u8 { | |
| 26 | return @field(c_source_flags, _paths[index]); | |
| 27 | } | |
| 28 | ||
| 29 | pub const _ids = .{ | |
| 30 | "89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r", | |
| 31 | "8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc", | |
| 32 | "s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h", | |
| 33 | "2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf", | |
| 34 | "2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o", | |
| 35 | "csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe", | |
| 36 | }; | |
| 37 | ||
| 38 | pub const _paths = .{ | |
| 39 | "", | |
| 40 | "/v/git/github.com/yaml/libyaml/tag-0.2.5/", | |
| 41 | "/v/git/github.com/nektro/zig-ansi/commit-25039ca/", | |
| 42 | "/v/git/github.com/ziglibs/known-folders/commit-f0f4188/", | |
| 43 | "/v/git/github.com/Vexu/zuri/commit-0f9cec8/", | |
| 44 | "/v/git/github.com/alexnask/iguanaTLS/commit-58f72f6/", | |
| 45 | }; | |
| 46 | ||
| 47 | pub const package_data = struct { | |
| 48 | pub const _s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h = build.Pkg{ .name = "ansi", .path = cache ++ "/v/git/github.com/nektro/zig-ansi/commit-25039ca/src/lib.zig", .dependencies = &[_]build.Pkg{ } }; | |
| 49 | pub const _2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf = build.Pkg{ .name = "known-folders", .path = cache ++ "/v/git/github.com/ziglibs/known-folders/commit-f0f4188/known-folders.zig", .dependencies = &[_]build.Pkg{ } }; | |
| 50 | pub const _2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o = build.Pkg{ .name = "zuri", .path = cache ++ "/v/git/github.com/Vexu/zuri/commit-0f9cec8/src/zuri.zig", .dependencies = &[_]build.Pkg{ } }; | |
| 51 | pub const _csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe = build.Pkg{ .name = "iguanatls", .path = cache ++ "/v/git/github.com/alexnask/iguanaTLS/commit-58f72f6/src/main.zig", .dependencies = &[_]build.Pkg{ } }; | |
| 52 | }; | |
| 53 | ||
| 54 | pub const packages = &[_]build.Pkg{ | |
| 55 | package_data._s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h, | |
| 56 | package_data._2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf, | |
| 57 | package_data._2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o, | |
| 58 | package_data._csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe, | |
| 59 | }; | |
| 60 | ||
| 61 | pub const pkgs = struct { | |
| 62 | pub const ansi = packages[1]; | |
| 63 | pub const known_folders = packages[2]; | |
| 64 | pub const zuri = packages[3]; | |
| 65 | pub const iguanatls = packages[4]; | |
| 66 | }; | |
| 67 | ||
| 68 | pub const c_include_dirs = &[_][]const u8{ | |
| 69 | cache ++ _paths[1] ++ "include", | |
| 70 | }; | |
| 71 | ||
| 72 | pub const c_source_flags = struct { | |
| 73 | pub const @"89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r" = &[_][]const u8{}; | |
| 74 | pub const @"8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc" = &[_][]const u8{"-DYAML_VERSION_MAJOR=0","-DYAML_VERSION_MINOR=2","-DYAML_VERSION_PATCH=5","-DYAML_VERSION_STRING=\"0.2.5\"","-DYAML_DECLARE_STATIC=1",}; | |
| 75 | pub const @"s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h" = &[_][]const u8{}; | |
| 76 | pub const @"2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf" = &[_][]const u8{}; | |
| 77 | pub const @"2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o" = &[_][]const u8{}; | |
| 78 | pub const @"csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe" = &[_][]const u8{}; | |
| 79 | }; | |
| 80 | ||
| 81 | pub const c_source_files = &[_][2][]const u8{ | |
| 82 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/api.c"}, | |
| 83 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/dumper.c"}, | |
| 84 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/emitter.c"}, | |
| 85 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/loader.c"}, | |
| 86 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/parser.c"}, | |
| 87 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/reader.c"}, | |
| 88 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/scanner.c"}, | |
| 89 | [_][]const u8{_ids[1], cache ++ _paths[1] ++ "src/writer.c"}, | |
| 90 | }; | |
| 91 | ||
| 92 | pub const system_libs = &[_][]const u8{ | |
| 93 | }; | |
| 94 |
src/main.zig+9-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | const build_options = @import("build_options"); | |
| 3 | 4 | |
| 4 | 5 | pub const u = @import("./util/index.zig"); |
| 5 | 6 | pub const common = @import("./common.zig"); |
| ... | ... | @@ -7,6 +8,10 @@ pub const common = @import("./common.zig"); |
| 7 | 8 | // |
| 8 | 9 | // |
| 9 | 10 | |
| 11 | pub const commands_to_bootstrap = struct { | |
| 12 | const fetch = @import("./cmd_fetch.zig"); | |
| 13 | }; | |
| 14 | ||
| 10 | 15 | pub const commands = struct { |
| 11 | 16 | const init = @import("./cmd_init.zig"); |
| 12 | 17 | const fetch = @import("./cmd_fetch.zig"); |
| ... | ... | @@ -31,9 +36,11 @@ pub fn main() !void { |
| 31 | 36 | return; |
| 32 | 37 | } |
| 33 | 38 | |
| 34 | inline for (std.meta.declarations(commands)) |decl| { | |
| 39 | const available = if (build_options.bootstrap) commands_to_bootstrap else commands; | |
| 40 | ||
| 41 | inline for (std.meta.declarations(available)) |decl| { | |
| 35 | 42 | if (std.mem.eql(u8, args[0], decl.name)) { |
| 36 | const cmd = @field(commands, decl.name); | |
| 43 | const cmd = @field(available, decl.name); | |
| 37 | 44 | try cmd.execute(args[1..]); |
| 38 | 45 | return; |
| 39 | 46 | } |
zig.bootstrap.mod deleted-28| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | id: 89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r | |
| 2 | name: zigmod | |
| 3 | main: src/main.zig | |
| 4 | dependencies: | |
| 5 | - src: git https://github.com/yaml/libyaml | |
| 6 | version: tag-0.2.5 | |
| 7 | c_include_dirs: | |
| 8 | - include | |
| 9 | c_source_flags: | |
| 10 | - -DYAML_VERSION_MAJOR=0 | |
| 11 | - -DYAML_VERSION_MINOR=2 | |
| 12 | - -DYAML_VERSION_PATCH=5 | |
| 13 | - -DYAML_VERSION_STRING="0.2.5" | |
| 14 | - -DYAML_DECLARE_STATIC=1 | |
| 15 | c_source_files: | |
| 16 | - libs/yaml/src/dumper.c | |
| 17 | - libs/yaml/src/emitter.c | |
| 18 | - libs/yaml/src/loader.c | |
| 19 | - libs/yaml/src/parser.c | |
| 20 | - libs/yaml/src/reader.c | |
| 21 | - libs/yaml/src/scanner.c | |
| 22 | - libs/yaml/src/writer.c | |
| 23 | ||
| 24 | - src: git https://github.com/ziglibs/known-folders | |
| 25 | version: commit-e1193f9ef5b3aad7a6071e9f5721934fe04a020e | |
| 26 | ||
| 27 | - src: git https://github.com/nektro/zig-ansi | |
| 28 | version: commit-876c32c42044a5e1554f4662b4b9bdfad7ee5086 |
zig.mod+37| ... | ... | @@ -1,3 +1,40 @@ |
| 1 | 1 | id: 89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r |
| 2 | 2 | name: zigmod |
| 3 | 3 | main: src/main.zig |
| 4 | dependencies: | |
| 5 | - src: git https://github.com/yaml/libyaml | |
| 6 | version: tag-0.2.5 | |
| 7 | c_include_dirs: | |
| 8 | - include | |
| 9 | c_source_flags: | |
| 10 | - -DYAML_VERSION_MAJOR=0 | |
| 11 | - -DYAML_VERSION_MINOR=2 | |
| 12 | - -DYAML_VERSION_PATCH=5 | |
| 13 | - -DYAML_VERSION_STRING="0.2.5" | |
| 14 | - -DYAML_DECLARE_STATIC=1 | |
| 15 | c_source_files: | |
| 16 | - src/api.c | |
| 17 | - src/dumper.c | |
| 18 | - src/emitter.c | |
| 19 | - src/loader.c | |
| 20 | - src/parser.c | |
| 21 | - src/reader.c | |
| 22 | - src/scanner.c | |
| 23 | - src/writer.c | |
| 24 | ||
| 25 | - src: git https://github.com/nektro/zig-ansi | |
| 26 | version: commit-25039ca | |
| 27 | ||
| 28 | # | |
| 29 | ||
| 30 | - src: git https://github.com/ziglibs/known-folders | |
| 31 | version: commit-f0f4188 | |
| 32 | ||
| 33 | - src: git https://github.com/Vexu/zuri | |
| 34 | version: commit-0f9cec8 | |
| 35 | ||
| 36 | - src: git https://github.com/alexnask/iguanaTLS | |
| 37 | version: commit-58f72f6 | |
| 38 | ||
| 39 | # - src: git https://github.com/nektro/zig-licenses | |
| 40 | # version: commit-a15ef9b |