# Copyright 2002, 2003, 2004, 2005 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 


import "class" : new ;

import lex ;
import qt ;
import extra ;

import type ;

type.register tUI : tui ;
type.register tUIC_H ;
type.set-generated-target-suffix tUIC_H : : h ;

type.register X1 : x1 ;
type.register X2 : x2  ;
type.register X_PRO : x_pro ;

import generators ;

generators.register-standard qt.uic : tUI tUIC_H : CPP ;
generators.register-standard qt.uic-h : tUI : tUIC_H ;

# That's an interesting example. Currently, X_PRO will be processed
# twice.
generators.register-standard extra.x : X1 X2 : CPP ;
generators.register-standard extra.x_pro : X_PRO : X1 X2 ;

# The point of this setup of to implement this functionality
# "When main target type is EST_EXE, build OBJ from CPP-MARKED, not
# for anything else (like CPP)
# Unfortunately, this does not really works.

#if $(no-var) {
import nm ;

type.register CPP_MARKED : marked_cpp : CPP ;
type.register POSITIONS : positions ;
type.register NM.TARGET.CPP : target_cpp : CPP ;
type.register NM_EXE : : EXE ;

generators.register-standard nm.target-source : CPP_MARKED : NM.TARGET.CPP ;
generators.register-standard nm.cpp-mark : CPP : CPP_MARKED POSITIONS ;
    
class nm::target::cpp-obj-generator : generator
{
    rule __init__ ( )
    {        
        generator.__init__ nm.target-obj : NM.TARGET.CPP : OBJ ;
    }
    
    rule requirements ( )
    {
        return <main-target-type>NM_EXE ;
    }
        
    # Consider: it it OK to ignore all other generated targets except for the first?
    rule run ( project name ? : properties * : source : multiple ? ) 
    {
        if [ $(source).type ] = CPP {    
            local converted = [ generators.construct $(project) : NM.TARGET.CPP : $(properties) : $(source) ] ;
        if $(converted[1])
            {            
                local result = [ generators.construct $(project) : OBJ : $(properties) : $(converted[2]) ] ;
                return $(result) ;
            }
            else
            {
                return ;
            }        
        }
        else
        {
            return ;
        }        
    }                
}

generators.register [ new nm::target::cpp-obj-generator ] ;

generators.override nm.target-obj : all ;

#}









