build: extract example executable from default target
This commit is contained in:
parent
5e3f2e0f91
commit
cf21c48771
13
build.zig
13
build.zig
@ -20,14 +20,17 @@ pub fn build(b: *std.Build) void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
const example_step = b.step("example", "build example");
|
||||
|
||||
const ex_exe = b.addExecutable(.{
|
||||
.name = "yamltest",
|
||||
.root_source_file = .{ .path = "src/main.zig" },
|
||||
.root_source_file = .{ .path = "example/main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
exe.linkLibrary(libyaml);
|
||||
exe.addModule("yaml", yaml_zig);
|
||||
ex_exe.linkLibrary(libyaml);
|
||||
ex_exe.addModule("yaml", yaml_zig);
|
||||
|
||||
b.installArtifact(exe);
|
||||
const install = b.addInstallArtifact(ex_exe, .{});
|
||||
example_step.dependOn(&install.step);
|
||||
}
|
||||
|
@ -7,11 +7,14 @@ pub fn main() !void {
|
||||
defer _ = gpa.deinit();
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
const slurp = try std.fs.cwd().readFileAlloc(
|
||||
const slurp = std.fs.cwd().readFileAlloc(
|
||||
allocator,
|
||||
"test.yaml",
|
||||
1024 * 1024 * 1024,
|
||||
);
|
||||
) catch |err| {
|
||||
std.debug.print("couldn't open test.yaml in the cwd\n", .{});
|
||||
return err;
|
||||
};
|
||||
defer allocator.free(slurp);
|
||||
|
||||
var diag = yaml.ParseDiagnostic{ .message = "?????" };
|
Loading…
x
Reference in New Issue
Block a user