replace module() helper; remove invalid re-exports;
Fixes hexops/mach#1041 Helps hexops/mach#1038 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
2615afaaed
commit
4e091f1cb8
3 changed files with 65 additions and 50 deletions
98
build.zig
98
build.zig
|
|
@ -6,48 +6,48 @@ const core = @import("mach_core");
|
|||
|
||||
var _module: ?*std.build.Module = null;
|
||||
|
||||
pub fn module(b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget) *std.build.Module {
|
||||
if (_module) |m| return m;
|
||||
|
||||
const mach_core = b.dependency("mach_core", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_sysaudio = b.dependency("mach_sysaudio", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_ecs = b.dependency("mach_ecs", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_basisu = b.dependency("mach_basisu", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_freetype = b.dependency("mach_freetype", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
_module = b.createModule(.{
|
||||
.source_file = .{ .path = sdkPath("/src/main.zig") },
|
||||
.dependencies = &.{
|
||||
.{ .name = "mach-core", .module = core.module(mach_core.builder, optimize, target) },
|
||||
.{ .name = "mach-ecs", .module = mach_ecs.module("mach-ecs") },
|
||||
.{ .name = "mach-sysaudio", .module = sysaudio.module(mach_sysaudio.builder, optimize, target) },
|
||||
.{ .name = "mach-basisu", .module = mach_basisu.module("mach-basisu") },
|
||||
.{ .name = "mach-freetype", .module = mach_freetype.module("mach-freetype") },
|
||||
.{ .name = "mach-harfbuzz", .module = mach_freetype.module("mach-harfbuzz") },
|
||||
},
|
||||
});
|
||||
return _module.?;
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
||||
const mach_core_dep = b.dependency("mach_core", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_sysaudio_dep = b.dependency("mach_sysaudio", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_ecs_dep = b.dependency("mach_ecs", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_basisu_dep = b.dependency("mach_basisu", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_freetype_dep = b.dependency("mach_freetype", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const mach_sysjs_dep = b.dependency("mach_sysjs", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const module = b.addModule("mach", .{
|
||||
.source_file = .{ .path = sdkPath("/src/main.zig") },
|
||||
.dependencies = &.{
|
||||
.{ .name = "mach-core", .module = mach_core_dep.module("mach-core") },
|
||||
.{ .name = "mach-ecs", .module = mach_ecs_dep.module("mach-ecs") },
|
||||
.{ .name = "mach-sysaudio", .module = mach_sysaudio_dep.module("mach-sysaudio") },
|
||||
.{ .name = "mach-basisu", .module = mach_basisu_dep.module("mach-basisu") },
|
||||
.{ .name = "mach-freetype", .module = mach_freetype_dep.module("mach-freetype") },
|
||||
.{ .name = "mach-harfbuzz", .module = mach_freetype_dep.module("mach-harfbuzz") },
|
||||
.{ .name = "mach-sysjs", .module = mach_sysjs_dep.module("mach-sysjs") },
|
||||
},
|
||||
});
|
||||
|
||||
if (target.getCpuArch() != .wasm32) {
|
||||
// Creates a step for unit testing. This only builds the test executable
|
||||
// but does not run it.
|
||||
|
|
@ -56,7 +56,7 @@ pub fn build(b: *std.Build) !void {
|
|||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
var iter = module(b, optimize, target).dependencies.iterator();
|
||||
var iter = module.dependencies.iterator();
|
||||
while (iter.next()) |e| {
|
||||
unit_tests.addModule(e.key_ptr.*, e.value_ptr.*);
|
||||
}
|
||||
|
|
@ -66,6 +66,14 @@ pub fn build(b: *std.Build) !void {
|
|||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_unit_tests.step);
|
||||
|
||||
const install_docs = b.addInstallDirectory(.{
|
||||
.source_dir = unit_tests.getEmittedDocs(),
|
||||
.install_dir = .prefix, // default build output prefix, ./zig-out
|
||||
.install_subdir = "docs",
|
||||
});
|
||||
const docs_step = b.step("docs", "Generate API docs");
|
||||
docs_step.dependOn(&install_docs.step);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,20 +99,26 @@ pub const App = struct {
|
|||
res_dirs: ?[]const []const u8 = null,
|
||||
watch_paths: ?[]const []const u8 = null,
|
||||
mach_builder: ?*std.Build = null,
|
||||
mach_mod: ?*std.build.Module = null,
|
||||
},
|
||||
) !App {
|
||||
const mach_builder = options.mach_builder orelse app_builder.dependency("mach", .{
|
||||
.target = options.target,
|
||||
.optimize = options.optimize,
|
||||
}).builder;
|
||||
const mach_mod = options.mach_mod orelse app_builder.dependency("mach", .{
|
||||
.target = options.target,
|
||||
.optimize = options.optimize,
|
||||
}).module("mach");
|
||||
|
||||
var deps = std.ArrayList(std.build.ModuleDependency).init(app_builder.allocator);
|
||||
if (options.deps) |v| try deps.appendSlice(v);
|
||||
try deps.append(.{ .name = "mach", .module = module(mach_builder, options.optimize, options.target) });
|
||||
const mach_sysaudio = mach_builder.dependency("mach_sysaudio", .{
|
||||
try deps.append(.{ .name = "mach", .module = mach_mod });
|
||||
const mach_sysaudio_dep = mach_builder.dependency("mach_sysaudio", .{
|
||||
.target = options.target,
|
||||
.optimize = options.optimize,
|
||||
});
|
||||
try deps.append(.{ .name = "sysaudio", .module = sysaudio.module(mach_sysaudio.builder, options.optimize, options.target) });
|
||||
try deps.append(.{ .name = "mach-sysaudio", .module = mach_sysaudio_dep.module("mach-sysaudio") });
|
||||
|
||||
const mach_core = mach_builder.dependency("mach_core", .{
|
||||
.target = options.target,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue