google / bazel_rules_install

Bazel rules for installing build results. Similar to `make install`.
Apache License 2.0
37 stars 14 forks source link

Alias target not installed. Expected to be symbolic link or copy depending on platform #28

Open hzeller opened 4 years ago

hzeller commented 4 years ago

An alias rule https://docs.bazel.build/versions/3.2.0/be/general.html#alias gives a different name to an existing thing.

I'd like to use this in verible to phase out legacy binary names and move them to new names (to implement https://github.com/google/verible/issues/169 ).

But simply declaring this in bazel:

alias(
   name = "old_binary_name",
   actual = ":new_binary_name"
)

and then using the old_binary_name alias name in an bazel_rules_install installer() target will not install anything (but will also not complain); I suppose because the alias is actually just an internal name within bazel, but actually never shows up as tangible object.

For installation: My proposal would be to interpret the alias information and create either a symbolic link or a copy, depending on the installation platform.

(Of course, I could implement the legacy-names with a little shell-script which then exec's the new location etc., but it would be less platform agnostic. Using 'alias' is the exact abstraction that conveys the intent much better and the install target can use the additional context to do the right thing on the target platform - symbolic link or copy)

hzeller commented 4 years ago

So I implemented this now in the project in question by installing shell-scripts that call the original binary.

It might still be worthwhile exploring if the semantic of an 'alias' would be something good to implement, or if this is too specific. So I am fine either way.