mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
Tidying (#150)
create resources folder during project_setup, and link with emscripten --embed-file complained b/c the directory was empty, so I added resources/placeholder.txt I tested project_setup.sh (but not project_setup.ps1) -- the emscripten build works also, s/std.builtin.Mode/std.builtin.OptimizeMode (std.builtin.Mode's source says: "///Deprecated; use OptimizeMode.")
This commit is contained in:
parent
87e18ab398
commit
6418a87091
@ -43,7 +43,7 @@ fn link(
|
|||||||
b: *std.Build,
|
b: *std.Build,
|
||||||
exe: *std.Build.Step.Compile,
|
exe: *std.Build.Step.Compile,
|
||||||
target: std.Build.ResolvedTarget,
|
target: std.Build.ResolvedTarget,
|
||||||
optimize: std.builtin.Mode,
|
optimize: std.builtin.OptimizeMode,
|
||||||
options: Options,
|
options: Options,
|
||||||
) void {
|
) void {
|
||||||
const lib = getRaylib(b, target, optimize, options);
|
const lib = getRaylib(b, target, optimize, options);
|
||||||
@ -91,7 +91,7 @@ fn link(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _raylib_lib_cache: ?*std.Build.Step.Compile = null;
|
var _raylib_lib_cache: ?*std.Build.Step.Compile = null;
|
||||||
fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.Mode, options: Options) *std.Build.Step.Compile {
|
fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) *std.Build.Step.Compile {
|
||||||
if (_raylib_lib_cache) |lib| return lib else {
|
if (_raylib_lib_cache) |lib| return lib else {
|
||||||
const raylib = b.dependency("raylib", .{
|
const raylib = b.dependency("raylib", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
@ -138,7 +138,7 @@ fn getRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.Mode) *std.Build.Module {
|
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
|
||||||
if (b.modules.contains("raylib")) {
|
if (b.modules.contains("raylib")) {
|
||||||
return b.modules.get("raylib").?;
|
return b.modules.get("raylib").?;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.buil
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gui = struct {
|
const gui = struct {
|
||||||
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.Mode) *std.Build.Module {
|
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Module {
|
||||||
const raylib = this.getModule(b, target, optimize);
|
const raylib = this.getModule(b, target, optimize);
|
||||||
return b.addModule("raygui", .{
|
return b.addModule("raygui", .{
|
||||||
.root_source_file = b.path("lib/raygui.zig"),
|
.root_source_file = b.path("lib/raygui.zig"),
|
||||||
|
@ -34,6 +34,9 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
// Note that raylib itself is not actually added to the exe_lib output file, so it also needs to be linked with emscripten.
|
// Note that raylib itself is not actually added to the exe_lib output file, so it also needs to be linked with emscripten.
|
||||||
const link_step = try rlz.emcc.linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact });
|
const link_step = try rlz.emcc.linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact });
|
||||||
|
//this lets your program access files like "resources/my-image.png":
|
||||||
|
link_step.addArg("--embed-file");
|
||||||
|
link_step.addArg("resources/");
|
||||||
|
|
||||||
b.getInstallStep().dependOn(&link_step.step);
|
b.getInstallStep().dependOn(&link_step.step);
|
||||||
const run_step = try rlz.emcc.emscriptenRunStep(b);
|
const run_step = try rlz.emcc.emscriptenRunStep(b);
|
||||||
@ -77,5 +80,7 @@ $ZON_FILE = @"
|
|||||||
New-Item -Name "build.zig.zon" -ItemType "file" -Value $ZON_FILE -Force
|
New-Item -Name "build.zig.zon" -ItemType "file" -Value $ZON_FILE -Force
|
||||||
|
|
||||||
New-Item -Name "src" -ItemType "directory"
|
New-Item -Name "src" -ItemType "directory"
|
||||||
|
New-Item -Name "resources" -ItemType "directory"
|
||||||
|
New-Item -Name "resources/placeholder.txt" -ItemType "file" -Value "" -Force
|
||||||
|
|
||||||
Copy-Item -Path "../examples/core/basic_window.zig" -Destination "src/main.zig"
|
Copy-Item -Path "../examples/core/basic_window.zig" -Destination "src/main.zig"
|
||||||
|
@ -33,6 +33,9 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
// Note that raylib itself is not actually added to the exe_lib output file, so it also needs to be linked with emscripten.
|
// Note that raylib itself is not actually added to the exe_lib output file, so it also needs to be linked with emscripten.
|
||||||
const link_step = try rlz.emcc.linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact });
|
const link_step = try rlz.emcc.linkWithEmscripten(b, &[_]*std.Build.Step.Compile{ exe_lib, raylib_artifact });
|
||||||
|
//this lets your program access files like "resources/my-image.png":
|
||||||
|
link_step.addArg("--embed-file");
|
||||||
|
link_step.addArg("resources/");
|
||||||
|
|
||||||
b.getInstallStep().dependOn(&link_step.step);
|
b.getInstallStep().dependOn(&link_step.step);
|
||||||
const run_step = try rlz.emcc.emscriptenRunStep(b);
|
const run_step = try rlz.emcc.emscriptenRunStep(b);
|
||||||
@ -69,4 +72,7 @@ echo '.{
|
|||||||
}' >> build.zig.zon
|
}' >> build.zig.zon
|
||||||
|
|
||||||
mkdir src
|
mkdir src
|
||||||
|
mkdir resources
|
||||||
|
touch resources/placeholder.txt
|
||||||
|
|
||||||
cp ../examples/core/basic_window.zig src/main.zig
|
cp ../examples/core/basic_window.zig src/main.zig
|
||||||
|
Loading…
x
Reference in New Issue
Block a user