11// SPDX: Apache-2.0
22// This file is part of zigpak.
33const std = @import ("std" );
4+ const budopts = @import ("./src/budopts.zig" );
45
56// Although this function looks imperative, note that its job is to
67// declaratively construct a build graph that will be executed by an external
@@ -25,15 +26,30 @@ pub fn build(b: *std.Build) void {
2526
2627 const kcov = b .option ([]const []const u8 , "kcov" , "Arguments for kcov in testing (default: null = disabled)" );
2728
29+ const lookupTableOptimize : budopts.LookupTableOptimize = b .option (
30+ budopts .LookupTableOptimize ,
31+ "lookup-table" ,
32+ "Lookup table optimization (default: all; small under ReleaseSmall)" ,
33+ ) orelse switch (optimize ) {
34+ .ReleaseSmall = > .small ,
35+ else = > .all ,
36+ };
37+
38+ const instRewriter = b .option (bool , "install-rewriter" , "Install rewriter (default: false)" ) orelse false ;
39+
2840 const stepCheck = b .step ("check" , "Build but don't install" );
2941 const stepTest = b .step ("test" , "Run library tests" );
3042 const stepCompatTest = b .step ("test-compat" , "Run compatibility tests" );
3143
44+ const bopts = b .addOptions ();
45+ bopts .addOption (budopts .LookupTableOptimize , "lookupTable" , lookupTableOptimize );
46+
3247 const core = b .addModule ("zigpak" , .{
3348 .root_source_file = b .path ("src/root.zig" ),
3449 .optimize = optimize ,
3550 .target = target ,
3651 });
52+ core .addOptions ("budopts" , bopts );
3753
3854 { // Docs for the module
3955 const docs = b .addStaticLibrary (.{
@@ -119,6 +135,10 @@ pub fn build(b: *std.Build) void {
119135 runCompatTest .addArtifactArg (rewriter );
120136 stepCompatTest .dependOn (& runCompatTest .step );
121137 }
138+
139+ if (instRewriter ) {
140+ b .installArtifact (rewriter );
141+ }
122142 }
123143
124144 {
0 commit comments