@@ -15,16 +15,23 @@ pub fn build(b: *std.Build) !void {
1515 const mode = b .standardOptimizeOption (.{});
1616 const target = b .standardTargetOptions (.{});
1717
18+ var build_opts = b .addOptions ();
19+ build_opts .addOption (
20+ bool ,
21+ "inspector_subtype" ,
22+ b .option (bool , "inspector_subtype" , "Export default valueSubtype and descriptionForValueSubtype" ) orelse true ,
23+ );
24+
1825 _ = createGetTools (b );
1926 _ = createGetV8 (b , icu );
2027
2128 const v8 = try createV8_Build (b , target , mode , use_zig_tc , icu );
2229
23- const create_test = createTest (b , target , mode , use_zig_tc );
30+ const create_test = createTest (b , target , mode , use_zig_tc , build_opts );
2431 const run_test = b .addRunArtifact (create_test );
2532 b .step ("test" , "Run tests." ).dependOn (& run_test .step );
2633
27- const build_exe = createCompileStep (b , path , target , mode , use_zig_tc );
34+ const build_exe = createCompileStep (b , path , target , mode , use_zig_tc , build_opts );
2835 b .step ("exe" , "Build exe with main file at -Dpath" ).dependOn (& build_exe .step );
2936
3037 const run_exe = b .addRunArtifact (build_exe );
@@ -510,13 +517,14 @@ fn linkV8(b: *std.Build, step: *std.Build.Step.Compile, use_zig_tc: bool) void {
510517 }
511518}
512519
513- fn createTest (b : * std.Build , target : std.Build.ResolvedTarget , mode : std.builtin.Mode , use_zig_tc : bool ) * std.Build.Step.Compile {
520+ fn createTest (b : * std.Build , target : std.Build.ResolvedTarget , mode : std.builtin.Mode , use_zig_tc : bool , build_opts : * std.Build.Step.Options ) * std.Build.Step.Compile {
514521 const step = b .addTest (.{
515522 .root_source_file = b .path ("./src/test.zig" ),
516523 .target = target ,
517524 .optimize = mode ,
518525 .link_libc = true ,
519526 });
527+ step .root_module .addImport ("default_exports" , build_opts .createModule ());
520528 step .addIncludePath (b .path ("./src" ));
521529 linkV8 (b , step , use_zig_tc );
522530 return step ;
@@ -733,7 +741,7 @@ pub const GetV8SourceStep = struct {
733741 }
734742};
735743
736- fn createCompileStep (b : * std.Build , path : []const u8 , target : std.Build.ResolvedTarget , mode : std.builtin.Mode , use_zig_tc : bool ) * std.Build.Step.Compile {
744+ fn createCompileStep (b : * std.Build , path : []const u8 , target : std.Build.ResolvedTarget , mode : std.builtin.Mode , use_zig_tc : bool , build_opts : * std.Build.Step.Options ) * std.Build.Step.Compile {
737745 const basename = std .fs .path .basename (path );
738746 const i = std .mem .indexOf (u8 , basename , ".zig" ) orelse basename .len ;
739747 const name = basename [0.. i ];
@@ -746,7 +754,7 @@ fn createCompileStep(b: *std.Build, path: []const u8, target: std.Build.Resolved
746754 .link_libc = true ,
747755 });
748756 step .addIncludePath (b .path ("src" ));
749-
757+ step . root_module . addImport ( "default_exports" , build_opts . createModule ());
750758 if (mode == .ReleaseSafe ) {
751759 step .root_module .strip = true ;
752760 }
0 commit comments