From 301c7eab635d4eca9ca1f8423b00c793e6de992d Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 17 Sep 2022 13:30:52 -0700 Subject: [PATCH] bootstrap step is no longer necessary --- build.zig | 38 +++----------------------------------- src/cmd/fetch.zig | 6 ------ src/common.zig | 6 +----- src/main.zig | 10 ++++------ 4 files changed, 8 insertions(+), 52 deletions(-) diff --git a/build.zig b/build.zig index 07d4307c3e1426e3a0a29def0b3bfb99106e1ffb..ff3ecb48ff1bfc09c020a4f7b5039fb206858278 100644 --- a/build.zig +++ b/build.zig @@ -11,11 +11,10 @@ pub fn build(b: *std.build.Builder) void { b.setPreferredReleaseMode(.ReleaseSafe); const mode = b.standardReleaseOptions(); - const bootstrap = b.option(bool, "bootstrap", "bootstrapping with just the zig compiler"); const use_full_name = b.option(bool, "use-full-name", "") orelse false; const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) }); const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); - const exe = makeExe(b, exe_name, target, mode, bootstrap); + const exe = makeExe(b, exe_name, target, mode); const run_cmd = exe.run(); run_cmd.step.dependOn(b.getInstallStep()); @@ -27,7 +26,7 @@ pub fn build(b: *std.build.Builder) void { run_step.dependOn(&run_cmd.step); } -fn makeExe(b: *std.build.Builder, exe_name: string, target: std.zig.CrossTarget, mode: std.builtin.Mode, bootstrap: ?bool) *std.build.LibExeObjStep { +fn makeExe(b: *std.build.Builder, exe_name: string, target: std.zig.CrossTarget, mode: std.builtin.Mode) *std.build.LibExeObjStep { const exe = b.addExecutable(exe_name, "src/main.zig"); exe.setTarget(target); exe.setBuildMode(mode); @@ -35,39 +34,8 @@ fn makeExe(b: *std.build.Builder, exe_name: string, target: std.zig.CrossTarget, const exe_options = b.addOptions(); exe.addOptions("build_options", exe_options); exe_options.addOption(string, "version", b.option(string, "tag", "") orelse "dev"); - exe_options.addOption(bool, "bootstrap", bootstrap != null); - - if (bootstrap != null) { - exe.linkLibC(); - - exe.addIncludeDir("./libs/yaml/include"); - exe.addCSourceFile("./libs/yaml/src/api.c", &.{ - // taken from https://github.com/yaml/libyaml/blob/0.2.5/CMakeLists.txt#L5-L8 - "-DYAML_VERSION_MAJOR=0", - "-DYAML_VERSION_MINOR=2", - "-DYAML_VERSION_PATCH=5", - "-DYAML_VERSION_STRING=\"0.2.5\"", - "-DYAML_DECLARE_STATIC=1", - }); - exe.addCSourceFile("./libs/yaml/src/dumper.c", &.{}); - exe.addCSourceFile("./libs/yaml/src/emitter.c", &.{}); - exe.addCSourceFile("./libs/yaml/src/loader.c", &.{}); - exe.addCSourceFile("./libs/yaml/src/parser.c", &.{}); - exe.addCSourceFile("./libs/yaml/src/reader.c", &.{}); - exe.addCSourceFile("./libs/yaml/src/scanner.c", &.{}); - exe.addCSourceFile("./libs/yaml/src/writer.c", &.{}); - - exe.addPackage(.{ - .name = "zigmod", - .source = .{ .path = "./src/lib.zig" }, - .dependencies = &[_]std.build.Pkg{ - .{ .name = "zfetch", .source = .{ .path = "src/zfetch_stub.zig" } }, - }, - }); - } else { - deps.addAllTo(exe); - } + deps.addAllTo(exe); exe.install(); return exe; } diff --git a/src/cmd/fetch.zig b/src/cmd/fetch.zig index bfbad49a7592024acfaf643b95593ada7ab3904d..c80a9b9277aca5d917501bb8ff5dacab83bf0c5d 100644 --- a/src/cmd/fetch.zig +++ b/src/cmd/fetch.zig @@ -1,15 +1,11 @@ const std = @import("std"); const string = []const u8; const ansi = @import("ansi"); -const root = @import("root"); const zigmod = @import("../lib.zig"); const u = @import("./../util/index.zig"); const common = @import("./../common.zig"); -const build_options = if (@hasDecl(root, "build_options")) root.build_options else struct {}; -const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootstrap else false; - // // @@ -32,8 +28,6 @@ pub fn execute(args: [][]u8) !void { try create_depszig(gpa, cachepath, dir, top_module, &list); - if (bootstrap) return; - try create_lockfile(gpa, &list, cachepath, dir); try diff_lockfile(gpa); diff --git a/src/common.zig b/src/common.zig index e17e3abd48453fa65dff05e460babac957333e75..e88b88cf8af776642fab53a1d864be441a0cfac9 100644 --- a/src/common.zig +++ b/src/common.zig @@ -2,14 +2,10 @@ const std = @import("std"); const string = []const u8; const builtin = @import("builtin"); const ansi = @import("ansi"); -const root = @import("root"); const zigmod = @import("./lib.zig"); const u = @import("./util/index.zig"); -const build_options = if (@hasDecl(root, "build_options")) root.build_options else struct {}; -const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootstrap else false; - // // @@ -114,7 +110,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! std.debug.print("fetch: {s}: {s}\n", .{ @tagName(d.type), d.path }); } defer { - if (!bootstrap and options.log and d.type != .local) { + if (options.log and d.type != .local) { std.debug.print("{s}", .{ansi.csi.CursorUp(1)}); std.debug.print("{s}", .{ansi.csi.EraseInLine(0)}); } diff --git a/src/main.zig b/src/main.zig index ed177ac16ab26ef0db03d216d42fd23b61069603..7d5e0006420327299354c9ba217c424d9a16f512 100644 --- a/src/main.zig +++ b/src/main.zig @@ -17,8 +17,6 @@ pub fn main() !void { const proc_args = try std.process.argsAlloc(gpa); const args = proc_args[1..]; - const available = if (build_options.bootstrap) zigmod.commands_to_bootstrap else zigmod.commands; - if (args.len == 0) { std.debug.print("zigmod {s} {s} {s} {s}\n", .{ build_options.version, @@ -28,13 +26,13 @@ pub fn main() !void { }); std.debug.print("\n", .{}); std.debug.print("The commands available are:\n", .{}); - inline for (comptime std.meta.declarations(available)) |decl| { + inline for (comptime std.meta.declarations(zigmod.commands)) |decl| { std.debug.print(" - {s}\n", .{decl.name}); } return; } - if (!build_options.bootstrap and builtin.os.tag == .windows) { + if (builtin.os.tag == .windows) { const console = win32.system.console; const h_out = console.GetStdHandle(console.STD_OUTPUT_HANDLE); _ = console.SetConsoleMode(h_out, console.CONSOLE_MODE.initFlags(.{ @@ -47,9 +45,9 @@ pub fn main() !void { try zigmod.init(); defer zigmod.deinit(); - inline for (comptime std.meta.declarations(available)) |decl| { + inline for (comptime std.meta.declarations(zigmod.commands)) |decl| { if (std.mem.eql(u8, args[0], decl.name)) { - const cmd = @field(available, decl.name); + const cmd = @field(zigmod.commands, decl.name); try cmd.execute(args[1..]); return; } -- 2.54.0