Boost logo

Boost-Build :

Subject: Re: [Boost-build] symlink problem
From: Phillip Seaver (phil_at_[hidden])
Date: 2014-08-28 13:47:11


On 8/28/14 11:31 AM, Vladimir Prus wrote:
> On 08/28/2014 12:06 AM, Phillip Seaver wrote:
>> Hello,
>>
>> I ran into this bug when trying to create symbolic links:
>> https://svn.boost.org/trac/boost/ticket/10096
>>
>> Is there a different way I could do it or an easy fix?
>
> Phillip,
>
> I don't quite remember the context, do you have an easy reproduction
> recipe?
>
> - Volodya

Hi, Volodya,

This is the thread where I found people talking about it:
http://lists.boost.org/boost-build/2014/05/27543.php

I get the "path.make called with ( ) " error. I was just doing
something like "symlink include/header.h : source/header.h ;"

I tried using the SEARCH and LOCATE, like my copy of link.jam does: "[
on $(<) return $(LOCATE) ] [ on $(<) return $(SEARCH) ]" and that fixed
that problem.

I then ran into a problem where it would add .h to the end of the
filename, so I would end up with "include/header.h.h". I made a change
to virtual-target.jam that fixed that.

I then noticed that it was stripping the relative paths off of the
files, so I made a change to handle that. It doesn't check to see if
the source file exists before creating the symbolic link, so it will
link to a non-existent file without an error. I don't know if that's
the correct behavior.

Here are my changes to symlink.jam:

***************
*** 110,118 ****
      if [ modules.peek : UNIX ] { os = UNIX ; }
      else { os ?= [ os.name ] ; }
      # Remember the path to make the link relative to where the symlink
is located.
! local path-to-source = [ path.relative-to
! [ path.make [ on $(<) return $(LOCATE) ] ]
! [ path.make [ on $(>) return $(LOCATE) ] ] ] ;
      if $(path-to-source) = .
      {
          PATH_TO_SOURCE on $(<) = "" ;
--- 110,120 ----
      if [ modules.peek : UNIX ] { os = UNIX ; }
      else { os ?= [ os.name ] ; }
      # Remember the path to make the link relative to where the symlink
is located.
! local src = [ on $(<) return $(LOCATE) ] [ on $(<) return
$(SEARCH) ] ;
! local dst = [ on $(>) return $(LOCATE) ] [ on $(>) return
$(SEARCH) ] ;
! src = $(src)/$(<:G=:D) ;
! dst = $(dst)/$(>:G=:D) ;
! local path-to-source = [ path.relative-to [ path.make $(src) ] [
path.make $(dst) ] ] ;
      if $(path-to-source) = .
      {
          PATH_TO_SOURCE on $(<) = "" ;

Here's the change I made to virtual-target.jam to avoid adding the suffix:

***************
*** 63,69 ****
  import set ;
  import type ;
  import utility ;
!
 
  # Models a potential target. It can be converted into a Jam target and
used in
  # building, if needed. However, it can be also dropped, which allows us to
--- 63,69 ----
  import set ;
  import type ;
  import utility ;
! import regex ;
 
  # Models a potential target. It can be converted into a Jam target and
used in
  # building, if needed. However, it can be also dropped, which allows us to
***************
*** 522,527 ****
--- 522,532 ----
      {
          prefix = ;
      }
+ local suffix-regex = [ regex.escape $(suffix) : "." : "\\" ] ;
+ if [ MATCH ($(suffix-regex))$ : $(specified-name) ]
+ {
+ suffix = ;
+ }
      return $(prefix:E="")$(specified-name)$(suffix:E="") ;
  }

Phillip


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk