|
| 1 | +const std = @import("std"); |
| 2 | + |
| 3 | +pub fn getPkg(dependencies: []const std.build.Pkg) std.build.Pkg { |
| 4 | + return .{ |
| 5 | + .name = "common", |
| 6 | + .source = .{ .path = thisDir() ++ "/src/common.zig" }, |
| 7 | + .dependencies = dependencies, |
| 8 | + }; |
| 9 | +} |
| 10 | + |
| 11 | +pub fn build(b: *std.build.Builder) void { |
| 12 | + _ = b; |
| 13 | +} |
| 14 | + |
| 15 | +pub fn link(exe: *std.build.LibExeObjStep) void { |
| 16 | + const lib = buildLibrary(exe); |
| 17 | + exe.linkLibrary(lib); |
| 18 | + //exe.addIncludePath(thisDir() ++ "/src/c"); |
| 19 | + exe.addIncludePath(thisDir() ++ "/libs/imgui"); |
| 20 | + //exe.addIncludePath(thisDir() ++ "/../zmesh/libs/cgltf"); |
| 21 | + //exe.addIncludePath(thisDir() ++ "/../zstbi/libs/stbi"); |
| 22 | +} |
| 23 | + |
| 24 | +fn buildLibrary(exe: *std.build.LibExeObjStep) *std.build.LibExeObjStep { |
| 25 | + const lib = exe.builder.addStaticLibrary("common", thisDir() ++ "/src/common.zig"); |
| 26 | + |
| 27 | + lib.setBuildMode(exe.build_mode); |
| 28 | + lib.setTarget(exe.target); |
| 29 | + //lib.addIncludePath(thisDir() ++ "/src/c"); |
| 30 | + |
| 31 | + lib.linkSystemLibraryName("c"); |
| 32 | + lib.linkSystemLibraryName("c++"); |
| 33 | + lib.linkSystemLibraryName("imm32"); |
| 34 | + |
| 35 | + lib.addIncludePath(thisDir() ++ "/libs"); |
| 36 | + lib.addCSourceFile(thisDir() ++ "/libs/imgui/imgui.cpp", &.{""}); |
| 37 | + lib.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_widgets.cpp", &.{""}); |
| 38 | + lib.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_tables.cpp", &.{""}); |
| 39 | + lib.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_draw.cpp", &.{""}); |
| 40 | + lib.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_demo.cpp", &.{""}); |
| 41 | + lib.addCSourceFile(thisDir() ++ "/libs/imgui/cimgui.cpp", &.{""}); |
| 42 | + |
| 43 | + //lib.addIncludePath(thisDir() ++ "/../zmesh/libs/cgltf"); |
| 44 | + //lib.addCSourceFile(thisDir() ++ "/../zmesh/libs/cgltf/cgltf.c", &.{"-std=c99"}); |
| 45 | + |
| 46 | + //lib.addIncludePath(thisDir() ++ "/../zstbi/libs/stbi"); |
| 47 | + //lib.addCSourceFile(thisDir() ++ "/../zstbi/libs/stbi/stb_image.c", &.{"-std=c99"}); |
| 48 | + |
| 49 | + return lib; |
| 50 | +} |
| 51 | + |
| 52 | +inline fn thisDir() []const u8 { |
| 53 | + return comptime std.fs.path.dirname(@src().file) orelse "."; |
| 54 | +} |
0 commit comments