Browse Source

Merge pull request #5061 from myQwil/zig_manual_module

[build][zig] use `addLibrary()` and set root modules manually
pull/5063/head
Ray 3 days ago
committed by GitHub
parent
commit
9a042bc9ad
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 15 deletions
  1. +16
    -15
      build.zig

+ 16
- 15
build.zig View File

@ -153,18 +153,14 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
try raylib_flags_arr.appendSlice(&config_h_flags);
}
const raylib = if (options.shared)
b.addSharedLibrary(.{
.name = "raylib",
const raylib = b.addLibrary(.{
.name = "raylib",
.linkage = if (options.shared) .dynamic else .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
})
else
b.addStaticLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
});
}),
});
raylib.linkLibC();
// No GLFW required on PLATFORM_DRM
@ -550,10 +546,13 @@ fn addExamples(
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
if (target.result.os.tag == .emscripten) {
const exe_lib = b.addStaticLibrary(.{
const exe_lib = b.addLibrary(.{
.name = name,
.target = target,
.optimize = optimize,
.linkage = .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
}),
});
exe_lib.addCSourceFile(.{
.file = b.path(path),
@ -633,8 +632,10 @@ fn addExamples(
} else {
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
}),
});
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibC();

Loading…
Cancel
Save