tweag / rules_sh

Shell rules for Bazel
Apache License 2.0
42 stars 3 forks source link

Implement create_shim to create a shim on Windows #26

Closed aherrmann closed 2 years ago

aherrmann commented 2 years ago

Part of https://github.com/tweag/rules_sh/issues/19

The sh_binaries rule can bundle Bazel tracked executable File objects as collections of tools. Tools can be imported into Bazel by download or built by Bazel. However, in some use-cases, users need to import executales that are installed outside of Bazel from the system.

On Unix systems this can be achieved in a hermetic way by creating a symbolic link in a repository rule. However, on Windows, symbolic file links are not generally available and the corresponding repository_ctx method will create a copy. However, file copies do not generally work, as executables may expect auxiliary files next to their installation path.

A shim offers an alternative on Windows. A shim is a small executable, accompanied by a small data file that points to the destination. It can be thought of as a custom executable that imitates the functionality of a symbolic file link.