Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ fn addStartPoint(
) *std.Build.Step {
const exe = b.addExecutable(.{
.name = name,
.root_source_file = b.path(path),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path(path),
.target = target,
.optimize = optimize,
}),
});

exe.root_module.addImport("zigplotlib", module);
Expand Down Expand Up @@ -64,16 +66,19 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const lib = b.addStaticLibrary(.{
const lib = b.addLibrary(.{
.name = "zigplotlib",
.linkage = .static,
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
}),
});

const lib_module = &lib.root_module;
const lib_module = lib.root_module;

_ = b.addModule("zigplotlib", .{
.root_source_file = b.path("src/root.zig"),
Expand Down Expand Up @@ -106,17 +111,21 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);

const exe_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});

const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
Expand Down
5 changes: 3 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.{
.name = "zigplotlib",
.name = .zigplotlib,
.version = "0.1.4",
.minimum_zig_version = "0.13.0",
.fingerprint = 0x1220c9f9d7b4cb25,
.minimum_zig_version = "0.15.2",
.dependencies = .{},

.paths = .{
Expand Down
8 changes: 6 additions & 2 deletions example/area.zig
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ pub fn main() !void {
var file = try std.fs.cwd().createFile("example/out/area.svg", .{});
defer file.close();

try svg.writeTo(file.writer());
}
var file_buffer: [1024]u8 = undefined;
var file_writer = file.writer(&file_buffer);
const file_int = &file_writer.interface;

try svg.writeTo(file_int);
}
6 changes: 5 additions & 1 deletion example/candle_stick.zig
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,9 @@ pub fn main() !void {
var file = try std.fs.cwd().createFile("example/out/candlestick.svg", .{});
defer file.close();

try svg.writeTo(file.writer());
var file_buffer: [1024]u8 = undefined;
var file_writer = file.writer(&file_buffer);
const file_int = &file_writer.interface;

try svg.writeTo(file_int);
}
6 changes: 5 additions & 1 deletion example/line.zig
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ pub fn main() !void {
var file = try std.fs.cwd().createFile("example/out/line.svg", .{});
defer file.close();

try svg.writeTo(file.writer());
var file_buffer: [1024]u8 = undefined;
var file_writer = file.writer(&file_buffer);
const file_int = &file_writer.interface;

try svg.writeTo(file_int);
}
6 changes: 5 additions & 1 deletion example/logarithmic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ pub fn main() !void {
var file = try std.fs.cwd().createFile("example/out/logarithmic.svg", .{});
defer file.close();

try svg.writeTo(file.writer());
var file_buffer: [1024]u8 = undefined;
var file_writer = file.writer(&file_buffer);
const file_int = &file_writer.interface;

try svg.writeTo(file_int);
}
4 changes: 2 additions & 2 deletions example/out/area.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions example/out/candlestick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading