Skip to content

Optional "lib" prefixes on build.zig #10956

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

Closed
lun-4 opened this issue Feb 21, 2022 · 2 comments
Closed

Optional "lib" prefixes on build.zig #10956

lun-4 opened this issue Feb 21, 2022 · 2 comments

Comments

@lun-4
Copy link
Contributor

lun-4 commented Feb 21, 2022

The title is self-explanatory, but here's the real world use cases that led me to opening the issue:

  • LÖVR's plugin loader does not account for lib prefixes by default, so I have to write require "libsomething" rather than require "something", even though the latter is the "practical default" across the lua ecosystem of native libraries.
  • Counter-Strike 1.6 server plugins are also not using the lib prefix, requiring your configuration file to needlessly add it.
  • PAM uses a different prefix entirely: pam_ (see /lib/security)

This can be done without a direct build.zig enhancement, as seen here, but I think we could add this as a configuration parameter since it's a common thing to do.

I don't know which would be the most ergonomic way to set a different prefix inside the build script, my suggestion is some setLibPrefix(prefix: []const u8). Here's an example:

    const lib = b.addSharedLibrary("rtsp", "src/main.zig", b.version(0, 0, 1));
    lib.setTarget(target);
    lib.setBuildMode(mode);
    lib.setLibPrefix("");
    lib.install();

Or, for a PAM library:

    const lib = b.addSharedLibrary("seven_factor_authentication", "src/main.zig", b.version(0, 0, 1));
    lib.setTarget(target);
    lib.setBuildMode(mode);
    lib.setLibPrefix("pam_");
    lib.install();
@daurnimator
Copy link
Contributor

Duplicate of #2231 ?

@lun-4
Copy link
Contributor Author

lun-4 commented Mar 11, 2022

Oops, it is.

@lun-4 lun-4 closed this as completed Mar 11, 2022
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

No branches or pull requests

2 participants