本文整理汇总了Python中SCons.Builder.add_action方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.add_action方法的具体用法?Python Builder.add_action怎么用?Python Builder.add_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SCons.Builder
的用法示例。
在下文中一共展示了Builder.add_action方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
CLVar = SCons.Util.CLVar
Action = SCons.Action.Action
Builder = SCons.Builder.Builder
env.SetDefault(QTDIR = _detect(env),
QT_BINPATH = os.path.join('$QTDIR', 'bin'),
QT_CPPPATH = os.path.join('$QTDIR', 'include'),
QT_LIBPATH = os.path.join('$QTDIR', 'lib'),
QT_MOC = os.path.join('$QT_BINPATH','moc'),
QT_UIC = os.path.join('$QT_BINPATH','uic'),
QT_LIB = 'qt', # may be set to qt-mt
QT_AUTOSCAN = 1, # scan for moc'able sources
# Some QT specific flags. I don't expect someone wants to
# manipulate those ...
QT_UICIMPLFLAGS = CLVar(''),
QT_UICDECLFLAGS = CLVar(''),
QT_MOCFROMHFLAGS = CLVar(''),
QT_MOCFROMCXXFLAGS = CLVar('-i'),
# suffixes/prefixes for the headers / sources to generate
QT_UICDECLPREFIX = '',
QT_UICDECLSUFFIX = '.h',
QT_UICIMPLPREFIX = 'uic_',
QT_UICIMPLSUFFIX = '$CXXFILESUFFIX',
QT_MOCHPREFIX = 'moc_',
QT_MOCHSUFFIX = '$CXXFILESUFFIX',
QT_MOCCXXPREFIX = '',
QT_MOCCXXSUFFIX = '.moc',
QT_UISUFFIX = '.ui',
# Commands for the qt support ...
# command to generate header, implementation and moc-file
# from a .ui file
QT_UICCOM = [
CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'),
CLVar('$QT_UIC $QT_UICIMPLFLAGS -impl ${TARGETS[0].file} '
'-o ${TARGETS[1]} $SOURCE'),
CLVar('$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}')],
# command to generate meta object information for a class
# declarated in a header
QT_MOCFROMHCOM = (
'$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE'),
# command to generate meta object information for a class
# declarated in a cpp file
QT_MOCFROMCXXCOM = [
CLVar('$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'),
Action(checkMocIncluded,None)])
# ... and the corresponding builders
uicBld = Builder(action=SCons.Action.Action('$QT_UICCOM', '$QT_UICCOMSTR'),
emitter=uicEmitter,
src_suffix='$QT_UISUFFIX',
suffix='$QT_UICDECLSUFFIX',
prefix='$QT_UICDECLPREFIX',
source_scanner=uicScanner)
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.Action('$QT_MOCFROMHCOM', '$QT_MOCFROMHCOMSTR')
mocBld.add_action(h, act)
mocBld.prefix[h] = '$QT_MOCHPREFIX'
mocBld.suffix[h] = '$QT_MOCHSUFFIX'
for cxx in cxx_suffixes:
act = SCons.Action.Action('$QT_MOCFROMCXXCOM', '$QT_MOCFROMCXXCOMSTR')
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
# register the builders
env['BUILDERS']['Uic'] = uicBld
env['BUILDERS']['Moc'] = mocBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.add_src_builder('Uic')
shared_obj.add_src_builder('Uic')
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(PROGEMITTER =[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER =[AutomocStatic],
# Of course, we need to link against the qt libraries
CPPPATH=["$QT_CPPPATH"],
LIBPATH=["$QT_LIBPATH"],
LIBS=['$QT_LIB'])
示例2: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
#.........这里部分代码省略.........
QT4_LRELEASECOM = '$QT4_LRELEASE -silent $SOURCE -qm $TARGET',
QT4_RCCCOM = '$QT4_RCC $QT4_QRCFLAGS -name $SOURCE $SOURCE -o $TARGET',
)
if len(env["QTDIR"]) > 0 :
env.Replace(QT4_LIBPATH = os.path.join('$QTDIR', 'lib'))
# Translation builder
tsbuilder = Builder(
action = SCons.Action.Action('$QT4_LUPDATECOM'), #,'$QT4_LUPDATECOMSTR'),
multi=1
)
env.Append( BUILDERS = { 'Ts': tsbuilder } )
qmbuilder = Builder(
action = SCons.Action.Action('$QT4_LRELEASECOM', cmdstr = '$QT4_LRELEASECOMSTR'),
src_suffix = '.ts',
suffix = '.qm',
single_source = True
)
env.Append( BUILDERS = { 'Qm': qmbuilder } )
# Resource builder
def scanResources(node, env, path, arg):
# I've being careful on providing names relative to the qrc file
# If that was not needed that code could be simplified a lot
def recursiveFiles(basepath, path) :
result = []
for item in os.listdir(os.path.join(basepath, path)) :
itemPath = os.path.join(path, item)
if os.path.isdir(os.path.join(basepath, itemPath)) :
result += recursiveFiles(basepath, itemPath)
else:
result.append(itemPath)
return result
contents = node.get_contents()
includes = qrcinclude_re.findall(contents)
qrcpath = os.path.dirname(node.path)
dirs = [included for included in includes if os.path.isdir(os.path.join(qrcpath,included))]
# dirs need to include files recursively
for dir in dirs :
includes.remove(dir)
includes+=recursiveFiles(qrcpath,dir)
return includes
qrcscanner = SCons.Scanner.Scanner(name = 'qrcfile',
function = scanResources,
argument = None,
skeys = ['.qrc'])
qrcbuilder = Builder(
action = SCons.Action.Action('$QT4_RCCCOM', cmdstr = '$QT4_RCCCOMSTR'),
source_scanner = qrcscanner,
src_suffix = '$QT4_QRCSUFFIX',
suffix = '$QT4_QRCCXXSUFFIX',
prefix = '$QT4_QRCCXXPREFIX',
single_source = True
)
env.Append( BUILDERS = { 'Qrc': qrcbuilder } )
# Interface builder
uic4builder = Builder(
action = SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'),
src_suffix='$QT4_UISUFFIX',
suffix='$QT4_UICDECLSUFFIX',
prefix='$QT4_UICDECLPREFIX',
single_source = True
#TODO: Consider the uiscanner on new scons version
)
env['BUILDERS']['Uic4'] = uic4builder
# Metaobject builder
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.Action('$QT4_MOCFROMHCOM', cmdstr = '$QT4_MOCFROMHCOMSTR')
mocBld.add_action(h, act)
mocBld.prefix[h] = '$QT4_MOCHPREFIX'
mocBld.suffix[h] = '$QT4_MOCHSUFFIX'
for cxx in cxx_suffixes:
act = SCons.Action.Action('$QT4_MOCFROMCXXCOM', cmdstr = '$QT4_MOCFROMCXXCOMSTR')
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = '$QT4_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT4_MOCCXXSUFFIX'
env['BUILDERS']['Moc4'] = mocBld
# er... no idea what that was for
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.src_builder.append('Uic4')
shared_obj.src_builder.append('Uic4')
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(PROGEMITTER =[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER =[AutomocStatic],
# Of course, we need to link against the qt libraries
LIBPATH=["$QT4_LIBPATH"],
LIBS=['$QT4_LIB'])
# TODO: Does dbusxml2cpp need an adapter
env.AddMethod(enable_modules, "EnableQt4Modules")
示例3: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
#.........这里部分代码省略.........
QT4_UICDECLSUFFIX = '.h',
QT4_MOCHPREFIX = 'moc_',
QT4_MOCHSUFFIX = '$CXXFILESUFFIX',
QT4_MOCCXXPREFIX = 'moc_',
QT4_MOCCXXSUFFIX = '.moc',
QT4_QRCSUFFIX = '.qrc',
QT4_QRCCXXSUFFIX = '$CXXFILESUFFIX',
QT4_QRCCXXPREFIX = 'qrc_',
# Commands for the qt support ...
QT4_UICCOM = '$QT4_UIC $QT4_UICFLAGS -o $TARGET $SOURCE',
QT4_MOCFROMHCOM = '$QT4_MOC $QT4_MOCFROMHFLAGS -o $TARGET $SOURCE',
QT4_MOCFROMCXXCOM = [
'$QT4_MOC $QT4_MOCFROMCXXFLAGS -o $TARGET $SOURCE',
Action(checkMocIncluded,None)],
QT4_LUPDATECOM = '$QT4_LUPDATE $SOURCE -ts $TARGET',
QT4_LRELEASECOM = '$QT4_LRELEASE $SOURCE',
QT4_RCCCOM = '$QT4_RCC $QT4_QRCFLAGS $SOURCE -o $TARGET',
)
# Translation builder
tsbuilder = Builder(
action = SCons.Action.Action('$QT4_LUPDATECOM'), #,'$QT4_LUPDATECOMSTR'),
multi=1
)
env.Append( BUILDERS = { 'Ts': tsbuilder } )
qmbuilder = Builder(
action = SCons.Action.Action('$QT4_LRELEASECOM'),# , '$QT4_LRELEASECOMSTR'),
src_suffix = '.ts',
suffix = '.qm',
single_source = True
)
env.Append( BUILDERS = { 'Qm': qmbuilder } )
# Resource builder
def scanResources(node, env, path, arg):
contents = node.get_contents()
includes = qrcinclude_re.findall(contents)
return includes
qrcscanner = SCons.Scanner.Scanner(name = 'qrcfile',
function = scanResources,
argument = None,
skeys = ['.qrc'])
qrcbuilder = Builder(
action = SCons.Action.Action('$QT4_RCCCOM'), #, '$QT4_RCCCOMSTR'),
source_scanner = qrcscanner,
src_suffix = '$QT4_QRCSUFFIX',
suffix = '$QT4_QRCCXXSUFFIX',
prefix = '$QT4_QRCCXXPREFIX',
single_source = True
)
env.Append( BUILDERS = { 'Qrc': qrcbuilder } )
# Interface builder
uic4builder = Builder(
action = SCons.Action.Action('$QT4_UICCOM'), #, '$QT4_UICCOMSTR'),
src_suffix='$QT4_UISUFFIX',
suffix='$QT4_UICDECLSUFFIX',
prefix='$QT4_UICDECLPREFIX',
single_source = True
#TODO: Consider the uiscanner on new scons version
)
env.Append( BUILDERS = { 'Uic4': uic4builder } )
# Metaobject builder
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.Action('$QT4_MOCFROMHCOM') #, '$QT4_MOCFROMHCOMSTR')
mocBld.add_action(h, act)
mocBld.prefix[h] = '$QT4_MOCHPREFIX'
mocBld.suffix[h] = '$QT4_MOCHSUFFIX'
for cxx in cxx_suffixes:
act = SCons.Action.Action('$QT4_MOCFROMCXXCOM') #, '$QT4_MOCFROMCXXCOMSTR')
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = '$QT4_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT4_MOCCXXSUFFIX'
env.Append( BUILDERS = { 'Moc4': mocBld } )
# er... no idea what that was for
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.src_builder.append('Uic4')
shared_obj.src_builder.append('Uic4')
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(PROGEMITTER =[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER =[AutomocStatic],
# Of course, we need to link against the qt libraries
CPPPATH=["$QT4_CPPPATH"],
LIBPATH=["$QT4_LIBPATH"],
LIBS=['$QT4_LIB'])
#import new
#method = new.instancemethod(enable_modules, env, SCons.Environment)
#env.EnableQt4Modules=method
SConsEnvironment.EnableQt4Modules = enable_modules
示例4: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
#.........这里部分代码省略.........
QT5_QRCCXXPREFIX = 'qrc_',
QT5_MOCDEFPREFIX = '-D',
QT5_MOCDEFSUFFIX = '',
QT5_MOCDEFINES = '${_defines(QT5_MOCDEFPREFIX, CPPDEFINES, QT5_MOCDEFSUFFIX, __env__)}',
QT5_MOCCPPPATH = [],
QT5_MOCINCFLAGS = '$( ${_concat(QT5_MOCINCPREFIX, QT5_MOCCPPPATH, INCSUFFIX, __env__, RDirs)} $)',
# Commands for the qt5 support ...
QT5_UICCOM = '$QT5_UIC $QT5_UICFLAGS -o $TARGET $SOURCE',
QT5_LUPDATECOM = '$QT5_LUPDATE $QT5_LUPDATEFLAGS $SOURCES -ts $TARGET',
QT5_LRELEASECOM = '$QT5_LRELEASE $QT5_LRELEASEFLAGS -qm $TARGET $SOURCES',
# Specialized variables for the Extended Automoc support
# (Strategy #1 for qtsolutions)
QT5_XMOCHPREFIX = 'moc_',
QT5_XMOCHSUFFIX = '.cpp',
QT5_XMOCCXXPREFIX = '',
QT5_XMOCCXXSUFFIX = '.moc',
)
try:
env.AddMethod(Ts5, "Ts5")
env.AddMethod(Qm5, "Qm5")
env.AddMethod(Qrc5, "Qrc5")
env.AddMethod(ExplicitMoc5, "ExplicitMoc5")
env.AddMethod(ExplicitUic5, "ExplicitUic5")
except AttributeError:
# Looks like we use a pre-0.98 version of SCons...
from SCons.Script.SConscript import SConsEnvironment
SConsEnvironment.Ts5 = Ts5
SConsEnvironment.Qm5 = Qm5
SConsEnvironment.Qrc5 = Qrc5
SConsEnvironment.ExplicitMoc5 = ExplicitMoc5
SConsEnvironment.ExplicitUic5 = ExplicitUic5
# Interface builder
uic5builder = Builder(
action = SCons.Action.Action('$QT5_UICCOM', '$QT5_UICCOMSTR'),
src_suffix='$QT5_UISUFFIX',
suffix='$QT5_UICDECLSUFFIX',
prefix='$QT5_UICDECLPREFIX',
single_source = True
#TODO: Consider the uiscanner on new scons version
)
env['BUILDERS']['Uic5'] = uic5builder
# Metaobject builder
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.CommandGeneratorAction(__moc_generator_from_h, {})
mocBld.add_action(h, act)
mocBld.prefix[h] = '$QT5_MOCHPREFIX'
mocBld.suffix[h] = '$QT5_MOCHSUFFIX'
for cxx in cxx_suffixes:
act = SCons.Action.CommandGeneratorAction(__moc_generator_from_cxx, {})
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = '$QT5_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT5_MOCCXXSUFFIX'
env['BUILDERS']['Moc5'] = mocBld
# Metaobject builder for the extended auto scan feature
# (Strategy #1 for qtsolutions)
xMocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.CommandGeneratorAction(__mocx_generator_from_h, {})
xMocBld.add_action(h, act)
xMocBld.prefix[h] = '$QT5_XMOCHPREFIX'
xMocBld.suffix[h] = '$QT5_XMOCHSUFFIX'
for cxx in cxx_suffixes:
act = SCons.Action.CommandGeneratorAction(__mocx_generator_from_cxx, {})
xMocBld.add_action(cxx, act)
xMocBld.prefix[cxx] = '$QT5_XMOCCXXPREFIX'
xMocBld.suffix[cxx] = '$QT5_XMOCCXXSUFFIX'
env['BUILDERS']['XMoc5'] = xMocBld
# Add the Qrc5 action to the CXX file builder (registers the
# *.qrc extension with the Environment)
cfile_builder, cxxfile_builder = SCons.Tool.createCFileBuilders(env)
qrc_act = SCons.Action.CommandGeneratorAction(__qrc_generator, {})
cxxfile_builder.add_action('$QT5_QRCSUFFIX', qrc_act)
cxxfile_builder.add_emitter('$QT5_QRCSUFFIX', __qrc_emitter)
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(PROGEMITTER =[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER =[AutomocStatic],
)
# TODO: Does dbusxml2cpp need an adapter
try:
env.AddMethod(enable_modules, "EnableQt5Modules")
except AttributeError:
# Looks like we use a pre-0.98 version of SCons...
from SCons.Script.SConscript import SConsEnvironment
SConsEnvironment.EnableQt5Modules = enable_modules
示例5: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
CLVar = SCons.Util.CLVar
Action = SCons.Action.Action
Builder = SCons.Builder.Builder
splitext = SCons.Util.splitext
env.SetDefault(
QTDIR=_detect(env),
QT_BINPATH=os.path.join("$QTDIR", "bin"),
QT_CPPPATH=os.path.join("$QTDIR", "include"),
QT_LIBPATH=os.path.join("$QTDIR", "lib"),
QT_MOC=os.path.join("$QT_BINPATH", "moc"),
QT_UIC=os.path.join("$QT_BINPATH", "uic"),
QT_LIB="qt", # may be set to qt-mt
QT_AUTOSCAN=1, # scan for moc'able sources
# Some QT specific flags. I don't expect someone wants to
# manipulate those ...
QT_UICIMPLFLAGS=CLVar(""),
QT_UICDECLFLAGS=CLVar(""),
QT_MOCFROMHFLAGS=CLVar(""),
QT_MOCFROMCXXFLAGS=CLVar("-i"),
# suffixes/prefixes for the headers / sources to generate
QT_UICDECLPREFIX="",
QT_UICDECLSUFFIX=".h",
QT_UICIMPLPREFIX="uic_",
QT_UICIMPLSUFFIX="$CXXFILESUFFIX",
QT_MOCHPREFIX="moc_",
QT_MOCHSUFFIX="$CXXFILESUFFIX",
QT_MOCCXXPREFIX="",
QT_MOCCXXSUFFIX=".moc",
QT_UISUFFIX=".ui",
# Commands for the qt support ...
# command to generate header, implementation and moc-file
# from a .ui file
QT_UICCOM=[
CLVar("$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE"),
CLVar("$QT_UIC $QT_UICIMPLFLAGS -impl ${TARGETS[0].file} " "-o ${TARGETS[1]} $SOURCE"),
CLVar("$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}"),
],
# command to generate meta object information for a class
# declarated in a header
QT_MOCFROMHCOM=("$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE"),
# command to generate meta object information for a class
# declarated in a cpp file
QT_MOCFROMCXXCOM=[
CLVar("$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE"),
Action(checkMocIncluded, None),
],
)
# ... and the corresponding builders
uicBld = Builder(
action=SCons.Action.Action("$QT_UICCOM", "$QT_UICCOMSTR"),
emitter=uicEmitter,
src_suffix="$QT_UISUFFIX",
suffix="$QT_UICDECLSUFFIX",
prefix="$QT_UICDECLPREFIX",
source_scanner=uicScanner,
)
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.Action("$QT_MOCFROMHCOM", "$QT_MOCFROMHCOMSTR")
mocBld.add_action(h, act)
mocBld.prefix[h] = "$QT_MOCHPREFIX"
mocBld.suffix[h] = "$QT_MOCHSUFFIX"
for cxx in cxx_suffixes:
act = SCons.Action.Action("$QT_MOCFROMCXXCOM", "$QT_MOCFROMCXXCOMSTR")
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = "$QT_MOCCXXPREFIX"
mocBld.suffix[cxx] = "$QT_MOCCXXSUFFIX"
# register the builders
env["BUILDERS"]["Uic"] = uicBld
env["BUILDERS"]["Moc"] = mocBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.src_builder.append("Uic")
shared_obj.src_builder.append("Uic")
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(
PROGEMITTER=[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER=[AutomocStatic],
# Of course, we need to link against the qt libraries
CPPPATH=["$QT_CPPPATH"],
LIBPATH=["$QT_LIBPATH"],
LIBS=["$QT_LIB"],
)
示例6: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
CLVar = SCons.Util.CLVar
Action = SCons.Action.Action
Builder = SCons.Builder.Builder
env.SetDefault(
QT_AUTOSCAN = 1, # scan for moc'able sources
# Some QT specific flags. I don't expect someone wants to
# manipulate those ...
QT_UICIMPLFLAGS = CLVar(''),
QT_UICDECLFLAGS = CLVar(''),
QT_MOCFROMHFLAGS = CLVar(''),
QT_MOCFROMCXXFLAGS = CLVar('-i'),
# suffixes/prefixes for the headers / sources to generate
QT_UICDECLPREFIX = '', #'ui_',
QT_UICDECLSUFFIX = '.h',
QT_UICIMPLPREFIX = '', #'ui_',
QT_UICIMPLSUFFIX = '$CXXFILESUFFIX',
QT_MOCHPREFIX = 'moc_',
QT_MOCHSUFFIX = '$CXXFILESUFFIX',
QT_MOCCXXPREFIX = '',
QT_MOCCXXSUFFIX = '.moc',
QT_UISUFFIX = '.ui',
# Commands for the qt support ...
# command to generate header, implementation and moc-file
# from a .ui file
QT_UICCOM = [
CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'),
CLVar('$QT_UIC $QT_UICIMPLFLAGS -impl ${TARGETS[0].file} '
'-o ${TARGETS[1]} $SOURCE'),
#CLVar('$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}'),
],
# command to generate meta object information for a class
# declarated in a header
QT_MOCFROMHCOM = (
'$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE'
),
# command to generate meta object information for a class
# declarated in a cpp file
QT_MOCFROMCXXCOM = [
CLVar('$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'),
Action(checkMocIncluded,None),
]
)
# ... and the corresponding builders
uicBld = Builder(
action = SCons.Action.Action('$QT_UICCOM', '$QT_UICCOMSTR'),
emitter = uicEmitter,
src_suffix = '$QT_UISUFFIX',
suffix = '$QT_UICDECLSUFFIX',
prefix = '$QT_UICDECLPREFIX',
source_scanner = uicScanner,
)
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.Action('$QT_MOCFROMHCOM', '$QT_MOCFROMHCOMSTR')
mocBld.add_action(h, act)
mocBld.prefix[h] = '$QT_MOCHPREFIX'
mocBld.suffix[h] = '$QT_MOCHSUFFIX'
for cxx in cxx_suffixes:
act = SCons.Action.Action('$QT_MOCFROMCXXCOM', '$QT_MOCFROMCXXCOMSTR')
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
# register the builders
env['BUILDERS']['Uic'] = uicBld
env['BUILDERS']['Moc'] = mocBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.add_src_builder('Uic')
shared_obj.add_src_builder('Uic')
env.AddMethod( enableQtEmmitters, "EnableQtEmmitters")
示例7: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
#.........这里部分代码省略.........
QT4_MOCCXXPREFIX="",
QT4_MOCCXXSUFFIX=".moc",
QT4_QRCSUFFIX=".qrc",
QT4_QRCCXXSUFFIX="$CXXFILESUFFIX",
QT4_QRCCXXPREFIX="qrc_",
QT4_MOCDEFPREFIX="-D",
QT4_MOCDEFSUFFIX="",
QT4_MOCDEFINES="${_defines(QT4_MOCDEFPREFIX, CPPDEFINES, QT4_MOCDEFSUFFIX, __env__)}",
QT4_MOCCPPPATH=[],
QT4_MOCINCFLAGS="$( ${_concat(QT4_MOCINCPREFIX, QT4_MOCCPPPATH, INCSUFFIX, __env__, RDirs)} $)",
# Commands for the qt4 support ...
QT4_UICCOM="$QT4_UIC $QT4_UICFLAGS -o $TARGET $SOURCE",
QT4_LUPDATECOM="$QT4_LUPDATE $QT4_LUPDATEFLAGS $SOURCES -ts $TARGET",
QT4_LRELEASECOM="$QT4_LRELEASE $QT4_LRELEASEFLAGS -qm $TARGET $SOURCES",
# Specialized variables for the Extended Automoc support
# (Strategy #1 for qtsolutions)
QT4_XMOCHPREFIX="moc_",
QT4_XMOCHSUFFIX=".cpp",
QT4_XMOCCXXPREFIX="",
QT4_XMOCCXXSUFFIX=".moc",
)
try:
env.AddMethod(Ts4, "Ts4")
env.AddMethod(Qm4, "Qm4")
env.AddMethod(Qrc4, "Qrc4")
env.AddMethod(ExplicitMoc4, "ExplicitMoc4")
env.AddMethod(ExplicitUic4, "ExplicitUic4")
except AttributeError:
# Looks like we use a pre-0.98 version of SCons...
from SCons.Script.SConscript import SConsEnvironment
SConsEnvironment.Ts4 = Ts4
SConsEnvironment.Qm4 = Qm4
SConsEnvironment.Qrc4 = Qrc4
SConsEnvironment.ExplicitMoc4 = ExplicitMoc4
SConsEnvironment.ExplicitUic4 = ExplicitUic4
# Interface builder
uic4builder = Builder(
action=SCons.Action.Action("$QT4_UICCOM", "$QT4_UICCOMSTR"),
src_suffix="$QT4_UISUFFIX",
suffix="$QT4_UICDECLSUFFIX",
prefix="$QT4_UICDECLPREFIX",
single_source=True
# TODO: Consider the uiscanner on new scons version
)
env["BUILDERS"]["Uic4"] = uic4builder
# Metaobject builder
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.CommandGeneratorAction(__moc_generator_from_h, {})
mocBld.add_action(h, act)
mocBld.prefix[h] = "$QT4_MOCHPREFIX"
mocBld.suffix[h] = "$QT4_MOCHSUFFIX"
for cxx in cxx_suffixes:
act = SCons.Action.CommandGeneratorAction(__moc_generator_from_cxx, {})
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = "$QT4_MOCCXXPREFIX"
mocBld.suffix[cxx] = "$QT4_MOCCXXSUFFIX"
env["BUILDERS"]["Moc4"] = mocBld
# Metaobject builder for the extended auto scan feature
# (Strategy #1 for qtsolutions)
xMocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.CommandGeneratorAction(__mocx_generator_from_h, {})
xMocBld.add_action(h, act)
xMocBld.prefix[h] = "$QT4_XMOCHPREFIX"
xMocBld.suffix[h] = "$QT4_XMOCHSUFFIX"
for cxx in cxx_suffixes:
act = SCons.Action.CommandGeneratorAction(__mocx_generator_from_cxx, {})
xMocBld.add_action(cxx, act)
xMocBld.prefix[cxx] = "$QT4_XMOCCXXPREFIX"
xMocBld.suffix[cxx] = "$QT4_XMOCCXXSUFFIX"
env["BUILDERS"]["XMoc4"] = xMocBld
# Add the Qrc4 action to the CXX file builder (registers the
# *.qrc extension with the Environment)
cfile_builder, cxxfile_builder = SCons.Tool.createCFileBuilders(env)
qrc_act = SCons.Action.CommandGeneratorAction(__qrc_generator, {})
cxxfile_builder.add_action("$QT4_QRCSUFFIX", qrc_act)
cxxfile_builder.add_emitter("$QT4_QRCSUFFIX", __qrc_emitter)
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(PROGEMITTER=[AutomocStatic], SHLIBEMITTER=[AutomocShared], LIBEMITTER=[AutomocStatic])
# TODO: Does dbusxml2cpp need an adapter
try:
env.AddMethod(enable_modules, "EnableQt4Modules")
except AttributeError:
# Looks like we use a pre-0.98 version of SCons...
from SCons.Script.SConscript import SConsEnvironment
SConsEnvironment.EnableQt4Modules = enable_modules
示例8: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
CLVar = SCons.Util.CLVar
Action = SCons.Action.Action
Builder = SCons.Builder.Builder
splitext = SCons.Util.splitext
dep_include = env["OPTICKSDEPENDENCIESINCLUDE"]
dep_bin = env["OPTICKSDEPENDENCIESBIN"]
env.AppendUnique(QT_BINPATH = dep_bin,
QT_CPPPATH = os.path.join(dep_include, 'qt4'),
QT_MOC = os.path.join('$QT_BINPATH','moc'),
QT_UIC = os.path.join('$QT_BINPATH','uic'),
QT_QRC = os.path.join('$QT_BINPATH','rcc'),
QT_LIB = None, # filled in by AddModules
QT_MODULES = [], # filled in by AddModules
QT_AUTOSCAN = 1, # scan for moc'able sources
# Some QT specific flags. I don't expect someone wants to
# manipulate those ...
QT_UICIMPLFLAGS = CLVar(''),
QT_UICDECLFLAGS = CLVar(''),
QT_MOCFROMHFLAGS = CLVar(''),
QT_MOCFROMCXXFLAGS = CLVar('-i'),
# suffixes/prefixes for the headers / sources to generate
QT_UICDECLPREFIX = 'ui_',
QT_UICDECLSUFFIX = '.h',
QT_QRCIMPLSUFFIX = '_qrc.cpp',
QT_MOCHPREFIX = 'moc_',
QT_MOCHSUFFIX = '$CXXFILESUFFIX',
QT_MOCCXXPREFIX = '',
QT_MOCCXXSUFFIX = '.moc',
QT_UISUFFIX = '.ui',
QT_QRCSUFFIX = '.qrc',
# Commands for the qt support ...
# command to generate header, implementation and moc-file
# from a .qrc file
QT_QRCCOM = [
CLVar('$QT_QRC $QT_QRCDECLFLAGS $SOURCE -name ${SOURCE.filebase} -o ${TARGETS[0]}')],
# from a .ui file
QT_UICCOM = [
CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE')],
# command to generate meta object information for a class
# declarated in a header
QT_MOCFROMHCOM = (
'$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE'),
# command to generate meta object information for a class
# declarated in a cpp file
QT_MOCFROMCXXCOM = [
CLVar('$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'),
Action(checkMocIncluded,None)])
# ... and the corresponding builders
qrcBld = Builder(action={'$QT_QRCSUFFIX':'$QT_QRCCOM'},
suffix='$QT_QRCIMPLSUFFIX',
src_suffix='$QT_QRCSUFFIX')
uicBld = Builder(action={'$QT_UISUFFIX':'$QT_UICCOM'},
src_suffix='$QT_UISUFFIX',
suffix='$QT_UICDECLSUFFIX',
prefix='$QT_UICDECLPREFIX',
source_scanner=uicScanner)
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
mocBld.add_action(h, '$QT_MOCFROMHCOM')
mocBld.prefix[h] = '$QT_MOCHPREFIX'
mocBld.suffix[h] = '$QT_MOCHSUFFIX'
for cxx in cxx_suffixes:
mocBld.add_action(cxx, '$QT_MOVFROMCXXCOM')
mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
# register the builders
env['BUILDERS']['Uic'] = uicBld
env['BUILDERS']['Moc'] = mocBld
env['BUILDERS']['Qrc'] = qrcBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.src_builder.append('Qrc')
shared_obj.src_builder.append('Qrc')
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(PROGEMITTER =[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER =[AutomocStatic])
示例9: generate
# 需要导入模块: from SCons import Builder [as 别名]
# 或者: from SCons.Builder import add_action [as 别名]
#.........这里部分代码省略.........
],
QT4_LUPDATECOM="$QT4_LUPDATE $SOURCE -ts $TARGET",
QT4_LRELEASECOM="$QT4_LRELEASE -silent $SOURCE -qm $TARGET",
QT4_RCCCOM="$QT4_RCC $QT4_QRCFLAGS -name $SOURCE $SOURCE -o $TARGET",
)
if len(env["QTDIR"]) > 0:
env.Replace(QT4_LIBPATH=os.path.join("$QTDIR", "lib"))
# Translation builder
tsbuilder = Builder(action=SCons.Action.Action("$QT4_LUPDATECOM"), multi=1) # ,'$QT4_LUPDATECOMSTR'),
env.Append(BUILDERS={"Ts": tsbuilder})
qmbuilder = Builder(
action=SCons.Action.Action("$QT4_LRELEASECOM", cmdstr="$QT4_LRELEASECOMSTR"),
src_suffix=".ts",
suffix=".qm",
single_source=True,
)
env.Append(BUILDERS={"Qm": qmbuilder})
# Resource builder
def scanResources(node, env, path, arg):
# I've being careful on providing names relative to the qrc file
# If that was not needed that code could be simplified a lot
def recursiveFiles(basepath, path):
result = []
for item in os.listdir(os.path.join(basepath, path)):
itemPath = os.path.join(path, item)
if os.path.isdir(os.path.join(basepath, itemPath)):
result += recursiveFiles(basepath, itemPath)
else:
result.append(itemPath)
return result
contents = node.get_contents()
includes = [included[1] for included in qrcinclude_re.findall(contents)]
qrcpath = os.path.dirname(node.path)
dirs = [included for included in includes if os.path.isdir(os.path.join(qrcpath, included))]
# dirs need to include files recursively
for dir in dirs:
includes.remove(dir)
includes += recursiveFiles(qrcpath, dir)
return includes
qrcscanner = SCons.Scanner.Scanner(name="qrcfile", function=scanResources, argument=None, skeys=[".qrc"])
qrcbuilder = Builder(
action=SCons.Action.Action("$QT4_RCCCOM", cmdstr="$QT4_RCCCOMSTR"),
source_scanner=qrcscanner,
src_suffix="$QT4_QRCSUFFIX",
suffix="$QT4_QRCCXXSUFFIX",
prefix="$QT4_QRCCXXPREFIX",
single_source=True,
)
env.Append(BUILDERS={"Qrc": qrcbuilder})
# Interface builder
uic4builder = Builder(
action=SCons.Action.Action("$QT4_UICCOM", cmdstr="$QT4_UICCOMSTR"),
src_suffix="$QT4_UISUFFIX",
suffix="$QT4_UICDECLSUFFIX",
prefix="$QT4_UICDECLPREFIX",
single_source=True
# TODO: Consider the uiscanner on new scons version
)
env["BUILDERS"]["Uic4"] = uic4builder
# Metaobject builder
mocBld = Builder(action={}, prefix={}, suffix={})
for h in header_extensions:
act = SCons.Action.Action("$QT4_MOCFROMHCOM", cmdstr="$QT4_MOCFROMHCOMSTR")
mocBld.add_action(h, act)
mocBld.prefix[h] = "$QT4_MOCHPREFIX"
mocBld.suffix[h] = "$QT4_MOCHSUFFIX"
for cxx in cxx_suffixes:
act = SCons.Action.Action("$QT4_MOCFROMCXXCOM", cmdstr="$QT4_MOCFROMCXXCOMSTR")
mocBld.add_action(cxx, act)
mocBld.prefix[cxx] = "$QT4_MOCCXXPREFIX"
mocBld.suffix[cxx] = "$QT4_MOCCXXSUFFIX"
env["BUILDERS"]["Moc4"] = mocBld
# er... no idea what that was for
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
static_obj.src_builder.append("Uic4")
shared_obj.src_builder.append("Uic4")
# We use the emitters of Program / StaticLibrary / SharedLibrary
# to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
env.AppendUnique(
PROGEMITTER=[AutomocStatic],
SHLIBEMITTER=[AutomocShared],
LIBEMITTER=[AutomocStatic],
# Of course, we need to link against the qt libraries
LIBPATH=["$QT4_LIBPATH"],
LIBS=["$QT4_LIB"],
)
# TODO: Does dbusxml2cpp need an adapter
env.AddMethod(enable_modules, "EnableQt4Modules")