Raylib gets added as a package to examples and the projectSetup generator

This commit is contained in:
G3bE 2020-02-15 20:42:22 +10:00
parent bfb4da40a0
commit b8c883e446
No known key found for this signature in database
GPG Key ID: 08BB71E672DB3BFD
4 changed files with 14 additions and 10 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -5,7 +5,7 @@
// Date: 2020-02-15
//
usingnamespace @import("raylib-zig.zig");
usingnamespace @import("raylib");
pub fn main() anyerror!void
{

View File

@ -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