model3d: set cross-target when compiling statically (#616)

This is required for building with a non-native target, otherwise library is build for the native platform and attempts to link fail
This commit is contained in:
Keith Chambers 2022-11-14 19:53:48 -05:00 committed by GitHub
parent 917b0eb8be
commit d21cce37a4
Failed to generate hash of commit

View file

@ -16,13 +16,14 @@ 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(b, main_tests);
link(b, main_tests, target);
main_tests.install();
return main_tests.run();
}
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep) void {
pub fn link(b: *std.build.Builder, step: *std.build.LibExeObjStep, target: std.zig.CrossTarget) void {
const lib = b.addStaticLibrarySource("model3d", null);
lib.setTarget(target);
lib.addCSourceFile(sdkPath("/src/c/m3d.c"), &.{ "-std=c89" });
lib.linkLibC();
step.addIncludePath(sdkPath("/src/c/"));