| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import "class" : new ; |
| import errors ; |
| import project ; |
| import property-set ; |
| import targets ; |
| import type ; |
|
|
|
|
| class cast-target-class : typed-target |
| { |
| import type ; |
|
|
| rule __init__ ( name : project : type : sources * : requirements * : |
| default-build * : usage-requirements * ) |
| { |
| typed-target.__init__ $(name) : $(project) : $(type) : $(sources) : |
| $(requirements) : $(default-build) : $(usage-requirements) ; |
| } |
|
|
| rule construct ( name : source-targets * : property-set ) |
| { |
| local result ; |
| for local s in $(source-targets) |
| { |
| if ! [ class.is-a $(s) : file-target ] |
| { |
| import errors ; |
| errors.user-error Source to the 'cast' rule is not a file! ; |
| } |
| if [ $(s).action ] |
| { |
| import errors ; |
| errors.user-error Only non-derived target are allowed for |
| 'cast'. : when building [ full-name ] ; |
| } |
| local r = [ $(s).clone-with-different-type $(self.type) ] ; |
| result += [ virtual-target.register $(r) ] ; |
| } |
| return [ property-set.empty ] $(result) ; |
| } |
| } |
|
|
|
|
| rule cast ( name type : sources * : requirements * : default-build * : |
| usage-requirements * ) |
| { |
| local project = [ project.current ] ; |
|
|
| local real-type = [ type.type-from-rule-name $(type) ] ; |
| if ! $(real-type) |
| { |
| errors.user-error No type corresponds to the main target rule name |
| '$(type)' : "Hint: try a lowercase name" ; |
| } |
|
|
| targets.main-target-alternative [ new cast-target-class $(name) : $(project) |
| : $(real-type) |
| : [ targets.main-target-sources $(sources) : $(name) ] |
| : [ targets.main-target-requirements $(requirements) : $(project) ] |
| : [ targets.main-target-default-build $(default-build) : $(project) ] |
| : [ targets.main-target-usage-requirements $(usage-requirements) : |
| $(project) ] ] ; |
| } |
|
|
|
|
| IMPORT $(__name__) : cast : : cast ; |
|
|