install prefix: indicate relative value with "./" (#36)

Unfortunately, the prefix is never relative.
If the relative value is passed, current directory is used as base,
and the real prefix is $(pwd)/<relative-prefix>
However, keep any value, passed by user, as finally outside the build that value can be used.
This commit is contained in:
irengrig 2018-08-20 15:56:35 +02:00 committed by GitHub
parent 6a0af905db
commit 8989362236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -42,10 +42,15 @@ def _cmake_external(ctx):
def _get_install_prefix(ctx):
if ctx.attr.install_prefix:
return ctx.attr.install_prefix
prefix = ctx.attr.install_prefix
# If not in sandbox, or after the build, the value can be absolute.
# So if the user passed the absolute value, do not touch it.
if (prefix.startswith("/")):
return prefix
return prefix if prefix.startswith("./") else "./" + prefix
if ctx.attr.lib_name:
return ctx.attr.lib_name
return ctx.attr.name
return "./" + ctx.attr.lib_name
return "./" + ctx.attr.name
def _get_toolchain_variables(ctx, tools, flags):
vars = {}