use an enum for zig version
This commit is contained in:
parent
94acedfde3
commit
8d46ceff07
@ -1,5 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = std.builtin;
|
const builtin = std.builtin;
|
||||||
|
const shared = @import("./src/shared.zig");
|
||||||
|
|
||||||
pub fn build(b: *std.build.Builder) !void {
|
pub fn build(b: *std.build.Builder) !void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
@ -10,9 +11,9 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
exe.addOptions("build_options", exe_options);
|
exe.addOptions("build_options", exe_options);
|
||||||
|
|
||||||
exe_options.addOption(
|
exe_options.addOption(
|
||||||
[]const u8,
|
shared.ZigVersion,
|
||||||
"data_version",
|
"data_version",
|
||||||
b.option([]const u8, "data_version", "The Zig version your compiler is.") orelse "master",
|
b.option(shared.ZigVersion, "data_version", "The Zig version your compiler is.") orelse .master,
|
||||||
);
|
);
|
||||||
|
|
||||||
exe.addPackage(.{ .name = "known-folders", .path = .{ .path = "src/known-folders/known-folders.zig" } });
|
exe.addPackage(.{ .name = "known-folders", .path = .{ .path = "src/known-folders/known-folders.zig" } });
|
||||||
|
15
src/main.zig
15
src/main.zig
@ -13,15 +13,16 @@ const rename = @import("./rename.zig");
|
|||||||
const offsets = @import("./offsets.zig");
|
const offsets = @import("./offsets.zig");
|
||||||
const setup = @import("./setup.zig");
|
const setup = @import("./setup.zig");
|
||||||
const semantic_tokens = @import("./semantic_tokens.zig");
|
const semantic_tokens = @import("./semantic_tokens.zig");
|
||||||
|
const shared = @import("./shared.zig");
|
||||||
const Ast = std.zig.Ast;
|
const Ast = std.zig.Ast;
|
||||||
const known_folders = @import("known-folders");
|
const known_folders = @import("known-folders");
|
||||||
const data = blk: {
|
|
||||||
if (std.mem.eql(u8, build_options.data_version, "0.7.0")) break :blk @import("data/0.7.0.zig");
|
const data = switch (build_options.data_version) {
|
||||||
if (std.mem.eql(u8, build_options.data_version, "0.7.1")) break :blk @import("data/0.7.1.zig");
|
.master => @import("data/master.zig"),
|
||||||
if (std.mem.eql(u8, build_options.data_version, "0.8.0")) break :blk @import("data/0.8.0.zig");
|
.@"0.7.0" => @import("data/0.7.0.zig"),
|
||||||
if (std.mem.eql(u8, build_options.data_version, "0.8.1")) break :blk @import("data/0.8.1.zig");
|
.@"0.7.1" => @import("data/0.7.1.zig"),
|
||||||
if (std.mem.eql(u8, build_options.data_version, "master")) break :blk @import("data/master.zig");
|
.@"0.8.0" => @import("data/0.8.0.zig"),
|
||||||
@compileError("invalid data_version provided");
|
.@"0.8.1" => @import("data/0.8.1.zig"),
|
||||||
};
|
};
|
||||||
|
|
||||||
const logger = std.log.scoped(.main);
|
const logger = std.log.scoped(.main);
|
||||||
|
9
src/shared.zig
Normal file
9
src/shared.zig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
//! Specifically shared between both build.zig and main app code.
|
||||||
|
|
||||||
|
pub const ZigVersion = enum {
|
||||||
|
master,
|
||||||
|
@"0.7.0",
|
||||||
|
@"0.7.1",
|
||||||
|
@"0.8.0",
|
||||||
|
@"0.8.1",
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user