{mach,model3d}: link model3d as static lib instead of adding C files to build step (#613)
This allows the library to link better with projects. Otherwise you can end up with a mix of conflicts over that compiler + version to use. Also adds .use_model3d option to mach build system. If set to true, model3d will be linked in statically to target project.
This commit is contained in:
parent
005a99a323
commit
731e2b1287
2 changed files with 13 additions and 5 deletions
|
|
@ -16,15 +16,17 @@ pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.C
|
|||
const main_tests = b.addTestExe("model3d-tests", "src/main.zig");
|
||||
main_tests.setBuildMode(mode);
|
||||
main_tests.setTarget(target);
|
||||
link(main_tests);
|
||||
link(b, main_tests);
|
||||
main_tests.install();
|
||||
return main_tests.run();
|
||||
}
|
||||
|
||||
pub fn link(step: *std.build.LibExeObjStep) void {
|
||||
step.addCSourceFile(sdkPath("/src/c/m3d.c"), &.{});
|
||||
step.addIncludePath(sdkPath("/src/c"));
|
||||
step.linkLibC();
|
||||
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep) void {
|
||||
const lib = b.addStaticLibrarySource("model3d", null);
|
||||
lib.addCSourceFile(sdkPath("/src/c/m3d.c"), &.{ "-std=c89", "-DM3D_ASCII" });
|
||||
lib.linkLibC();
|
||||
step.addIncludePath(sdkPath("/src/c/"));
|
||||
step.linkLibrary(lib);
|
||||
}
|
||||
|
||||
fn sdkPath(comptime suffix: []const u8) []const u8 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue