diff --git a/ReadMe.md b/ReadMe.md index e86acb6..62f9a34 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -46,8 +46,7 @@ pub fn main() anyerror!void ``` ## Building the examples -Don't. At the moment im still trying to figure out how to turn the binding into a proper zig package and until then I can't build the examples without destroying the project setup. -The `basic_window` example is the default source file for project setup though +To build all available examples simply `zig build examples`. To list available examples run `zig build --help`. If you want to run and examples, say `basic_window` run `zig build basic_window` ## Building and using + Install raylib diff --git a/build.zig b/build.zig index 1445158..1ed5769 100644 --- a/build.zig +++ b/build.zig @@ -10,14 +10,17 @@ const Builder = @import("std").build.Builder; pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); - const lib = b.addStaticLibrary("raylib-zig", "lib/raylib-zig.zig"); - lib.setBuildMode(mode); - lib.linkSystemLibrary("raylib"); - lib.install(); var basicWindow = b.addExecutable("BasicWindow", "examples/core/BasicWindow.zig"); basicWindow.setBuildMode(mode); + basicWindow.linkSystemLibrary("raylib"); + basicWindow.addPackagePath("raylib", "lib/raylib-zig.zig"); - const example_step = b.step("basicWindow", "Creates a basic window and text"); - example_step.dependOn(&basicWindow.step); + const examplesStep = b.step("examples", "Builds all the examples"); + examplesStep.dependOn(&basicWindow.step); + + const runBasicWindow = basicWindow.run(); + runBasicWindow.step.dependOn(b.getInstallStep()); + const basicWindowStep = b.step("basic_window", "Creates a basic window with text"); + basicWindowStep.dependOn(&runBasicWindow.step); } diff --git a/examples/core/BasicWindow.zig b/examples/core/BasicWindow.zig index b9beb33..fd46be9 100644 --- a/examples/core/BasicWindow.zig +++ b/examples/core/BasicWindow.zig @@ -5,7 +5,7 @@ // Date: 2020-02-15 // -usingnamespace @import("raylib-zig.zig"); +usingnamespace @import("raylib"); pub fn main() anyerror!void { diff --git a/projectSetup.sh b/projectSetup.sh index 896ee4f..e854d29 100755 --- a/projectSetup.sh +++ b/projectSetup.sh @@ -14,6 +14,7 @@ pub fn build(b: *Builder) void { const exe = b.addExecutable("'"$PROJECT_NAME"'", "src/main.zig"); exe.setBuildMode(mode); exe.linkSystemLibrary("raylib"); + exe.addPackagePath("raylib", "raylib-zig/raylib-zig.zig"); exe.install(); const run_cmd = exe.run(); @@ -25,6 +26,7 @@ pub fn build(b: *Builder) void { ' >> build.zig mkdir src -cp ../lib/* src +mkdir raylib-zig +cp ../lib/* raylib-zig cp ../examples/core/BasicWindow.zig src mv src/BasicWindow.zig src/main.zig \ No newline at end of file