mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
Update build system to latest raylib
This commit is contained in:
parent
c83263a8a7
commit
ba7b7c97f8
9
.gitignore
vendored
9
.gitignore
vendored
@ -2,10 +2,7 @@ zig-cache/
|
||||
.idea/
|
||||
Project/*
|
||||
|
||||
**/raylib.h
|
||||
**/raymath.h
|
||||
**/.DS_Store
|
||||
**/CMakeLists.txt
|
||||
**/cmake-build-debug
|
||||
examples/**/**.c
|
||||
raylib.h
|
||||
raymath.h
|
||||
libraylib.a
|
||||
**/.DS_Store
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
const std = @import("std");
|
||||
const Builder = std.build.Builder;
|
||||
const raylib = @import("lib.zig").Pkg(".");
|
||||
const raylib = @import("lib.zig");
|
||||
|
||||
const Program = struct {
|
||||
name: []const u8,
|
||||
|
@ -59,8 +59,7 @@ pub fn main() anyerror!void
|
||||
if ((touchPosition.x >= 0) and (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it
|
||||
{
|
||||
// Draw circle and touch index number
|
||||
rl.DrawCircle(@floatToInt(c_int, touchPosition.x), @floatToInt(c_int, touchPosition.y), 34, rl.ORANGE);
|
||||
//DrawCircleV(touchPosition, 34, ORANGE);
|
||||
rl.DrawCircleV(touchPosition, 34, rl.ORANGE);
|
||||
rl.DrawText(rl.FormatText("%d", i), @floatToInt(c_int, touchPosition.x) - 10, @floatToInt(c_int, touchPosition.y) - 70, 40, rl.BLACK);
|
||||
}
|
||||
}
|
||||
|
114
lib.zig
114
lib.zig
@ -1,62 +1,64 @@
|
||||
const std = @import("std");
|
||||
const Builder = std.build.Builder;
|
||||
const LibExeObjStep = std.build.LibExeObjStep;
|
||||
const rl = @import("raylib/src/build.zig").Pkg("raylib/src");
|
||||
const rl = @import("raylib/src/build.zig");
|
||||
|
||||
pub fn Pkg(pkgdir: []const u8) type {
|
||||
return struct {
|
||||
var ran_git = false;
|
||||
pub fn link(exe: *LibExeObjStep, system_lib: bool) void {
|
||||
if (system_lib) {
|
||||
exe.linkSystemLibrary("raylib");
|
||||
return;
|
||||
} else {
|
||||
exe.linkLibrary(rl.addRaylib(exe.builder, exe.target));
|
||||
}
|
||||
var ran_git = false;
|
||||
const srcdir = getSrcDir();
|
||||
|
||||
const target_os = exe.target.toTarget().os.tag;
|
||||
switch (target_os) {
|
||||
.windows => {
|
||||
exe.linkSystemLibrary("winmm");
|
||||
exe.linkSystemLibrary("gdi32");
|
||||
exe.linkSystemLibrary("opengl32");
|
||||
},
|
||||
.macos => {
|
||||
exe.linkFramework("OpenGL");
|
||||
exe.linkFramework("Cocoa");
|
||||
exe.linkFramework("IOKit");
|
||||
exe.linkFramework("CoreAudio");
|
||||
exe.linkFramework("CoreVideo");
|
||||
},
|
||||
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
||||
exe.linkSystemLibrary("GL");
|
||||
exe.linkSystemLibrary("rt");
|
||||
exe.linkSystemLibrary("dl");
|
||||
exe.linkSystemLibrary("m");
|
||||
exe.linkSystemLibrary("X11");
|
||||
exe.linkSystemLibrary("Xrandr");
|
||||
exe.linkSystemLibrary("Xinerama");
|
||||
exe.linkSystemLibrary("Xi");
|
||||
exe.linkSystemLibrary("Xxf86vm");
|
||||
exe.linkSystemLibrary("Xcursor");
|
||||
},
|
||||
else => { // linux and possibly others
|
||||
exe.linkSystemLibrary("GL");
|
||||
exe.linkSystemLibrary("rt");
|
||||
exe.linkSystemLibrary("dl");
|
||||
exe.linkSystemLibrary("m");
|
||||
exe.linkSystemLibrary("X11");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn addAsPackage(name: []const u8, to: *LibExeObjStep) void {
|
||||
to.addPackagePath(name, pkgdir ++ "/lib/raylib-zig.zig");
|
||||
}
|
||||
pub const math = struct {
|
||||
pub fn addAsPackage(name: []const u8, to: *LibExeObjStep) void {
|
||||
to.addPackagePath(name, pkgdir ++ "/lib/raylib-zig-math.zig");
|
||||
}
|
||||
};
|
||||
};
|
||||
fn getSrcDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub fn link(exe: *LibExeObjStep, system_lib: bool) void {
|
||||
if (system_lib) {
|
||||
exe.linkSystemLibrary("raylib");
|
||||
return;
|
||||
} else {
|
||||
exe.linkLibrary(rl.addRaylib(exe.builder, exe.target));
|
||||
}
|
||||
|
||||
const target_os = exe.target.toTarget().os.tag;
|
||||
switch (target_os) {
|
||||
.windows => {
|
||||
exe.linkSystemLibrary("winmm");
|
||||
exe.linkSystemLibrary("gdi32");
|
||||
exe.linkSystemLibrary("opengl32");
|
||||
},
|
||||
.macos => {
|
||||
exe.linkFramework("OpenGL");
|
||||
exe.linkFramework("Cocoa");
|
||||
exe.linkFramework("IOKit");
|
||||
exe.linkFramework("CoreAudio");
|
||||
exe.linkFramework("CoreVideo");
|
||||
},
|
||||
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
||||
exe.linkSystemLibrary("GL");
|
||||
exe.linkSystemLibrary("rt");
|
||||
exe.linkSystemLibrary("dl");
|
||||
exe.linkSystemLibrary("m");
|
||||
exe.linkSystemLibrary("X11");
|
||||
exe.linkSystemLibrary("Xrandr");
|
||||
exe.linkSystemLibrary("Xinerama");
|
||||
exe.linkSystemLibrary("Xi");
|
||||
exe.linkSystemLibrary("Xxf86vm");
|
||||
exe.linkSystemLibrary("Xcursor");
|
||||
},
|
||||
else => { // linux and possibly others
|
||||
exe.linkSystemLibrary("GL");
|
||||
exe.linkSystemLibrary("rt");
|
||||
exe.linkSystemLibrary("dl");
|
||||
exe.linkSystemLibrary("m");
|
||||
exe.linkSystemLibrary("X11");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn addAsPackage(name: []const u8, to: *LibExeObjStep) void {
|
||||
to.addPackagePath(name, srcdir ++ "/lib/raylib-zig.zig");
|
||||
}
|
||||
pub const math = struct {
|
||||
pub fn addAsPackage(name: []const u8, to: *LibExeObjStep) void {
|
||||
to.addPackagePath(name, srcdir ++ "/lib/raylib-zig-math.zig");
|
||||
}
|
||||
};
|
||||
|
2
raylib
2
raylib
@ -1 +1 @@
|
||||
Subproject commit a6aa5a1e4c34e7d8dfbede6d17ee40f7648265bb
|
||||
Subproject commit 9ecbc465a934fdde9e3d69a709370a370bf193a0
|
Loading…
x
Reference in New Issue
Block a user