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

Move the logic for library ordering to a separate module. Add library

ordering to 'sun' toolset.


[SVN r22284]
This commit is contained in:
Vladimir Prus
2004-02-16 09:12:27 +00:00
parent cd17918331
commit 53ca4fcb36
3 changed files with 169 additions and 143 deletions

View File

@@ -16,7 +16,9 @@ import "class" : new ;
import order ;
import set ;
feature.extend toolset : gcc ;
#feature.extend toolset : gcc ;
toolset.inherit gcc : unix ;
feature.subfeature toolset gcc : version : : optional propagated link-incompatible ;
# Make the "o" suffix used for gcc toolset on all
@@ -54,96 +56,6 @@ if [ os.name ] = NT
JAMSHELL = % ;
}
# Special linking generator for gcc which handles order requirements on
# the command line.
class gcc-linking-generator : linking-generator
{
import property-set ;
import type ;
import gcc ;
rule __init__ ( id
composing ? : # Specify if generator is composing. The generator will be
# composing if non-empty string is passed, or parameter is
# not given. To make generator non-composing, pass empty
# string ("")
source-types + : target-types + :
requirements * )
{
composing ?= true ;
generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) :
$(requirements) ;
}
rule run ( project name ? : property-set : sources + : multiple ? )
{
local result = [ linking-generator.run $(project) $(name) : $(property-set)
: $(sources) : $(multiple) ] ;
gcc.set-library-order $(sources) : $(property-set) : $(result) ;
return $(result) ;
}
rule generated-targets ( sources + : property-set : project name ? )
{
local sources2 ;
local libraries ;
for local l in $(sources)
{
if [ type.is-derived [ $(l).type ] LIB ]
{
libraries += $(l) ;
}
else
{
sources2 += $(l) ;
}
}
sources = $(sources2) [ gcc.order-libraries $(libraries) ] ;
return [ linking-generator.generated-targets $(sources) : $(property-set)
: $(project) $(name) ] ;
}
}
class gcc-archive-generator : generator
{
import gcc ;
rule __init__ ( id composing ? : source-types + : target-types + :
requirements * )
{
composing ?= true ;
generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) :
$(requirements) ;
}
rule run ( project name ? : property-set : sources + : multiple ? )
{
local result = [ generator.run $(project) $(name) : $(property-set)
: $(sources) : $(multiple) ] ;
gcc.set-library-order $(sources) : $(property-set) : $(result) ;
return $(result) ;
}
}
# Declare generators
generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE
: <toolset>gcc ] ;
generators.register [ new gcc-archive-generator gcc.archive : OBJ : STATIC_LIB
: <toolset>gcc ] ;
generators.register [ new gcc-linking-generator gcc.link.dll : LIB OBJ : SHARED_LIB
: <toolset>gcc ] ;
generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : <toolset>gcc ;
generators.register-c-compiler gcc.compile.c : C : OBJ : <toolset>gcc ;
@@ -281,51 +193,3 @@ else if [ modules.peek : UNIX ]
}
}
.order = [ new order ] ;
rule set-library-order-aux ( from * : to * )
{
for local f in $(from)
{
for local t in $(to)
{
if $(f) != $(t)
{
$(.order).add-pair $(f) $(t) ;
}
}
}
}
rule set-library-order ( sources * : property-set : result * )
{
local used-libraries ;
local deps = [ $(property-set).dependency ] ;
for local l in $(sources) $(deps:G=)
{
if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ]
{
used-libraries += $(l) ;
}
}
local created-libraries ;
for local l in $(result)
{
if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ]
{
created-libraries += $(l) ;
}
}
created-libraries = [ set.difference $(created-libraries) : $(used-libraries) ] ;
set-library-order-aux $(created-libraries) : $(used-libraries) ;
}
rule order-libraries ( libraries * )
{
return [ $(.order).order $(libraries) ] ;
}

View File

