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

Add platform folders which contain the config.h files to build.zig.zon #13

Open
wants to merge 1 commit into
base: v1.0.26-zig
Choose a base branch
from

Conversation

stephan-wenninger
Copy link

This PR adds the platform dependent folders "Xcode", "android", "msvc" to the build.zig.zon 'paths' variable.

Otherwise, when using

zig fetch --save git+https://github.com/allyourcodebase/libusb#d9bc1457b0d3cc5c39a4dc845d6974f52dac2dea (current master commit),

and then linking the libusb library to your own executable via

    const libusb = b.dependency("libusb", .{.target = target, .optimize = optimize});
    exe.linkLibrary(libusb.artifact("usb"));

the build fails with:

error: 'config.h' file not found
#include <config.h>

because the zig package manager only copies the files and folders referenced in the package's paths definition in build.zig.zon.
The paths currently do not contain these folders needed for compiling the library on e.g. MacOS.

By adding the mentionend folders, compilation should succeed on all platforms, because the config.h can now be found.

The relevant lines in the build.zig file:

libusb/build.zig

Lines 80 to 90 in d9bc145

// config header
if (target.result.isDarwin()) {
lib.addIncludePath(b.path("Xcode"));
} else if (target.result.abi == .msvc) {
lib.addIncludePath(b.path("msvc"));
} else if (target.result.abi == .android) {
lib.addIncludePath(b.path("android"));
} else {
const config_h = b.addConfigHeader(.{ .style = .{
.autoconf = b.path("config.h.in"),
} }, .{

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.

1 participant