GithubHelp home page GithubHelp logo

Comments (5)

alexrp avatar alexrp commented on August 11, 2024 1

Only partially. Those fields aren't used in all the places you'd hope/expect compared to name. There's also the issue that they include all the target-specific prefixes/suffixes, so you lose quite a bit of abstraction once you start mucking with them.

Another separate but related issue is that if the static library in my scenario has a different name on Windows (to avoid conflicting with the shared library's generated import library), the user of my library has to replicate the logic to pick the artifact name based on whether the target is Windows. Having a separate "artifact name" concept that is distinct from "application/library name" would solve that, too.

from zig.

rohlem avatar rohlem commented on August 11, 2024

They have the same name because I want them to end up as libfoo.so and libfoo.a.

std.Build.Dependency.artifact returns a *std.Build.Step.Compile, which has a field out_filename (and out_lib_filename).
I think you should be able to refer to them as "fooDynamic" and "fooStatic", and then tweak these field values so they are still generated with the name you want.
I hope that helps, not sure if this fully addresses your use case though.

from zig.

BratishkaErik avatar BratishkaErik commented on August 11, 2024

Related: #18513 .

I suggested in Discord to separate creating a module/artifact and exporting it for the package manager in two different calls, which should fix this problem and make a nice simmetry with dep.module("...") and dep.artifact("...") calls in downstream consumers:

const mod = b.createModule(.{
    .root_source_file = b.path("src/main.zig"),
    .target = target,
    .optimize = optimize,
});
mod.expose("main");
// In downstream: b.dependency(...).nodule("main")

const exe = b.addExecutable(.{ .name = "project", ... });
const lib = b.addExecutable(.{ name = "project", ... });
exe.expose("main-exe");
lib.expose("main-lib");
// In downstream: b.dependency(...).artifact(...);

Since this is a rare case, we can make Step.Compile.expose to accept struct instead, with default field = null meaning "take name from the artifact itself", so that for common cases user do not need to repeat name of artifact twice.

from zig.

Lzard avatar Lzard commented on August 11, 2024

Would adding an output_name optional field to addStaticLibrary/addSharedLibrary options and use it to construct the related Step.Compile fields be a good solution to this?

from zig.

alexrp avatar alexrp commented on August 11, 2024

Would adding an output_name optional field to addStaticLibrary/addSharedLibrary options and use it to construct the related Step.Compile fields be a good solution to this?

That was more or less my initial suggestion in the Discord discussion. Having slept on it, though, I'm starting to warm to the idea of having an explicit gesture to "export" an artifact from the build script, just like how marking an artifact for installation is an explicit gesture. It feels more "Zig-y".

from zig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.