-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples/build.zig needs update #22
Comments
this appears to work for anyone interested. |
Formatted mine to this ( zig version: 0.12.0-dev.414+461036069), just to test the examples after building everything from respective source first. const builtin = @import("builtin");
const std = @import("std");
const Builder = std.build.Builder;
const Step = std.build.Step;
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *Builder) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const win32 = b.createModule(.{
.source_file = .{ .path = "zigwin32/win32.zig" },
});
try addExample(b, target, optimize, win32, "helloworld", .Console);
try addExample(b, target, optimize, win32, "wasapi", .Console);
try addExample(b, target, optimize, win32, "net", .Console);
try addExample(b, target, optimize, win32, "helloworld-window", .Windows);
try addExample(b, target, optimize, win32, "d2dcircle", .Windows);
try addExample(b, target, optimize, win32, "opendialog", .Windows);
}
fn concat(b: *Builder, slices: []const []const u8) []u8 {
return std.mem.concat(b.allocator, u8, slices) catch unreachable;
}
fn addExample(
b: *Builder,
target: CrossTarget,
optimize: std.builtin.Mode,
win32: *std.Build.Module,
root: []const u8,
subsystem: std.Target.SubSystem,
) !void {
const basename = concat(b, &.{ root, ".zig" });
const exe = b.addExecutable(.{
.name = root,
.root_source_file = .{ .path = b.pathJoin(&.{ "examples", basename }) },
.target = target,
.optimize = optimize,
});
exe.subsystem = subsystem;
if (subsystem == .Console) {
exe.single_threaded = true;
}
exe.addModule("win32", win32);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am a zig noob so not entirely sure, but I believe this file needs to be updated for the new zig version in order to be able to build the examples properly
The text was updated successfully, but these errors were encountered: