Skip to content

build: linkSystemLibrary should abstract over multiple sources of libraries #3671

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

Open
Sahnvour opened this issue Nov 12, 2019 · 1 comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@Sahnvour
Copy link
Contributor

Following #3447

This comes from the fact that on Windows, we may want to use libraries obtained through vcpkg or conan for example. We can also imagine a daemon to help the user find a manually installed lib.

Citing @andrewrk

The use case we are trying to solve right now is to have a build script API that helps applications link against system libraries, on all platforms. Given that this is the goal, and that linking against a system library may want to take advantage of vcpkg on Windows, I think that we may need to make the linkSystemLibrary API a bit more complicated, in order to gain the ability to fully specify what library the application wants to link against, by allowing the build script to specify multiple names.

artifact.linkSystemLibrary2(.{
    .so_name = "gdk-3",
    .pkgconf_name = "gdk-3.0",
    .vcpkg_name = "gdk",
});

These fields would all default to null and potentially have heuristics for guessing names of other things based on each other. In the status quo API, it's essentially so_name that is the parameter to linkSystemLibrary and the pkgconf_name is guessed based on heuristics.

@Sahnvour Sahnvour added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Nov 12, 2019
@Sahnvour Sahnvour added this to the 0.6.0 milestone Nov 12, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Mar 31, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@nektro
Copy link
Contributor

nektro commented Nov 29, 2020

the upcoming release of https://github.com/nektro/zigmod solves this. example zig.mod

name: my-app
main: src/main.zig
dependencies:
- type: system_lib
  path: gdk
  only_os: windows
- type: system_lib
  path: gdk-3
  except_os: windows

this would then use the already existing linkSystemLibrary function to link gdk when on Windows and gdk-3 otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

3 participants