{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:
Keith Chambers 2022-11-14 17:43:53 -05:00 committed by GitHub
parent 005a99a323
commit 731e2b1287
Failed to generate hash of commit
2 changed files with 13 additions and 5 deletions

View file

@ -169,6 +169,7 @@ pub const App = struct {
res_dirs: ?[]const []const u8,
watch_paths: ?[]const []const u8,
use_freetype: ?[]const u8 = null,
use_model3d: bool = false,
pub const InitError = error{OutOfMemory} || std.zig.system.NativeTargetInfo.DetectError;
pub const LinkError = glfw.LinkError;
@ -199,6 +200,7 @@ pub const App = struct {
/// If set, freetype will be linked and can be imported using this name.
// TODO(build-system): name is currently not used / always "freetype"
use_freetype: ?[]const u8 = null,
use_model3d: bool = false,
},
) InitError!App {
const target = (try std.zig.system.NativeTargetInfo.detect(options.target)).target;
@ -254,6 +256,7 @@ pub const App = struct {
.res_dirs = options.res_dirs,
.watch_paths = options.watch_paths,
.use_freetype = options.use_freetype,
.use_model3d = options.use_model3d,
};
}
@ -266,6 +269,9 @@ pub const App = struct {
}
sysaudio.link(app.b, app.step, options.sysaudio_options);
if (app.use_freetype) |_| freetype.link(app.b, app.step, options.freetype_options);
if (app.use_model3d) {
model3d.link(app.b, app.step);
}
}
pub fn install(app: *const App) void {