mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-25 19:08:39 +03:00
build: requireZig cleanup
This commit is contained in:
16
build.zig
16
build.zig
@ -3,21 +3,7 @@ const builtin = @import("builtin");
|
|||||||
const buildpkg = @import("src/build/main.zig");
|
const buildpkg = @import("src/build/main.zig");
|
||||||
|
|
||||||
comptime {
|
comptime {
|
||||||
// This is the required Zig version for building this project. We allow
|
buildpkg.requireZig("0.13.0");
|
||||||
// any patch version but the major and minor must match exactly.
|
|
||||||
const required_zig = "0.13.0";
|
|
||||||
|
|
||||||
// Fail compilation if the current Zig version doesn't meet requirements.
|
|
||||||
const current_vsn = builtin.zig_version;
|
|
||||||
const required_vsn = std.SemanticVersion.parse(required_zig) catch unreachable;
|
|
||||||
if (current_vsn.major != required_vsn.major or
|
|
||||||
current_vsn.minor != required_vsn.minor)
|
|
||||||
{
|
|
||||||
@compileError(std.fmt.comptimePrint(
|
|
||||||
"Your Zig version v{} does not meet the required build version of v{}",
|
|
||||||
.{ current_vsn, required_vsn },
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(b: *std.Build) !void {
|
pub fn build(b: *std.Build) !void {
|
||||||
|
@ -28,3 +28,6 @@ pub const XCFrameworkStep = @import("XCFrameworkStep.zig");
|
|||||||
pub const fish_completions = @import("fish_completions.zig").completions;
|
pub const fish_completions = @import("fish_completions.zig").completions;
|
||||||
pub const zsh_completions = @import("zsh_completions.zig").completions;
|
pub const zsh_completions = @import("zsh_completions.zig").completions;
|
||||||
pub const bash_completions = @import("bash_completions.zig").completions;
|
pub const bash_completions = @import("bash_completions.zig").completions;
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
pub const requireZig = @import("zig.zig").requireZig;
|
||||||
|
17
src/build/zig.zig
Normal file
17
src/build/zig.zig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
|
/// Require a specific version of Zig to build this project.
|
||||||
|
pub fn requireZig(comptime required_zig: []const u8) void {
|
||||||
|
// Fail compilation if the current Zig version doesn't meet requirements.
|
||||||
|
const current_vsn = builtin.zig_version;
|
||||||
|
const required_vsn = std.SemanticVersion.parse(required_zig) catch unreachable;
|
||||||
|
if (current_vsn.major != required_vsn.major or
|
||||||
|
current_vsn.minor != required_vsn.minor)
|
||||||
|
{
|
||||||
|
@compileError(std.fmt.comptimePrint(
|
||||||
|
"Your Zig version v{} does not meet the required build version of v{}",
|
||||||
|
.{ current_vsn, required_vsn },
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user