(There was some earlier discussion on this on the Zig Discord.)
Right now, if a dependency project has multiple artifacts with the same name, you're going to hit this panic:
|
pub fn artifact(d: *Dependency, name: []const u8) *Step.Compile { |
|
var found: ?*Step.Compile = null; |
|
for (d.builder.install_tls.step.dependencies.items) |dep_step| { |
|
const inst = dep_step.cast(Step.InstallArtifact) orelse continue; |
|
if (mem.eql(u8, inst.artifact.name, name)) { |
|
if (found != null) panic("artifact name '{s}' is ambiguous", .{name}); |
|
found = inst.artifact; |
|
} |
|
} |
|
return found orelse { |
|
for (d.builder.install_tls.step.dependencies.items) |dep_step| { |
|
const inst = dep_step.cast(Step.InstallArtifact) orelse continue; |
|
log.info("available artifact: '{s}'", .{inst.artifact.name}); |
|
} |
|
panic("unable to find artifact '{s}'", .{name}); |
|
}; |
|
} |
There are legitimate reasons to have artifacts with the same name. For example, in my case, I'm building both a static and shared library. They have the same name because I want them to end up as libfoo.so and libfoo.a. I think the build system needs some way for dep.artifact("foo") to work in this scenario.
(There was some earlier discussion on this on the Zig Discord.)
Right now, if a dependency project has multiple artifacts with the same name, you're going to hit this panic:
zig/lib/std/Build.zig
Lines 1855 to 1871 in 451550e
There are legitimate reasons to have artifacts with the same name. For example, in my case, I'm building both a static and shared library. They have the same name because I want them to end up as
libfoo.soandlibfoo.a. I think the build system needs some way fordep.artifact("foo")to work in this scenario.