I have a following rule in WORKSPACE:
new_local_repository(
name = "llvm",
path = "/opt/local/libexec/llvm-4.0",
build_file= "llvm.BUILD")
I would like to now use hardcoded path for llvm. llvm-config --prefix
can give me the directory for llvm. What is the correct way to get this? Can I just use standard python commands (e.g. subprocess
package)?
You can create a custom repository_rule, in which you can call
repository_ctx.execute("llvm-config --prefix")
in and make that value available in your package.I'd suggest you first read about
repository_rule
and if anything is not clear, do not hesitate to ask.As @abergmeier said, you can create a custom repository rule, run the command, create a symlink pointing to its output, and create a BUILD file for the repository:
WORKSPACE file:
foo/repo.bzl:
Targets in the repo:
Generated files: