@@ -10,7 +10,11 @@ pub fn build(b: *std.Build) !void {
1010 const is_cross_compiling = target .result .cpu .arch != native_target .result .cpu .arch or
1111 target .result .os .tag != native_target .result .os .tag ;
1212
13- const lib_mod , const exe = buildOdiff (b , target , optimize , dynamic );
13+ const build_options = b .addOptions ();
14+ build_options .addOption ([]const u8 , "version" , manifest .version );
15+ const build_options_mod = build_options .createModule ();
16+
17+ const lib_mod , const exe = buildOdiff (b , target , optimize , dynamic , build_options_mod );
1418 b .installArtifact (exe );
1519
1620 const run_cmd = b .addRunArtifact (exe );
@@ -36,6 +40,7 @@ pub fn build(b: *std.Build) !void {
3640 "src/test_io_bmp.zig" ,
3741 "src/test_io_jpg.zig" ,
3842 "src/test_io_tiff.zig" ,
43+ "src/test_avx.zig" ,
3944 };
4045
4146 const integration_tests_pure_zig = [_ ][]const u8 {
@@ -58,6 +63,7 @@ pub fn build(b: *std.Build) !void {
5863 .optimize = optimize ,
5964 }),
6065 });
66+ integration_test .root_module .addImport ("build_options" , build_options_mod );
6167 integration_test .linkLibC ();
6268 integration_test .linkLibrary (root_lib );
6369 linkDeps (b , target , optimize , false , integration_test .root_module );
@@ -74,6 +80,7 @@ pub fn build(b: *std.Build) !void {
7480 .optimize = optimize ,
7581 }),
7682 });
83+ pure_test .root_module .addImport ("build_options" , build_options_mod );
7784
7885 const run_pure_test = b .addRunArtifact (pure_test );
7986 integration_test_steps .append (run_pure_test ) catch @panic ("OOM" );
@@ -95,7 +102,7 @@ pub fn build(b: *std.Build) !void {
95102 const build_ci_step = b .step ("ci" , "Build the app for CI" );
96103 for (build_targets ) | target_query | {
97104 const t = b .resolveTargetQuery (target_query );
98- _ , const odiff_exe = buildOdiff (b , t , optimize , dynamic );
105+ _ , const odiff_exe = buildOdiff (b , t , optimize , dynamic , build_options_mod );
99106 odiff_exe .root_module .strip = true ;
100107 const odiff_output = b .addInstallArtifact (odiff_exe , .{
101108 .dest_dir = .{
@@ -113,6 +120,7 @@ fn buildOdiff(
113120 target : std.Build.ResolvedTarget ,
114121 optimize : std.builtin.OptimizeMode ,
115122 dynamic : bool ,
123+ build_options_mod : * std.Build.Module ,
116124) struct { * std .Build .Module , * std .Build .Step .Compile } {
117125 const lib_mod = b .createModule (.{
118126 .root_source_file = b .path ("src/root.zig" ),
@@ -146,11 +154,24 @@ fn buildOdiff(
146154 });
147155
148156 exe_mod .addImport ("odiff_lib" , lib_mod );
149-
150- const options = b .addOptions ();
151- options .addOption ([]const u8 , "version" , manifest .version );
152- exe_mod .addImport ("build_options" , options .createModule ());
153- lib_mod .addImport ("build_options" , options .createModule ());
157+ exe_mod .addImport ("build_options" , build_options_mod );
158+ lib_mod .addImport ("build_options" , build_options_mod );
159+
160+ if (target .result .cpu .arch == .x86_64 ) {
161+ const os_tag = target .result .os .tag ;
162+ const fmt : ? []const u8 = switch (os_tag ) {
163+ .linux = > "elf64" ,
164+ .macos = > "macho64" ,
165+ else = > null ,
166+ };
167+
168+ if (fmt ) | nasm_fmt | {
169+ const nasm = b .addSystemCommand (&.{ "nasm" , "-f" , nasm_fmt , "-o" });
170+ const asm_obj = nasm .addOutputFileArg ("vxdiff.o" );
171+ nasm .addFileArg (b .path ("src/vxdiff.asm" ));
172+ lib_mod .addObjectFile (asm_obj );
173+ }
174+ }
154175
155176 const exe = b .addExecutable (.{
156177 .name = "odiff" ,
0 commit comments