move platform to be a separate module
This commit is contained in:
parent
6f21915c9a
commit
1165c53683
65
build.zig
65
build.zig
@ -34,20 +34,29 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const dep_tiled = b.dependency("tiled", .{});
|
||||||
|
exe_mod.addImport("tiled", dep_tiled.module("tiled"));
|
||||||
|
|
||||||
|
const dep_stb = b.dependency("stb", .{});
|
||||||
|
exe_mod.addImport("stb_image", dep_stb.module("stb_image"));
|
||||||
|
exe_mod.addImport("stb_truetype", dep_stb.module("stb_truetype"));
|
||||||
|
|
||||||
|
const platform_mod = b.createModule(.{
|
||||||
|
.root_source_file = b.path("src/platform/root.zig")
|
||||||
|
});
|
||||||
|
exe_mod.addImport("platform", platform_mod);
|
||||||
|
{
|
||||||
const build_options = b.addOptions();
|
const build_options = b.addOptions();
|
||||||
build_options.addOption(bool, "has_imgui", has_imgui);
|
build_options.addOption(bool, "has_imgui", has_imgui);
|
||||||
build_options.addOption(?[]const u8, "assets_dir", if (assets_from_filesystem) asset_dir_realpath else null);
|
build_options.addOption(?[]const u8, "assets_dir", if (assets_from_filesystem) asset_dir_realpath else null);
|
||||||
exe_mod.addOptions("build_options", build_options);
|
platform_mod.addOptions("build_options", build_options);
|
||||||
|
|
||||||
exe_mod.addImport("embedded_assets", try createEmbeddedAssets(b, assets_dir, &asset_files));
|
platform_mod.addImport("embedded_assets", try createEmbeddedAssets(b, assets_dir, &asset_files));
|
||||||
|
|
||||||
const math_mod = b.createModule(.{
|
const math_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/platform/math.zig")
|
.root_source_file = b.path("src/platform/math.zig")
|
||||||
});
|
});
|
||||||
exe_mod.addImport("math", math_mod);
|
platform_mod.addImport("math", math_mod);
|
||||||
|
|
||||||
const dep_tiled = b.dependency("tiled", .{});
|
|
||||||
exe_mod.addImport("tiled", dep_tiled.module("tiled"));
|
|
||||||
|
|
||||||
const dep_sokol = b.dependency("sokol", .{
|
const dep_sokol = b.dependency("sokol", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
@ -55,8 +64,8 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.with_sokol_imgui = has_imgui
|
.with_sokol_imgui = has_imgui
|
||||||
});
|
});
|
||||||
const mod_sokol = dep_sokol.module("sokol");
|
const mod_sokol = dep_sokol.module("sokol");
|
||||||
exe_mod.linkLibrary(dep_sokol.artifact("sokol_clib"));
|
platform_mod.linkLibrary(dep_sokol.artifact("sokol_clib"));
|
||||||
exe_mod.addImport("sokol", mod_sokol);
|
platform_mod.addImport("sokol", mod_sokol);
|
||||||
|
|
||||||
const dep_shdc = dep_sokol.builder.dependency("shdc", .{});
|
const dep_shdc = dep_sokol.builder.dependency("shdc", .{});
|
||||||
|
|
||||||
@ -76,7 +85,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.slang = slang
|
.slang = slang
|
||||||
});
|
});
|
||||||
mod_shader.addImport("math", math_mod);
|
mod_shader.addImport("math", math_mod);
|
||||||
exe_mod.addImport("shader", mod_shader);
|
platform_mod.addImport("shader", mod_shader);
|
||||||
|
|
||||||
if (has_imgui) {
|
if (has_imgui) {
|
||||||
if (b.lazyDependency("cimgui", .{
|
if (b.lazyDependency("cimgui", .{
|
||||||
@ -85,16 +94,13 @@ pub fn build(b: *std.Build) !void {
|
|||||||
})) |dep_cimgui| {
|
})) |dep_cimgui| {
|
||||||
const cimgui = b.lazyImport(@This(), "cimgui").?;
|
const cimgui = b.lazyImport(@This(), "cimgui").?;
|
||||||
const cimgui_conf = cimgui.getConfig(true);
|
const cimgui_conf = cimgui.getConfig(true);
|
||||||
exe_mod.addImport("cimgui", dep_cimgui.module(cimgui_conf.module_name));
|
platform_mod.addImport("cimgui", dep_cimgui.module(cimgui_conf.module_name));
|
||||||
dep_sokol.artifact("sokol_clib").root_module.addIncludePath(dep_cimgui.path(cimgui_conf.include_dir));
|
dep_sokol.artifact("sokol_clib").root_module.addIncludePath(dep_cimgui.path(cimgui_conf.include_dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dep_stb = b.dependency("stb", .{});
|
platform_mod.addImport("stb_vorbis", dep_stb.module("stb_vorbis"));
|
||||||
exe_mod.addImport("stb_image", dep_stb.module("stb_image"));
|
platform_mod.addImport("stb_rect_pack", dep_stb.module("stb_rect_pack"));
|
||||||
exe_mod.addImport("stb_vorbis", dep_stb.module("stb_vorbis"));
|
|
||||||
exe_mod.addImport("stb_rect_pack", dep_stb.module("stb_rect_pack"));
|
|
||||||
exe_mod.addImport("stb_truetype", dep_stb.module("stb_truetype"));
|
|
||||||
|
|
||||||
const dep_tracy = b.dependency("tracy", .{
|
const dep_tracy = b.dependency("tracy", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
@ -103,9 +109,11 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.tracy_only_localhost = true
|
.tracy_only_localhost = true
|
||||||
});
|
});
|
||||||
if (has_tracy) {
|
if (has_tracy) {
|
||||||
exe_mod.linkLibrary(dep_tracy.artifact("tracy"));
|
platform_mod.linkLibrary(dep_tracy.artifact("tracy"));
|
||||||
}
|
}
|
||||||
exe_mod.addImport("tracy", dep_tracy.module("tracy"));
|
platform_mod.addImport("tracy", dep_tracy.module("tracy"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var run_cmd_step: *std.Build.Step = undefined;
|
var run_cmd_step: *std.Build.Step = undefined;
|
||||||
if (is_wasm) {
|
if (is_wasm) {
|
||||||
@ -113,17 +121,18 @@ pub fn build(b: *std.Build) !void {
|
|||||||
@panic("TODO: test in 0.17");
|
@panic("TODO: test in 0.17");
|
||||||
}
|
}
|
||||||
|
|
||||||
const build_step = buildWasm(b, .{
|
// TODO:
|
||||||
.name = "index",
|
// const build_step = buildWasm(b, .{
|
||||||
.root_module = exe_mod,
|
// .name = "index",
|
||||||
.dep_sokol = dep_sokol,
|
// .root_module = exe_mod,
|
||||||
});
|
// .dep_sokol = dep_sokol,
|
||||||
b.getInstallStep().dependOn(build_step);
|
// });
|
||||||
|
// b.getInstallStep().dependOn(build_step);
|
||||||
const dep_emsdk = dep_sokol.builder.dependency("emsdk", .{});
|
//
|
||||||
const emrun_step = sokol.emRunStep(b, .{ .name = "index", .emsdk = dep_emsdk });
|
// const dep_emsdk = dep_sokol.builder.dependency("emsdk", .{});
|
||||||
emrun_step.step.dependOn(build_step);
|
// const emrun_step = sokol.emRunStep(b, .{ .name = "index", .emsdk = dep_emsdk });
|
||||||
run_cmd_step = &emrun_step.step;
|
// emrun_step.step.dependOn(build_step);
|
||||||
|
// run_cmd_step = &emrun_step.step;
|
||||||
|
|
||||||
// TODO: Create a zip archive of all of the files. Would be useful for easier itch.io upload
|
// TODO: Create a zip archive of all of the files. Would be useful for easier itch.io upload
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
.minimum_zig_version = "0.16.0",
|
.minimum_zig_version = "0.16.0",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.sokol = .{
|
.sokol = .{
|
||||||
.url = "git+https://github.com/floooh/sokol-zig.git#ba97ac4e82e36a0f6c62f7fad5dc9c2d82beadd8",
|
.url = "git+https://github.com/floooh/sokol-zig.git#d4adaef70dd68d2ca8e8c3b6a392ab455181ab4a",
|
||||||
.hash = "sokol-0.1.0-pb1HK4prNwDGx2RJFyv7VtYJubDahi19XKioPzPeMCxv",
|
.hash = "sokol-0.1.0-pb1HK0EaQQDC6r1jTWJbUWiXbjxfpWuWEK3tz0z4K1aY",
|
||||||
},
|
},
|
||||||
.stb = .{
|
.stb = .{
|
||||||
.path = "./libs/stb",
|
.path = "./libs/stb",
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const STBImage = @import("stb_image");
|
|||||||
const STBTrueType = @import("stb_truetype");
|
const STBTrueType = @import("stb_truetype");
|
||||||
const Tiled = @import("tiled");
|
const Tiled = @import("tiled");
|
||||||
|
|
||||||
const Platform = @import("platform/root.zig");
|
const Platform = @import("platform");
|
||||||
const Gfx = Platform.Gfx;
|
const Gfx = Platform.Gfx;
|
||||||
const Vec2 = Platform.Vec2;
|
const Vec2 = Platform.Vec2;
|
||||||
const Audio = Platform.Audio;
|
const Audio = Platform.Audio;
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
const Math = @import("math");
|
const Platform = @import("platform");
|
||||||
const Vec2 = Math.Vec2;
|
|
||||||
|
|
||||||
const Platform = @import("platform/root.zig");
|
|
||||||
const Gfx = Platform.Gfx;
|
const Gfx = Platform.Gfx;
|
||||||
const Color = Platform.Color;
|
const Color = Platform.Color;
|
||||||
|
|
||||||
|
const Vec2 = Platform.Math.Vec2;
|
||||||
|
|
||||||
const Canvas = @This();
|
const Canvas = @This();
|
||||||
|
|
||||||
size: Vec2,
|
size: Vec2,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const Io = std.Io;
|
const Io = std.Io;
|
||||||
|
|
||||||
const Platform = @import("platform/root.zig");
|
const Platform = @import("platform");
|
||||||
const Gfx = Platform.Gfx;
|
const Gfx = Platform.Gfx;
|
||||||
const SlotMapType = Platform.SlotMapType;
|
const SlotMapType = Platform.SlotMapType;
|
||||||
const Vec2 = Platform.Vec2;
|
const Vec2 = Platform.Vec2;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
const Platform = @import("platform/root.zig");
|
const Platform = @import("platform");
|
||||||
const App = @import("app.zig");
|
const App = @import("app.zig");
|
||||||
|
|
||||||
pub const std_options: std.Options = .{
|
pub const std_options: std.Options = .{
|
||||||
@ -21,5 +21,5 @@ pub fn main(init: std.process.Init) void {
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
std.testing.refAllDecls(@This());
|
std.testing.refAllDecls(@This());
|
||||||
_ = @import("./platform/slot_map.zig");
|
_ = Platform;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ const Mat4 = Math.Mat4;
|
|||||||
const Rect = Math.Rect;
|
const Rect = Math.Rect;
|
||||||
|
|
||||||
const STBRectPack = @import("stb_rect_pack");
|
const STBRectPack = @import("stb_rect_pack");
|
||||||
const STBTrueType = @import("stb_truetype");
|
|
||||||
const ImGUI = @import("imgui.zig");
|
const ImGUI = @import("imgui.zig");
|
||||||
pub const Color = @import("./color.zig");
|
pub const Color = @import("./color.zig");
|
||||||
const shd = @import("shader");
|
const shd = @import("shader");
|
||||||
@ -126,7 +125,7 @@ pub fn init(gpa: std.mem.Allocator, logger: sg.Logger) !void {
|
|||||||
|
|
||||||
bindings.vertex_buffers[0] = sg.makeBuffer(.{
|
bindings.vertex_buffers[0] = sg.makeBuffer(.{
|
||||||
.size = @sizeOf(VertexQuad) * max_quads,
|
.size = @sizeOf(VertexQuad) * max_quads,
|
||||||
.usage = .{ .vertex_buffer = true, .stream_update = true },
|
.usage = .{ .vertex_buffer = true, .dynamic_update = true },
|
||||||
.label = "quad-vertices"
|
.label = "quad-vertices"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ const std = @import("std");
|
|||||||
const log = std.log.scoped(.app);
|
const log = std.log.scoped(.app);
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
const Platform = @import("platform/root.zig");
|
const Platform = @import("platform");
|
||||||
const Gfx = Platform.Gfx;
|
const Gfx = Platform.Gfx;
|
||||||
const Vec2 = Platform.Vec2;
|
const Vec2 = Platform.Vec2;
|
||||||
const Rect = Platform.Rect;
|
const Rect = Platform.Rect;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user