mirror of
https://github.com/boostorg/build.git
synced 2026-02-13 12:22:17 +00:00
115 lines
3.3 KiB
Plaintext
115 lines
3.3 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.
|
|
|
|
import modules ;
|
|
import feature ;
|
|
import errors ;
|
|
import type ;
|
|
import class : class new ;
|
|
|
|
# Initialized the QT support module. The 'prefix' parameter
|
|
# tells where QT is installed. When not given, environmental
|
|
# variable QTDIR should be set.
|
|
rule init ( prefix ? )
|
|
{
|
|
if ! $(prefix)
|
|
{
|
|
prefix = [ modules.peek : QTDIR ] ;
|
|
if ! $(prefix)
|
|
{
|
|
errors.error
|
|
"QT installation prefix not given and QTDIR variable is empty" ;
|
|
}
|
|
}
|
|
|
|
if $(.initialized)
|
|
{
|
|
if $(prefix) != $(.prefix)
|
|
{
|
|
errors.error
|
|
"Attempt the reinitialize QT with different installation prefix" ;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
.initialized = true ;
|
|
.prefix = $(prefix) ;
|
|
|
|
feature.extend uses : qt ;
|
|
feature.action <uses>qt : qt.add-properties ;
|
|
|
|
generators.register-standard qt.moc : H : CPP(moc_%) : <uses>qt ;
|
|
|
|
type.register UI : ui ;
|
|
type.register UIC_H : : H ;
|
|
|
|
generators.register-standard qt.uic-h : UI : UIC_H : <uses>qt ;
|
|
|
|
# The following generator is used to convert UI files to CPP
|
|
# It creates UIC_H from UI, and constructs CPP from UI/UIC_H
|
|
# In addition, it also returns UIC_H target, so that it can bee
|
|
# mocced.
|
|
rule qt.uic-cpp-generator
|
|
{
|
|
generator.__init__ qt.uic-cpp : UI UIC_H : CPP : <uses>qt ;
|
|
|
|
rule run ( project name ? : properties * : sources + : multiple ? )
|
|
{
|
|
# Construct CPP as usual
|
|
local result = [ generator.run $(project) $(name)
|
|
: $(properties) : $(sources) : $(multiple) ] ;
|
|
# If OK, add "UIC_H" target to the returned list
|
|
if $(result)
|
|
{
|
|
local action = [ $(result[1]).action ] ;
|
|
local sources = [ $(action).sources ] ;
|
|
result += $(sources[2]) ;
|
|
}
|
|
|
|
return $(result) ;
|
|
}
|
|
}
|
|
|
|
class qt.uic-cpp-generator : generator ;
|
|
generators.register [ new qt.uic-cpp-generator ] ;
|
|
}
|
|
}
|
|
|
|
rule qt.add-properties ( property : properties * )
|
|
{
|
|
local lib-name ;
|
|
if <threading>multi in $(properties)
|
|
{
|
|
lib-name = qt-mt ;
|
|
}
|
|
else
|
|
{
|
|
lib-name = qt ;
|
|
}
|
|
return <include>$(.prefix)/include <dll-path>$(.prefix)/lib <library-path>$(.prefix)/lib <find-shared-library>$(lib-name) ;
|
|
}
|
|
|
|
# -f forces moc to include the processed source file.
|
|
# Without it, it would think that .qpp is not a header and would not
|
|
# include it from the generated file.
|
|
actions moc
|
|
{
|
|
$(.prefix)/bin/moc -f $(>) -o $(<)
|
|
}
|
|
|
|
actions uic-h
|
|
{
|
|
$(.prefix)/bin/uic $(>) -o $(<)
|
|
}
|
|
|
|
# The second target is uic-generated header name. It's placed in
|
|
# build dir, but we want to include it using only basename.
|
|
actions uic-cpp
|
|
{
|
|
$(.prefix)/bin/uic $(>[1]) -i $(>[2]:D=) -o $(<)
|
|
}
|
|
|
|
|