mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
make the build script great again
This commit is contained in:
parent
f38116fd50
commit
1f2b9bedca
31
build.zig
31
build.zig
@ -63,6 +63,23 @@ fn compileTheRightLua(b: *std.Build, c: *std.Build.Step.Compile, version: LuaVer
|
|||||||
.files = files.items,
|
.files = files.items,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
fn addRunArtifact(b: *std.Build, os: std.Target.Os.Tag, exe: *std.Build.Step.Compile) *std.Build.Step.Run {
|
||||||
|
if (os == .windows) {
|
||||||
|
// do this so that windows can find dll's
|
||||||
|
return b.addSystemCommand(&[_][]const u8{
|
||||||
|
b.getInstallPath(.bin, exe.name),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return b.addRunArtifact(exe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn getSharedEngineName(os: std.Target.Os.Tag) []const u8 {
|
||||||
|
if (os == .windows) {
|
||||||
|
return "neonucleusdll";
|
||||||
|
} else {
|
||||||
|
return "neonucleus";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const os = builtin.target.os.tag;
|
const os = builtin.target.os.tag;
|
||||||
@ -81,7 +98,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
addEngineSources(engineStatic);
|
addEngineSources(engineStatic);
|
||||||
|
|
||||||
const engineShared = b.addSharedLibrary(.{
|
const engineShared = b.addSharedLibrary(.{
|
||||||
.name = "neonucleus",
|
.name = getSharedEngineName(os),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
@ -90,9 +107,11 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
const engineStep = b.step("engine", "Builds the engine as a static library");
|
const engineStep = b.step("engine", "Builds the engine as a static library");
|
||||||
engineStep.dependOn(&engineStatic.step);
|
engineStep.dependOn(&engineStatic.step);
|
||||||
|
engineStep.dependOn(&b.addInstallArtifact(engineStatic, .{}).step);
|
||||||
|
|
||||||
const sharedStep = b.step("shared", "Builds the engine as a shared library");
|
const sharedStep = b.step("shared", "Builds the engine as a shared library");
|
||||||
sharedStep.dependOn(&engineShared.step);
|
sharedStep.dependOn(&engineShared.step);
|
||||||
|
sharedStep.dependOn(&b.addInstallArtifact(engineShared, .{}).step);
|
||||||
|
|
||||||
const emulator = b.addExecutable(.{
|
const emulator = b.addExecutable(.{
|
||||||
.name = "neonucleus",
|
.name = "neonucleus",
|
||||||
@ -121,15 +140,21 @@ pub fn build(b: *std.Build) void {
|
|||||||
// forces us to link in everything too
|
// forces us to link in everything too
|
||||||
emulator.linkLibrary(engineStatic);
|
emulator.linkLibrary(engineStatic);
|
||||||
|
|
||||||
b.step("emulator", "Builds the emulator").dependOn(&emulator.step);
|
const emulatorStep = b.step("emulator", "Builds the emulator");
|
||||||
|
emulatorStep.dependOn(&emulator.step);
|
||||||
|
emulatorStep.dependOn(&b.addInstallArtifact(emulator, .{}).step);
|
||||||
|
if (os == .windows) {
|
||||||
|
emulatorStep.dependOn(&b.addInstallBinFile(b.path("raylib/lib/raylib.dll"), "raylib.dll").step);
|
||||||
|
}
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(emulator);
|
var run_cmd = addRunArtifact(b, os, emulator);
|
||||||
|
|
||||||
if (b.args) |args| {
|
if (b.args) |args| {
|
||||||
run_cmd.addArgs(args);
|
run_cmd.addArgs(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the emulator");
|
const run_step = b.step("run", "Run the emulator");
|
||||||
|
run_step.dependOn(emulatorStep);
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
const lib_unit_tests = b.addTest(.{
|
const lib_unit_tests = b.addTest(.{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user