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

update build.zig for zig 0.12.0-dev.3635+786876c05 #1

Merged

Conversation

tazend
Copy link
Contributor

@tazend tazend commented Apr 14, 2024

Hi,

first off: thanks for this library, tried it out in one of my projects and it works pretty nice.

I'm using pretty much the latest zig on my project right now (zig 0.12.0-dev.3635+786876c05), and there were some errors while building.

  1. Passing target to the buildExamples function which requires a std.zig.CrossTarget type doesn't work (anymore). It throws this error:
expected type 'Target.Query', found 'Build.ResolvedTarget'

Instead I just changed it to require std.Build.ResolvedTarget. Not really sure if this is the right way, but it builds.

  1. Make the "prettytable" module available for other projects to import as a dependency.

Without this:

const module = b.addModule("prettytable", .{
    .root_source_file = .{ .path = "src/lib.zig" },
});

it is not possible to import prettytable inside of other projects depending on it. It worked for the examples because there it was added as a private module to them (createModule only creates a private module). With the lines above however, importing it in external projects works.
Additionally, this can just be passed on to the buildExamples function and used as module for the examples, removing the need to call createModule again.

  1. Other than the above, just a few things that weren't needed anymore have been removed, like FileSource (which was recently renamed to LazyPath in zig), Builder and CrossTarget

- remove unused variables
- Passing "target" as "CrossTarget" to the buildExamples function throws
  an error expecting a different type, simply pass it as the resolved
  target.
- make the "prettytable" module available for other projects to import
  as a dependency. Without "b.addModule('prettytable')...", it isn't
  possible to import it. Also simply pass this module then on to the
  buildExample function, so the tests can also use it, without needing
  to call createModule again.
@Hanaasagi
Copy link
Member

Thank you for this. I appreciate your taking the time to explain the changes in the recent Zig version.

@Hanaasagi Hanaasagi merged commit 1cdfca7 into dying-will-bullet:master Apr 22, 2024
1 check passed
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.

2 participants