HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Library/share/b2/tools/generators/c-compiling-generator.jam
# Copyright 2002-2017 Rene Rivera
# Copyright 2002-2017 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at
# https://www.bfgroup.xyz/b2/LICENSE.txt)

import "class" : new ;
import generators ;
import virtual-target ;

# Declare a special compiler generator. The only thing it does is changing the
# type used to represent 'action' in the constructed dependency graph to
# 'compile-action'. That class in turn adds additional include paths to handle
# cases when a source file includes headers which are generated themselves.
#
class C-compiling-generator : generator
{
    rule __init__ ( id : source-types + : target-types + : requirements *
        : optional-properties * )
    {
        generator.__init__ $(id) : $(source-types) : $(target-types) :
            $(requirements) : $(optional-properties) ;
    }

    rule action-class ( )
    {
        return compile-action ;
    }
}


rule register-c-compiler ( id : source-types + : target-types + : requirements *
    : optional-properties * )
{
    generators.register [ new C-compiling-generator $(id) : $(source-types) :
        $(target-types) : $(requirements) : $(optional-properties) ] ;
}

# FIXME: this is ugly, should find a better way (we would like client code to
# register all generators as "generators.some-rule" instead of
# "some-module.some-rule".)
#
IMPORT $(__name__) : register-c-compiler : : generators.register-c-compiler ;

class compile-action : action
{
    import sequence ;

    rule __init__ ( targets * : sources * : action-name : properties * )
    {
        action.__init__ $(targets) : $(sources) : $(action-name) : $(properties) ;
    }

    # For all virtual targets for the same dependency graph as self, i.e. which
    # belong to the same main target, add their directories to the include path.
    #
    rule adjust-properties ( property-set )
    {
        local s = [ $(self.targets[1]).creating-subvariant ] ;
        if $(s)
        {
            return [ $(property-set).add-raw
              [ $(s).implicit-includes "include" : H ] ] ;
        }
        else
        {
            return $(property-set) ;
        }
    }
}