Last active
February 28, 2024 17:11
Revisions
-
jacobly0 revised this gist
Feb 28, 2024 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,16 +11,14 @@ pub fn build(b: *std.Build) void { zmesh_options.addOption(bool, "shape_use_32bit_indices", shape_use_32bit_indices); zmesh_options.addOption(bool, "shared", shared); const zmesh = b.addModule("zmesh", .{ .root_source_file = .{ .path = "src/main.zig" }, .imports = &.{ .{ .name = "zmesh_options", .module = b.addModule("zmesh_options", .{ .root_source_file = zmesh_options.getOutput(), }), } }, }); const zmesh_c_cpp = if (shared) blk: { -
jacobly0 created this gist
Feb 28, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); const shape_use_32bit_indices = b.option(bool, "shape_use_32bit_indices", "Enable par shapes 32-bit indices") orelse true; const shared = b.option(bool, "shared", "Build as shared library") orelse false; const zmesh_options = b.addOptions(); zmesh_options.addOption(bool, "shape_use_32bit_indices", shape_use_32bit_indices); zmesh_options.addOption(bool, "shared", shared); const zmesh_options = step.createModule(); const zmesh_options_mod = b.addModule("zmesh_options", .{ .root_source_file = zmesh_options.getOutput(), }); const zmesh = b.addModule("zmesh", .{ .root_source_file = .{ .path = "src/main.zig" }, .imports = &.{ .{ .name = "zmesh_options", .module = zmesh_options }, }, }); const zmesh_c_cpp = if (shared) blk: { const lib = b.addSharedLibrary(.{ .name = "zmesh", .target = target, .optimize = optimize, }); if (target.result.os.tag == .windows) { lib.defineCMacro("CGLTF_API", "__declspec(dllexport)"); lib.defineCMacro("MESHOPTIMIZER_API", "__declspec(dllexport)"); lib.defineCMacro("ZMESH_API", "__declspec(dllexport)"); } break :blk lib; } else b.addStaticLibrary(.{ .name = "zmesh", .target = target, .optimize = optimize, }); zmesh_c_cpp.linkLibC(); if (target.result.abi != .msvc) zmesh_c_cpp.linkLibCpp(); const par_shapes_t = if (shape_use_32bit_indices) "-DPAR_SHAPES_T=uint32_t" else "-DPAR_SHAPES_T=uint16_t"; zmesh_c_cpp.addIncludePath(.{ .path = "libs/par_shapes" }); zmesh_c_cpp.addCSourceFile(.{ .file = .{ .path = "libs/par_shapes/par_shapes.c" }, .flags = &.{ "-std=c99", "-fno-sanitize=undefined", par_shapes_t }, }); zmesh_c_cpp.addCSourceFiles(.{ .root = .{ .path = "libs/meshoptimizer" }, .files = &.{ "clusterizer.cpp", "indexgenerator.cpp", "vcacheoptimizer.cpp", "vcacheanalyzer.cpp", "vfetchoptimizer.cpp", "vfetchanalyzer.cpp", "overdrawoptimizer.cpp", "overdrawanalyzer.cpp", "simplifier.cpp", "allocator.cpp", }, }); zmesh_c_cpp.addIncludePath(.{ .path = "libs/cgltf" }); zmesh_c_cpp.addCSourceFile(.{ .file = .{ .path = "libs/cgltf/cgltf.c" }, .flags = &.{"-std=c99"}, }); const zmesh_tests = b.addTest(.{ .name = "zmesh-tests", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); zmesh_tests.addIncludePath(.{ .path = "libs/cgltf" }); const test_step = b.step("test", "Run zmesh tests"); test_step.dependOn(&b.addRunArtifact(zmesh_tests).step); }