@@ -21,38 +21,21 @@ const builtin = @import("builtin");
2121
2222const Build = std .Build ;
2323
24- /// Do not rename this constant. It is scanned by some scripts to determine
25- /// which zig version to install.
26- const recommended_zig_version = "0.15.2" ;
27-
2824pub fn build (b : * Build ) ! void {
29- switch (comptime builtin .zig_version .order (std .SemanticVersion .parse (recommended_zig_version ) catch unreachable )) {
30- .eq = > {},
31- .lt = > {
32- @compileError ("The minimum version of Zig required to compile is '" ++ recommended_zig_version ++ "', found '" ++ builtin .zig_version_string ++ "'." );
33- },
34- .gt = > {
35- std .debug .print (
36- "WARNING: Recommended Zig version '{s}', but found '{s}', build may fail...\n\n " ,
37- .{ recommended_zig_version , builtin .zig_version_string },
38- );
39- },
40- }
25+ const target = b .standardTargetOptions (.{});
26+ const optimize = b .standardOptimizeOption (.{});
4127
42- var opts = b .addOptions ();
43- opts .addOption (
44- []const u8 ,
45- "git_commit" ,
46- b .option ([]const u8 , "git_commit" , "Current git commit" ) orelse "dev" ,
47- );
28+ const manifest = Manifest .init (b );
4829
30+ const git_commit = b .option ([]const u8 , "git_commit" , "Current git commit" );
4931 const prebuilt_v8_path = b .option ([]const u8 , "prebuilt_v8_path" , "Path to prebuilt libc_v8.a" );
5032
51- const target = b .standardTargetOptions (.{});
52- const optimize = b .standardOptimizeOption (.{});
33+ var opts = b .addOptions ();
34+ opts .addOption ([]const u8 , "version" , manifest .version );
35+ opts .addOption ([]const u8 , "git_commit" , git_commit orelse "dev" );
5336
54- // We're still using llvm because the new x86 backend seems to crash
55- // with v8. This can be reproduced in zig-v8-fork.
37+ // We're still using llvm because the new x86 backend seems to crash with v8.
38+ // This can be reproduced in zig-v8-fork.
5639
5740 const lightpanda_module = b .addModule ("lightpanda" , .{
5841 .root_source_file = b .path ("src/main.zig" ),
@@ -851,3 +834,28 @@ pub fn buildAda(b: *Build, m: *Build.Module) !void {
851834 // Expose ada module to main module.
852835 m .addImport ("ada" , ada_mod );
853836}
837+
838+ const Manifest = struct {
839+ version : []const u8 ,
840+ minimum_zig_version : []const u8 ,
841+
842+ fn init (b : * std.Build ) Manifest {
843+ const input = @embedFile ("build.zig.zon" );
844+
845+ var diagnostics : std.zon.parse.Diagnostics = .{};
846+ defer diagnostics .deinit (b .allocator );
847+
848+ return std .zon .parse .fromSlice (Manifest , b .allocator , input , & diagnostics , .{
849+ .free_on_error = true ,
850+ .ignore_unknown_fields = true ,
851+ }) catch | err | {
852+ switch (err ) {
853+ error .OutOfMemory = > @panic ("OOM" ),
854+ error .ParseZon = > {
855+ std .debug .print ("Parse diagnostics:\n {f}\n " , .{diagnostics });
856+ std .process .exit (1 );
857+ },
858+ }
859+ };
860+ }
861+ };
0 commit comments