Skip to content
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

Zig package #400

Merged
merged 2 commits into from
May 12, 2023
Merged

Zig package #400

merged 2 commits into from
May 12, 2023

Conversation

kassane
Copy link
Contributor

@kassane kassane commented Apr 23, 2023

closes #401

How to use

e.g:

  • build.zig
    const libxlsxwriter_dep = b.dependency("libxlsxwriter", .{ // <== as declared in build.zig.zon
        .target = target, // the same as passing `-Dtarget=<...>` to the library's build.zig script
        .optimize = optimize, // ditto for `-Doptimize=<...>`
    });
    const libxlsxwriter = libxlsxwriter_dep.artifact("xlsxwriter"); // <== has the location of the dependency files (libxlsxwriter)
    /// your executable config
    exe.linkLibrary(libxlsxwriter); // <== link libxlsxwriter
    exe.installLibraryHeaders(libxlsxwriter); // <== get copy libxlsxwriter headers to zig-out/include 
  • build.zig.zon
.{
    .name = "example",
    .version = "0.1.0",
    .dependencies = .{
        .libxlsxwriter = .{
            .url = "https://github.com/jmcnamara/libxlsxwriter/archive/[tag/commit-hash].tar.gz",
            .hash = "[multihash - sha256-2]",
        },
    },
}

More info about zig-pkg

@jmcnamara
Copy link
Owner

How would a zig developer use this to build a zig compatible library?

@kassane
Copy link
Contributor Author

kassane commented Apr 29, 2023

How would a zig developer use this to build a zig compatible library?

Hi, @jmcnamara

Using that build the developers could choose to create a binding on top of the original library or access the library directly.

In other words, do you remember the binding built by me? zig-xlsxwriter

Well, with this change, not only could that project benefit from the library addition be downloaded, build and run with the included binding (another project) or also, users can bypass my binding and use the library directly with @cImport/@cInclude (zig translate-c inside) to auto-generate a binding, regardless of the user-binding project that me or any other developers.

more info:
https://ziglang.org/documentation/master/#cImport-vs-translate-c

@kassane
Copy link
Contributor Author

kassane commented Apr 29, 2023

Pointer 2

Using zig toolchain does not exactly mean that need to create a ziglang project, could replace the makefile, cmake, or any other conventional tool with zig.
zig toolchain is pure-LLVM buildtools (replaces: build-essential/base-devel - does not include dbgs or binutils).

@jmcnamara
Copy link
Owner

jmcnamara commented May 12, 2023

In general I'd prefer not to add this type of configuration to the root directory. I made an exception for iOS and now there are too many Coacoa and other related files as well as several PRs.

I prefer the VPG and Homebrew approaches where the package updates are in an external repository, like this: https://vcpkg.roundtrip.dev/ports/libxlsxwriter

However, I like Zig as a language and would like to support it so if you agree to support the library additions and make any fixes that are required in the future then I will merge it.

@kassane
Copy link
Contributor Author

kassane commented May 12, 2023

OK!
I will even complete support for zlib and minizip dependencies. (Optional install)

@jmcnamara jmcnamara merged commit f43e53e into jmcnamara:main May 12, 2023
@jmcnamara
Copy link
Owner

Ok. Merged. Thanks!

@kassane kassane deleted the zig-pkg branch May 12, 2023 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add zig package
2 participants