Skip to content

Commit

Permalink
improve handling of install directories
Browse files Browse the repository at this point in the history
1. Consider options when constructing values for install directories.
2. Evaluate explicitly-provided values for directories relative to PWD,
   not base directory.
3. Change 2 requires a different implementation of staging-prefix
   handling.
  • Loading branch information
grisumbras authored and grafikrobot committed May 24, 2024
1 parent bf6992b commit 5a51558
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions src/tools/stage.jam
Original file line number Diff line number Diff line change
Expand Up @@ -738,38 +738,67 @@ rule get-dir ( name : property-set : package-name : flags * )
# is based on the value of <target-os> property.
if $(name) = prefix
{
result = [ get-install-prefix $(property-set) : $(package-name)
return [ get-install-prefix $(property-set) : $(package-name)
: $(flags) ] ;
}
else
{
# First, try getting the path for requested directory from properties.
result = [ $(property-set).get <install-$(name)> ] ;
local info = [ get-dir-info $(name) : $(package-name) ] ;
# Otherwise, use the default path. In both cases, it could be a
# relative path.
result ?= $(info[1]) ;
result ?= [ option.get $(name) ] ;
if $(result)
{
result = [ path.make $(result) ] ;
result = [ path.root [ path.make $(result) ] [ path.pwd ] ] ;
}

local info = [ get-dir-info $(name) : $(package-name) ] ;

local base-relative ;
if ! $(result)
{
# Otherwise, use the default path. In both cases, it could be a
# relative path.
result = $(info[1]) ;
result ?= "" ;
base-relative = true ;
}

# If there is a base directory, we may need to modify result further.
if $(info[2])
{
if $(base-relative) && ( relative in $(flags) )
{
return $(result) ;
}

local base = [ get-dir $(info[2]) : $(property-set)
: $(package-name) : $(flags) ] ;
: $(package-name) ] ;
result = [ path.root $(result) $(base) ] ;

if relative in $(flags)
{
local rel = [ path.relative $(result) $(base) : no-error ] ;
if not-a-child != $(rel)
{
result = $(rel) ;
}
return $(result) ;
}
else
}
}

if staged in $(flags)
{
local prefix = [ get-install-prefix $(property-set)
: $(package-name) ] ;
local stage = [ get-install-prefix $(property-set) : $(package-name)
: staged ] ;
if $(prefix) != $(stage)
{
local rel = [ path.relative $(result) $(prefix) : no-error ] ;
if not-a-child != $(rel)
{
result = [ path.root $(result) $(base) ] ;
result = [ path.root $(rel) $(prefix) ] ;
}
}
}
Expand Down Expand Up @@ -817,7 +846,7 @@ local rule get-install-prefix ( property-set : package-name : flags * )
prefix = /usr/local ;
}
}
return [ path.make $(prefix) ] ;
return [ path.root [ path.make $(prefix) ] [ path.pwd ] ] ;
}


Expand Down

0 comments on commit 5a51558

Please sign in to comment.