mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 01:12:13 +00:00
58 lines
2.0 KiB
Plaintext
58 lines
2.0 KiB
Plaintext
# Copyright (C) Vladimir Prus 2002. 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.
|
|
|
|
# This module defines a special generator, which handles targets with
|
|
# <file> property. It allows to use prebuilt targets.
|
|
|
|
import targets ;
|
|
import class : class new ;
|
|
import property ;
|
|
import errors : error ;
|
|
import type : type ;
|
|
import regex ;
|
|
import feature ;
|
|
import generators ;
|
|
|
|
feature.feature file : : free ;
|
|
|
|
rule prebuilt-file-generator
|
|
{
|
|
generator.__init__ prebuilt-file-generator : : * : <file> ;
|
|
|
|
rule run ( project name ? : properties * : sources * )
|
|
{
|
|
local name = [ feature.get-values <file> : $(properties) ] ;
|
|
local type = [ type.type $(name:S) ] ;
|
|
if ! $(type)
|
|
{
|
|
errors.error "Unknown type for prebuilt target " $(name) in $(project) ;
|
|
}
|
|
|
|
local pl = [ project.attribute $(project) location ] ;
|
|
local path = [ path.root [ path.native $(name:D) ] $(pl) ] ;
|
|
|
|
local t = [ new file-target $(name:S=:D=) : $(type) : $(project) ] ;
|
|
$(t).set-path $(path) ;
|
|
# TODO: have no idea how handle this. Specifically,
|
|
# we need to distinguish between virtual targets with different
|
|
# properties. In this case, there are no properties, because
|
|
# they are stored in action, and we don't have any action.
|
|
# Therefore, we encode properties via 'extra-grist', which is ugly.
|
|
# Maybe, we should just introduce 'do-nothing-action', which only
|
|
# keps properties.
|
|
$(t).extra-grist [ property.as-path $(properties) ] ;
|
|
$(t).suffix [ MATCH .(.*) : $(name:S) ] ;
|
|
return $(t) ;
|
|
|
|
}
|
|
}
|
|
|
|
class prebuilt-file-generator : generator ;
|
|
|
|
generators.register [ new prebuilt-file-generator ] ;
|
|
|
|
|
|
|