RFC: Link configuration

The beginning of this thread was about having a configuration file for the linked options, that instead of been computed directly, could be generated if missing. Allowing the user to override it.

That’s part of my problem and I think it’s related to this discussion.

  1. I have a shard.
  2. The shard itself has a preference for custom link options of using it’s own library when the system installed version is old or unavailable.
  3. The shard will be used by other shards or applications.
  4. The person compiling the final application should be able to override the link options.
  5. crystal specs should work in the shard itself or any applications requiring the shard without Makefiles, wrappers, or any additional work.

It doesn’t seem like there’s a standard way to do this or even hooks to do this like in other languages unless I missed them.

I’m 90% of the way there using:
@[Link(ldflags: "``./build/pkg-libs.sh``")]

In my case link flags are determined by a possible local installed library. Based on the solutions above whether using link overrides on the command line or configuration files it seems like my code will break. I hope whatever solution you come up with takes this in to account. (Not my particular method but a design that is flexible enough to accommodate conditional library installations)

Now my problem is crystal spec changing directories on me. I don’t suppose there’s a simple way to get the project directory before cd?

I have a solution for the directory problem. It’s not pretty but it works.

@[Link(ldflags: "`#{__DIR__}/../../build/pkg-libs.sh #{__DIR__}/../..`")]