From f43e53e018b6f90b06e8b7eadb26c30fbfcf0528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20C=2E=20Fran=C3=A7a?= Date: Sun, 23 Apr 2023 15:08:04 -0300 Subject: [PATCH] zig build --- .gitignore | 3 +++ build.zig | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ build.zig.zon | 6 +++++ 3 files changed, 75 insertions(+) create mode 100644 build.zig create mode 100644 build.zig.zon diff --git a/.gitignore b/.gitignore index 2b860a04..4124b881 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ cmake !cmake/i686-toolchain.cmake .vscode + +zig-cache/ +zig-out/ \ No newline at end of file diff --git a/build.zig b/build.zig new file mode 100644 index 00000000..0b974a8f --- /dev/null +++ b/build.zig @@ -0,0 +1,66 @@ +const std = @import("std"); + +// Although this function looks imperative, note that its job is to +// declaratively construct a build graph that will be libcuted by an external +// runner. +pub fn build(b: *std.Build) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard optimization options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not + // set a preferred release mode, allowing the user to decide how to optimize. + const optimize = b.standardOptimizeOption(.{}); + + const shared = b.option(bool, "Shared", "Build the Shared Library [default: false]") orelse false; + + const lib = if (shared) b.addSharedLibrary(.{ + .name = "xlsxwriter", + .target = target, + .optimize = optimize, + .version = .{ + .major = 1, + .minor = 1, + .patch = 6, + }, + }) else b.addStaticLibrary(.{ + .name = "xlsxwriter", + .target = target, + .optimize = optimize, + }); + lib.addCSourceFiles(&.{ + "src/vml.c", + "src/chartsheet.c", + "src/theme.c", + "src/content_types.c", + "src/xmlwriter.c", + "src/app.c", + "src/styles.c", + "src/core.c", + "src/comment.c", + "src/utility.c", + "src/metadata.c", + "src/custom.c", + "src/hash_table.c", + "src/relationships.c", + "src/drawing.c", + "src/chart.c", + "src/shared_strings.c", + "src/worksheet.c", + "src/format.c", + "src/table.c", + "src/workbook.c", + "src/packager.c", + }, &.{ + "-Wall", + "-Wextra", + }); + lib.addIncludePath("include"); + lib.addIncludePath("third_party"); + lib.linkLibC(); + lib.installHeadersDirectory("include", ""); + b.installArtifact(lib); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 00000000..0e7fced8 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,6 @@ +.{ + .name = "libxlsxwriter", + .version = "1.1.6", + .dependencies = .{}, +} +//syntax tip: zig - anon struct (json-like)