~ubuntu-branches/ubuntu/raring/boost-build/raring

« back to all changes in this revision

Viewing changes to build/generators.jam

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-08-06 00:38:31 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080806003831-zr65893244swds0b
Tags: 2.0-m12-2
* debian/rules: Do not install /etc/user-config.jam.
* debian/site-config.jam: New.  Install into /etc instead of empty
  example.  Closes: #493323.

* debian/control: Update homepage.  Update description.  Closes:
  #493510.  Update Standards-Version to 3.8.0; no changes.

* debian/compat: New.  Set compat level to 7.
* debian/rules: Remove DH_COMPAT setting.
* debian/control: Change debhelper build-dep to version >= 7.

* debian/control: Remove docbook-to-man, bison from build-deps.

* debian/rules: Clean up upstream source by removing debian/conffiles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#  Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and
2
 
#  distribute this software is granted provided this copyright notice appears in
3
 
#  all copies. This software is provided "as is" without express or implied
4
 
#  warranty, and with no claim as to its suitability for any purpose.
 
1
# Copyright Vladimir Prus 2002.
 
2
# Copyright Rene Rivera 2006.
 
3
#
 
4
# Distributed under the Boost Software License, Version 1.0.
 
5
#    (See accompanying file LICENSE_1_0.txt or copy at
 
6
#          http://www.boost.org/LICENSE_1_0.txt)
5
7
 
6
8
#  Manages 'generators' --- objects which can do transformation between different
7
9
#  target types and contain algorithm for finding transformation from sources
219
221
            return ;
220
222
        }
221
223
    }
222
 
        
 
224
    
223
225
    # Returns another generator which differers from $(self) in
224
226
    # - id
225
227
    # - value to <toolset> feature in properties
264
266
    
265
267
    # Tries to invoke this generator on the given sources. Returns a
266
268
    # list of generated targets (instances of 'virtual-target').
 
269
    # Returning nothing from run indicates that the generator was
 
270
    # unable to create the target.
267
271
    rule run ( project  # Project for which the targets are generated
268
272
               name ?   # Determines the name of 'name' attribute for 
269
273
                        # all generated targets. See 'generated-targets' method.
367
371
            }                        
368
372
        }
369
373
        return $(result) ;
370
 
    }   
 
374
    }
 
375
    
 
376
    # Determine the name of the produced target from the
 
377
    # names of the sources.
 
378
    rule determine-output-name ( sources + )
 
379
    {
 
380
        # The simple case if when a name
 
381
        # of source has single dot. Then, we take the part before
 
382
        # dot. Several dots can be caused by:
 
383
        # - Using source file like a.host.cpp
 
384
        # - A type which suffix has a dot. Say, we can
 
385
        #   type 'host_cpp' with extension 'host.cpp'.
 
386
        # In the first case, we want to take the part till the last
 
387
        # dot. In the second case -- no sure, but for now take
 
388
        # the part till the last dot too.
 
389
        name = [ utility.basename [ $(sources[1]).name ] ] ;
 
390
                        
 
391
        for local s in $(sources[2])
 
392
        {
 
393
            local n2 = [ utility.basename [ $(s).name ] ] ;
 
394
            if $(n2) != $(name)
 
395
            {
 
396
                error "$(self.id): source targets have different names: cannot determine target name" ;
 
397
            }
 
398
        }
 
399
        
 
400
        # Names of sources might include directory. We should strip it.
 
401
        name = $(name:D=) ;
 
402
        
 
403
        return $(name) ;
 
404
    }
371
405
    
372
406
    # Constructs targets that are created after consuming 'sources'.
373
407
    # The result will be the list of virtual-target, which the same length
