2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-14 00:32:11 +00:00

"symlink" targets.

[SVN r16332]
This commit is contained in:
Rene Rivera
2002-11-20 00:44:43 +00:00
parent d7c96aa1bc
commit c7d04e52c6
2 changed files with 106 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ import stage ;
import prebuilt ;
import toolset ;
import errors : error ;
import symlink ;
feature toolset : gcc : implicit propagated link-incompatible ;
feature shared : false true : propagated ;

105
src/tools/symlink.jam Normal file
View File

@@ -0,0 +1,105 @@
# Copyright (C) 2002, Rene Rivera. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears in
# all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
# Defines the "symlink" special target. 'symlink' targets make symbolic links
# to the sources.
import numbers ;
import targets ;
import virtual-target ;
import class ;
import property ;
import modules ;
import os ;
count = 0 ;
# The class representing "symlink" targets.
#
rule symlink-targets (
project
: targets *
: sources *
)
{
# Generate a fake name for now. Need unnamed targets eventually.
local c = [ modules.peek symlink : count ] ;
modules.poke symlink : count : [ numbers.increment $(c) ] ;
local fake-name = symlink#$(c) ;
basic-target.__init__ $(fake-name) : $(project) : $(sources) ;
# Remember the targets to map the sources onto. Pad or truncate
# to fit the sources given.
self.targets = ;
for local source in $(sources)
{
if $(targets)
{
self.targets += $(targets[1]) ;
targets = $(targets[2-]) ;
}
else
{
self.targets += $(source) ;
}
}
# The virtual targets corresponding to the given targets.
self.virtual-targets = ;
rule construct ( source-targets * : properties * )
{
local i = 1 ;
for local t in $(source-targets)
{
local s = $(self.targets[$(i)]) ;
local vt = [ class.new virtual-target $(s) : [ $(t).type ] : $(self.project) ] ;
$(vt).action [ class.new action $(vt) : $(t) : symlink.ln ] ;
self.virtual-targets += $(vt) ;
i = [ numbers.increment $(i) ] ;
}
return $(self.virtual-targets) ;
}
}
class.class symlink-targets : basic-target ;
# Creates a symbolic link from a set of targets to a set of sources.
# The targets and sources map one to one. The symlinks generated are
# limited to be the ones given as the sources. That is, the targets
# are either padded or trimmed to equate to the sources. The padding
# is done with the name of the corresponding source. For example::
#
# symlink : one two ;
#
# Is equal to::
#
# symlink one two : one two ;
#
rule symlink (
targets *
: sources *
)
{
local project = [ CALLER_MODULE ] ;
return [ targets.main-target-alternative
[ class.new symlink-targets $(project) : $(targets) : $(sources) ] ] ;
}
rule ln
{
local os ;
if [ modules.peek : UNIX ] { os = UNIX ; }
else { os ?= [ os.name ] ; }
ln-$(os) $(<) : $(>) ;
}
actions ln-UNIX
{
if test -n '$(<:D)' ; then cd '$(<:D)' ; fi && ln -s '$(>)' '$(<:D=)'
}
IMPORT $(__name__) : symlink : : symlink ;