@@ -3,9 +3,6 @@ const builtin = @import("builtin");
33const Build = std .Build ;
44
55pub fn build (b : * Build ) ! void {
6- var envMap = try std .process .getEnvMap (b .allocator );
7- defer envMap .deinit ();
8-
96 const build_mode = b .standardOptimizeOption (.{});
107 const target = b .standardTargetOptions (.{});
118 const is_wasm = target .result .cpu .arch .isWasm ();
@@ -15,7 +12,6 @@ pub fn build(b: *Build) !void {
1512 b ,
1613 is_wasm ,
1714 target ,
18- envMap ,
1915 );
2016 const build_option_module = build_options .step (b );
2117
@@ -259,7 +255,7 @@ pub fn build(b: *Build) !void {
259255 const test_step = b .step ("test" , "Run all the tests" );
260256 const run_tests = b .addRunArtifact (tests );
261257 run_tests .cwd = b .path ("." );
262- run_tests .setEnvironmentVariable ("BUZZ_PATH" , envMap .get ("BUZZ_PATH" ) orelse std .fs .path .dirname (b .exe_dir ).? );
258+ run_tests .setEnvironmentVariable ("BUZZ_PATH" , b . graph . environ_map .get ("BUZZ_PATH" ) orelse std .fs .path .dirname (b .exe_dir ).? );
263259 run_tests .step .dependOn (install_step ); // wait for libraries to be installed
264260 test_step .dependOn (& run_tests .step );
265261
@@ -270,14 +266,14 @@ pub fn build(b: *Build) !void {
270266
271267 // Link non-zig deps to executables and library
272268 for (ext_deps ) | dep | {
273- c .linkLibrary (dep );
269+ c .root_module . linkLibrary (dep );
274270
275271 if (target .result .os .tag == .windows ) {
276- c .linkSystemLibrary ("bcrypt" );
272+ c .root_module . linkSystemLibrary ("bcrypt" , .{} );
277273 }
278274
279275 if (build_options .needLibC ()) {
280- c .linkLibC () ;
276+ c .root_module . link_libc = true ;
281277 }
282278 }
283279 }
@@ -286,7 +282,7 @@ pub fn build(b: *Build) !void {
286282 // So that JIT compiled function can reference buzz_api
287283 for ([_ ]? * std.Build.Step.Compile { exe , behavior_exe , debugger_exe , lsp_exe , check_exe , fuzz }) | comp | {
288284 if (comp ) | c | {
289- c .linkLibrary (static_lib );
285+ c .root_module . linkLibrary (static_lib );
290286 }
291287 }
292288
@@ -385,17 +381,18 @@ pub fn build(b: *Build) !void {
385381
386382 // No need to link anything when building for wasm since everything is static
387383 if (build_options .needLibC ()) {
388- std_lib .linkLibC () ;
384+ std_lib .root_module . link_libc = true ;
389385 }
390386
391387 for (ext_deps ) | dep | {
392- std_lib .linkLibrary (dep );
388+ std_lib .root_module . linkLibrary (dep );
393389 }
394390
395- std_lib .linkLibrary (static_lib );
391+ std_lib .root_module . linkLibrary (static_lib );
396392 std_lib .root_module .addImport ("build_options" , build_option_module );
397393
398394 b .default_step .dependOn (& std_lib .step );
395+ check_exe .step .dependOn (& std_lib .step );
399396 }
400397}
401398
@@ -429,13 +426,14 @@ pub fn buildPcre2(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin
429426 .target = target ,
430427 .optimize = optimize ,
431428 .sanitize_c = .off ,
429+ .link_libc = true ,
432430 },
433431 ),
434432 },
435433 );
436- lib .addIncludePath (b .path ("vendors/pcre2/src" ));
437- lib .addIncludePath (copyFiles .getDirectory ().path (b , "vendors/pcre2/src" ));
438- lib .addCSourceFiles (
434+ lib .root_module . addIncludePath (b .path ("vendors/pcre2/src" ));
435+ lib .root_module . addIncludePath (copyFiles .getDirectory ().path (b , "vendors/pcre2/src" ));
436+ lib .root_module . addCSourceFiles (
439437 .{
440438 .files = &.{
441439 "vendors/pcre2/src/pcre2_auto_possess.c" ,
@@ -467,14 +465,13 @@ pub fn buildPcre2(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin
467465 .flags = flags ,
468466 },
469467 );
470- lib .addCSourceFile (
468+ lib .root_module . addCSourceFile (
471469 .{
472470 .file = copyFiles .getDirectory ().path (b , "vendors/pcre2/src/pcre2_chartables.c" ),
473471 .flags = flags ,
474472 },
475473 );
476474 lib .step .dependOn (& copyFiles .step );
477- lib .linkLibC ();
478475 b .installArtifact (lib );
479476
480477 return lib ;
@@ -490,15 +487,15 @@ pub fn buildMimalloc(b: *Build, target: Build.ResolvedTarget, optimize: std.buil
490487 .{
491488 .target = target ,
492489 .optimize = optimize ,
490+ .link_libc = true ,
493491 },
494492 ),
495493 },
496494 );
497495
498- lib .addIncludePath (b .path ("./vendors/mimalloc/include" ));
499- lib .linkLibC ();
496+ lib .root_module .addIncludePath (b .path ("./vendors/mimalloc/include" ));
500497
501- lib .addCSourceFiles (
498+ lib .root_module . addCSourceFiles (
502499 .{
503500 .files = &.{
504501 "./vendors/mimalloc/src/alloc.c" ,
@@ -553,13 +550,14 @@ pub fn buildLinenoise(b: *Build, target: Build.ResolvedTarget, optimize: std.bui
553550 .target = target ,
554551 .optimize = optimize ,
555552 .sanitize_c = .off ,
553+ .link_libc = true ,
556554 },
557555 ),
558556 },
559557 );
560558
561- lib .addIncludePath (b .path ("vendors/linenoise" ));
562- lib .addCSourceFiles (
559+ lib .root_module . addIncludePath (b .path ("vendors/linenoise" ));
560+ lib .root_module . addCSourceFiles (
563561 .{
564562 .files = &.{
565563 "vendors/linenoise/linenoise.c" ,
@@ -569,7 +567,6 @@ pub fn buildLinenoise(b: *Build, target: Build.ResolvedTarget, optimize: std.bui
569567 },
570568 },
571569 );
572- lib .linkLibC ();
573570 b .installArtifact (lib );
574571
575572 return lib ;
@@ -622,16 +619,15 @@ pub fn buildMir(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.O
622619 .{
623620 .target = target ,
624621 .optimize = optimize ,
622+ .link_libc = true ,
625623 },
626624 ),
627625 },
628626 );
629627
630- lib .addIncludePath (b .path ("./vendors/mir" ));
631-
632- lib .linkLibC ();
628+ lib .root_module .addIncludePath (b .path ("./vendors/mir" ));
633629
634- lib .addCSourceFiles (
630+ lib .root_module . addCSourceFiles (
635631 .{
636632 .files = &.{
637633 "./vendors/mir/mir.c" ,
@@ -649,8 +645,8 @@ pub fn buildMir(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.O
649645 );
650646
651647 if (target .result .os .tag == .windows ) {
652- lib .linkSystemLibrary ("kernel32" );
653- lib .linkSystemLibrary ("psapi" );
648+ lib .root_module . linkSystemLibrary ("kernel32" , .{} );
649+ lib .root_module . linkSystemLibrary ("psapi" , .{} );
654650 }
655651 b .installArtifact (lib );
656652
@@ -776,13 +772,13 @@ const BuildOptions = struct {
776772 recursive_call_limit : ? u32 ,
777773 stack_size : usize = 100_000 ,
778774
779- pub fn init (b : * Build , is_wasm : bool , target : Build.ResolvedTarget , envMap : std.process.EnvMap ) BuildOptions {
775+ pub fn init (b : * Build , is_wasm : bool , target : Build.ResolvedTarget ) BuildOptions {
780776 return BuildOptions {
781777 .target = target ,
782778 .version = std.SemanticVersion { .major = 0 , .minor = 6 , .patch = 0 },
783779 // Current commit sha
784- .sha = envMap .get ("GIT_SHA" ) orelse
785- envMap .get ("GITHUB_SHA" ) orelse std .mem .trim (
780+ .sha = b . graph . environ_map .get ("GIT_SHA" ) orelse
781+ b . graph . environ_map .get ("GITHUB_SHA" ) orelse std .mem .trim (
786782 u8 ,
787783 b .run (
788784 &.{
@@ -865,7 +861,7 @@ const BuildOptions = struct {
865861 .debug_access = b .option (
866862 bool ,
867863 "gc_debug_access" ,
868- "Track objects access" ,
864+ "Show access debug information for the garbage collector " ,
869865 ) orelse false ,
870866 .on = b .option (
871867 bool ,
0 commit comments