393
427
    {
394
428
        if ! $(name)
395
429
        {
396
 
            # Determine the name of the produced target from the
397
 
            # names of the sources. The simple case if when a name
398
 
            # of source has single dot. Then, we take the part before
399
 
            # dot. Several dots can be caused by:
400
 
            # - Using source file like a.host.cpp
401
 
            # - A type which suffix has a dot. Say, we can
402
 
            #   type 'host_cpp' with extension 'host.cpp'.
403
 
            # In the first case, we want to take the part till the last
404
 
            # dot. In the second case -- no sure, but for now take
405
 
            # the part till the last dot too.
406
 
            name = [ utility.basename [ $(sources[1]).name ] ] ;
407
 
                        
408
 
            for local s in $(sources[2])
409
 
            {
410
 
                local n2 = [ utility.basename [ $(s).name ] ] ;
411
 
                if $(n2) != $(name)
412
 
                {
413
 
                    error "$(self.id): source targets have different names: cannot determine target name" ;
414
 
                }
415
 
            }
416
 
 
417
 
            # Names of sources might include directory. We should strip it.
418
 
            name = $(name:D=) ;
 
430
            name = [ determine-output-name $(sources) ] ;
419
431
        }
420
432
        
421
433
        # Assign an action for each target
635
647
# a generator and then call 'run' method on that generator, bypassing all
636
648
# generator selection.
637
649
rule register-standard ( id : source-types * : target-types + : requirements * )
638
 
 
639
650
{
640
651
    local g = [ new generator $(id) : $(source-types) : $(target-types)
641
652
      : $(requirements) ] ;
660
671
    return $(.generators-for-toolset.$(toolset)) ;
661
672
}
662
673
 
 
674
# Make generator 'overrider-id' be preferred to
 
675
# 'overridee-id'. If, when searching for generators
 
676
# that could produce a target of certain type,
 
677
# both those generators are amoung viable generators,
 
678
# the overridden generator is immediately discarded.
 
679
#
 
680
# The overridden generators are discarded immediately
 
681
# after computing the list of viable generators, before
 
682
# running any of them.
663
683
rule override ( overrider-id : overridee-id )
664
684
{
665
685
    .override.$(overrider-id) += $(overridee-id) ;    
821
841
      ] ;
822
842
            
823
843
    local usage-requirements ;
824
 
    if $(targets) && [ class.is-a $(targets[1]) : property-set ]
825
 
    {
826
 
        usage-requirements = $(targets[1]) ;
827
 
        targets = $(targets[2-]) ;
828
 
    }
829
 
    else
830
 
    {
831
 
        usage-requirements = [ property-set.empty ] ;
 
844
    local success ;
 
845
    
 
846
    generators.dout [ indent ] returned $(targets) ;
 
847
    
 
848
    if $(targets)
 
849
    {
 
850
        success = true ;
 
851
    
 
852
        if  [ class.is-a $(targets[1]) : property-set ]
 
853
        {
 
854
            usage-requirements = $(targets[1]) ;
 
855
            targets = $(targets[2-]) ;
 
856
        }
 
857
        else
 
858
        {
 
859
            usage-requirements = [ property-set.empty ] ;
 
860
        }
832
861
    }
833
862
    
834
863
    generators.dout [ indent ] "  generator" [ $(generator).id ] " spawned " ;
835
864
    generators.dout [ indent ] " " $(targets) ; 
836
 
    if $(targets)
 
865
    if $(usage-requirements)
 
866
    {
 
867
        generators.dout [ indent ] "  with usage requirements:" $(x) ;
 
868
    }
 
869
    
 
870
    
 
871
    if $(success)
837
872
    {
838
873
        return $(usage-requirements) $(targets) ;
839
 
    }    
 
874
    }
840
875
}
841
876
 
842
877
# Checks if generator invocation can be pruned, because it's guaranteed
981
1016
    for local g in $(generators)
982
1017
    {
983
1018
        generators.dout [ indent ] "trying generator" [ $(g).id ] "(" [ $(g).source-types ] -> [ $(g).target-types ] ")" ;
984
 
            
 
1019
        
985
1020
        local m = [ $(g).match-rank $(property-set) ] ;
986
 
        if $(m) 
 
1021
        if $(m)
987
1022
        {
988
1023
            generators.dout [ indent ] "  is viable" ;
989
1024
            viable-generators += $(g) ;
990
 
        }                                    
 
1025
        }
991
1026
    }
992
1027
                            
993
1028
    return $(viable-generators) ;
1124
1159
# 'construct' in stack, returns only targets of requested 'target-type',
1125
1160
# otherwise, returns also unused sources and additionally generated
1126
1161
# targets.    
1127
 
#
1128
 
# Does not return target which are not of 'allowed-type' or of type derived from
1129
 
# it. If 'allowed-type' is not specified, it's defaulted to 'target-type'.
1130
 
# See lib-target-class for use case of this.
1131
 
rule construct ( project name ? : target-type : property-set * : sources * 
1132
 
   : allowed-type * )
 
1162
rule construct ( project name ? : target-type : property-set * : sources * )
1133
1163
{
1134
1164
    if (.construct-stack)
1135
1165
    {
1163
1193
    return $(result) ;        
1164
1194
}
1165
1195
 
 
1196
# Given 'result', obtained from some generator or 
 
1197
# generators.construct, adds 'raw-properties' as usage requirements
 
1198
# to it. If result already contains usage requirements -- that is
 
1199
# the first element of result of an instance of the property-set class,
 
1200
# the existing usage requirements and 'raw-properties' are combined.
 
1201
rule add-usage-requirements ( result * : raw-properties * )
 
1202
{
 
1203
    if $(result)
 
1204
    {
 
1205
        if [ class.is-a $(result[1]) : property-set ] 
 
1206
        {
 
1207
            return [ $(result[1]).add-raw $(raw-properties) ] $(result[2-]) ;
 
1208
        }
 
1209
        else
 
1210
        {
 
1211
            return [ property-set.create $(raw-properties) ] $(result) ;
 
1212
        }        
 
1213
    }    
 
1214
}