@@ -11,7 +11,7 @@ import toolset : flags ;
import feature ;
import type ;
toolset.register sun ;
toolset.inherit sun : unix ;
feature.subfeature toolset sun : version ;
# Installation root to use for versionless toolset
@@ -53,9 +53,6 @@ rule init ( version ? : root ? )
# Declare generators
generators.register-c-compiler sun.compile.c : C : OBJ : <toolset>sun ;
generators.register-c-compiler sun.compile.c++ : CPP : OBJ : <toolset>sun ;
generators.register-composing sun.archive : OBJ : STATIC_LIB : <toolset>sun ;
generators.register-linker sun.link.dll : LIB OBJ : SHARED_LIB : <toolset>sun ;
generators.register-linker sun.link : LIB OBJ : EXE : <toolset>sun ;
# Declare flags and actions for compilation
flags sun.compile OPTIONS <debug-symbols>on : -g ;

165
src/tools/unix.jam Normal file
View File

@@ -0,0 +1,165 @@
# Copyright (c) 2004 Vladimir Prus.
#
# Use, modification and distribution is subject to the Boost Software
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
# This file implements linking semantic common to all unixes. On unix, static
# libraries must be specified in a fixed order on the linker command line. Generators
# declared there store information about the order and use it property.
import feature ;
import "class" : new ;
import generators ;
import type ;
import set ;
feature.extend toolset : gcc ;
class unix-linking-generator : linking-generator
{
import property-set ;
import type ;
import unix ;
rule __init__ ( id
composing ? : # Specify if generator is composing. The generator will be
# composing if non-empty string is passed, or parameter is
# not given. To make generator non-composing, pass empty
# string ("")
source-types + : target-types + :
requirements * )
{
composing ?= true ;
generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) :
$(requirements) ;
}
rule run ( project name ? : property-set : sources + : multiple ? )
{
local result = [ linking-generator.run $(project) $(name) : $(property-set)
: $(sources) : $(multiple) ] ;
unix.set-library-order $(sources) : $(property-set) : $(result) ;
return $(result) ;
}
rule generated-targets ( sources + : property-set : project name ? )
{
local sources2 ;
local libraries ;
for local l in $(sources)
{
if [ type.is-derived [ $(l).type ] LIB ]
{
libraries += $(l) ;
}
else
{
sources2 += $(l) ;
}
}
sources = $(sources2) [ unix.order-libraries $(libraries) ] ;
return [ linking-generator.generated-targets $(sources) : $(property-set)
: $(project) $(name) ] ;
}
}
class unix-archive-generator : generator
{
import unix ;
rule __init__ ( id composing ? : source-types + : target-types + :
requirements * )
{
composing ?= true ;
generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) :
$(requirements) ;
}
rule run ( project name ? : property-set : sources + : multiple ? )
{
local result = [ generator.run $(project) $(name) : $(property-set)
: $(sources) : $(multiple) ] ;
unix.set-library-order $(sources) : $(property-set) : $(result) ;
return $(result) ;
}
}
# Declare generators
generators.register [ new unix-linking-generator unix.link : LIB OBJ : EXE
: <toolset>unix ] ;
generators.register [ new unix-archive-generator unix.archive : OBJ : STATIC_LIB
: <toolset>unix ] ;
generators.register [ new unix-linking-generator unix.link.dll : LIB OBJ : SHARED_LIB
: <toolset>unix ] ;
# The derived toolset must specify their own actions.
actions link {
}
actions link.dll {
}
actions archive {
}
.order = [ new order ] ;
rule set-library-order-aux ( from * : to * )
{
for local f in $(from)
{
for local t in $(to)
{
if $(f) != $(t)
{
$(.order).add-pair $(f) $(t) ;
}
}
}
}
rule set-library-order ( sources * : property-set : result * )
{
local used-libraries ;
local deps = [ $(property-set).dependency ] ;
for local l in $(sources) $(deps:G=)
{
if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ]
{
used-libraries += $(l) ;
}
}
local created-libraries ;
for local l in $(result)
{
if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ]
{
created-libraries += $(l) ;
}
}
created-libraries = [ set.difference $(created-libraries) : $(used-libraries) ] ;
set-library-order-aux $(created-libraries) : $(used-libraries) ;
}
rule order-libraries ( libraries * )
{
return [ $(.order).order $(libraries) ] ;
}