@@ -10,14 +10,15 @@ pub fn build(b: *std.Build) !void {
1010 //const build_v8 = b.option(bool, "build_v8", "Whether to build from v8 source") orelse false;
1111 const path = b .option ([]const u8 , "path" , "Path to main file, for: build, run" ) orelse "" ;
1212 const use_zig_tc = b .option (bool , "zig-toolchain" , "Experimental: Use zig cc/c++/ld to build v8." ) orelse false ;
13+ const icu = b .option (bool , "icu" , "Add ICU (unicode) support. Default is true" ) orelse true ;
1314
1415 const mode = b .standardOptimizeOption (.{});
1516 const target = b .standardTargetOptions (.{});
1617
1718 _ = createGetTools (b );
18- _ = createGetV8 (b );
19+ _ = createGetV8 (b , icu );
1920
20- const v8 = try createV8_Build (b , target , mode , use_zig_tc );
21+ const v8 = try createV8_Build (b , target , mode , use_zig_tc , icu );
2122
2223 const create_test = createTest (b , target , mode , use_zig_tc );
2324 const run_test = b .addRunArtifact (create_test );
@@ -32,18 +33,14 @@ pub fn build(b: *std.Build) !void {
3233 b .default_step .dependOn (v8 );
3334}
3435
35- // When this is true, we'll strip V8 features down to a minimum so the resulting library is smaller.
36- // eg. i18n will be excluded.
37- const MinimalV8 = true ;
38-
3936// gclient is comprehensive and will pull everything for the v8 project.
4037// Set this to false to pull the minimal required src by parsing v8/DEPS and whitelisting deps we care about.
4138const UseGclient = false ;
4239
4340// V8's build process is complex and porting it to zig could take quite awhile.
4441// It would be nice if there was a way to import .gn files into the zig build system.
4542// For now we just use gn/ninja like rusty_v8 does: https://github.com/denoland/rusty_v8/blob/main/build.rs
46- fn createV8_Build (b : * std.Build , target : std.Build.ResolvedTarget , mode : std.builtin.Mode , use_zig_tc : bool ) ! * std.Build.Step {
43+ fn createV8_Build (b : * std.Build , target : std.Build.ResolvedTarget , mode : std.builtin.Mode , use_zig_tc : bool , icu : bool ) ! * std.Build.Step {
4744 const step = b .step ("v8" , "Build v8 c binding lib." );
4845
4946 var cp : * CopyFileStep = undefined ;
@@ -113,7 +110,7 @@ fn createV8_Build(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.bui
113110 // TODO: Might want to turn V8_ENABLE_CHECKS off to remove asserts.
114111 }
115112
116- if (MinimalV8 ) {
113+ if (! icu ) {
117114 // Don't add i18n for now. It has a large dependency on third_party/icu.
118115 try gn_args .append ("v8_enable_i18n_support=false" );
119116 }
@@ -351,7 +348,7 @@ const CheckV8DepsStep = struct {
351348 }
352349};
353350
354- fn createGetV8 (b : * std.Build ) * std.Build.Step {
351+ fn createGetV8 (b : * std.Build , icu : bool ) * std.Build.Step {
355352 const step = b .step ("get-v8" , "Gets v8 source using gclient." );
356353 if (UseGclient ) {
357354 const mkpath = MakePathStep .create (b , "./gclient" );
@@ -363,7 +360,7 @@ fn createGetV8(b: *std.Build) *std.Build.Step {
363360 cmd .addPathDir (b .pathFromRoot ("./tools/depot_tools" ));
364361 step .dependOn (& cmd .step );
365362 } else {
366- const get = GetV8SourceStep .create (b );
363+ const get = GetV8SourceStep .create (b , icu );
367364 step .dependOn (& get .step );
368365 }
369366 return step ;
@@ -557,8 +554,9 @@ pub const GetV8SourceStep = struct {
557554
558555 step : Step ,
559556 b : * std.Build ,
557+ icu : bool ,
560558
561- pub fn create (b : * std.Build ) * Self {
559+ pub fn create (b : * std.Build , icu : bool ) * Self {
562560 const self = b .allocator .create (Self ) catch unreachable ;
563561 self .* = .{
564562 .b = b ,
@@ -568,6 +566,7 @@ pub const GetV8SourceStep = struct {
568566 .makeFn = make ,
569567 .owner = b ,
570568 }),
569+ .icu = icu ,
571570 };
572571 return self ;
573572 }
@@ -712,6 +711,11 @@ pub const GetV8SourceStep = struct {
712711 // markupsafe
713712 try self .getDep (step , deps , "third_party/markupsafe" , "v8/third_party/markupsafe" );
714713
714+ // icu
715+ if (self .icu ) {
716+ try self .getDep (step , deps , "third_party/icu" , "v8/third_party/icu" );
717+ }
718+
715719 // For windows.
716720 if (builtin .os .tag == .windows ) {
717721 // lastchange.py is flaky when it tries to do git commands from subprocess.Popen. Will sometimes get [WinError 50].
0 commit comments