当前位置: 首页>>代码示例>>Python>>正文


Python SCons.Builder类代码示例

本文整理汇总了Python中SCons.Builder的典型用法代码示例。如果您正苦于以下问题:Python Builder类的具体用法?Python Builder怎么用?Python Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Builder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate

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'])
开发者ID:madnessw,项目名称:thesnow,代码行数:90,代码来源:qt.py

示例2: generate

def generate(env):
	"""Add Builders and construction variables for qt to an Environment."""

	def locateQt4Command(env, command, qtdir) :
		if len(qtdir) == 0 :
			qtdir = "/usr"
		suffixes = [
			'-qt4',
			'-qt4.exe',
			'4',
			'4.exe',
			'',
			'.exe',
		]
		triedPaths = []
		for suffix in suffixes :
			fullpath = os.path.join(qtdir,'bin',command + suffix)
			if os.access(fullpath, os.X_OK) :
				return fullpath
			triedPaths.append(fullpath)

		fullpath = env.Detect([command+'-qt4', command+'4', command])
		if not (fullpath is None) : return fullpath

		raise Exception("Qt4 command '" + command + "' not found. Tried: " + ', '.join(triedPaths))
		

	CLVar = SCons.Util.CLVar
	Action = SCons.Action.Action
	Builder = SCons.Builder.Builder
	splitext = SCons.Util.splitext

	env['QTDIR']	= _detect(env)
	# TODO: 'Replace' should be 'SetDefault'
#	env.SetDefault(
	env.Replace(
		QTDIR  = _detect(env),
		# TODO: This is not reliable to QTDIR value changes but needed in order to support '-qt4' variants
		QT4_MOC = locateQt4Command(env,'moc', env['QTDIR']),
		QT4_UIC = locateQt4Command(env,'uic', env['QTDIR']),
		QT4_RCC = locateQt4Command(env,'rcc', env['QTDIR']),
		QT4_LUPDATE = locateQt4Command(env,'lupdate', env['QTDIR']),
		QT4_LRELEASE = locateQt4Command(env,'lrelease', env['QTDIR']),
		QT4_LIB = '', # KLUDGE to avoid linking qt3 library

		QT4_AUTOSCAN = 1, # Should the qt tool try to figure out, which sources are to be moc'ed?

		# Some QT specific flags. I don't expect someone wants to
		# manipulate those ...
		QT4_UICFLAGS = CLVar(''),
		QT4_MOCFROMHFLAGS = CLVar(''),
		QT4_MOCFROMCXXFLAGS = CLVar('-i'),
		QT4_QRCFLAGS = '',

		# suffixes/prefixes for the headers / sources to generate
		QT4_UISUFFIX = '.ui',
		QT4_UICDECLPREFIX = 'ui_',
		QT4_UICDECLSUFFIX = '.h',
		QT4_MOCHPREFIX = 'moc_',
		QT4_MOCHSUFFIX = '$CXXFILESUFFIX',
		QT4_MOCCXXPREFIX = '',
		QT4_MOCCXXSUFFIX = '.moc',
		QT4_QRCSUFFIX = '.qrc',
		QT4_QRCCXXSUFFIX = '$CXXFILESUFFIX',
		QT4_QRCCXXPREFIX = 'qrc_',
		QT4_MOCCPPPATH = [],
		QT4_MOCINCFLAGS = '$( ${_concat("-I", QT4_MOCCPPPATH, INCSUFFIX, __env__, RDirs)} $)',

		# Commands for the qt support ...
		QT4_UICCOM = '$QT4_UIC $QT4_UICFLAGS -o $TARGET $SOURCE',
		QT4_MOCFROMHCOM = '$QT4_MOC $QT4_MOCFROMHFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE',
		QT4_MOCFROMCXXCOM = [
			'$QT4_MOC $QT4_MOCFROMCXXFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE',
			Action(checkMocIncluded,None)],
		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'), #,'$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) :
#.........这里部分代码省略.........
开发者ID:bessey,项目名称:picnic-doc-server,代码行数:101,代码来源:qt4.py

示例3: generate

def generate(env):
    """Add Builders and construction variables for qt to an Environment."""

    print "Loading qt4 tool..."

    def locateQt4Command(env, command, qtdir) :
        fullpath1 = os.path.join(qtdir, 'bin', command +'-qt4')
        if os.access(fullpath1, os.X_OK) or \
            os.access(fullpath1+".exe", os.X_OK):
            return fullpath1
        fullpath3 = os.path.join(qtdir, 'bin', command +'4')
        if os.access(fullpath3, os.X_OK) or \
            os.access(fullpath3+".exe", os.X_OK):
            return fullpath3
        fullpath2 = os.path.join(qtdir, 'bin', command)
        if os.access(fullpath2, os.X_OK) or \
            os.access(fullpath2+".exe", os.X_OK):
            return fullpath2
        fullpath = env.Detect([command+'-qt4', command+'4', command])
        if not (fullpath is None):
            return fullpath
        raise Exception("Qt4 command '" + command + "' not found. Tried: " + fullpath1 + " and "+ fullpath2)
        

    CLVar = SCons.Util.CLVar
    Action = SCons.Action.Action
    Builder = SCons.Builder.Builder
    splitext = SCons.Util.splitext

    env['QTDIR']  = _detect(env)
    # TODO: 'Replace' should be 'SetDefault'
#    env.SetDefault(
    env.Replace(
        QTDIR  = _detect(env),
        QT4_BINPATH = os.path.join('$QTDIR', 'bin'),
        QT4_CPPPATH = os.path.join('$QTDIR', 'include'),
        QT4_LIBPATH = os.path.join('$QTDIR', 'lib'),
        # TODO: This is not reliable to QTDIR value changes but needed in order to support '-qt4' variants
        QT4_MOC = locateQt4Command(env,'moc', env['QTDIR']),
        QT4_UIC = locateQt4Command(env,'uic', env['QTDIR']),
        QT4_RCC = locateQt4Command(env,'rcc', env['QTDIR']),
        QT4_LUPDATE = locateQt4Command(env,'lupdate', env['QTDIR']),
        QT4_LRELEASE = locateQt4Command(env,'lrelease', env['QTDIR']),
        QT4_LIB = '', # KLUDGE to avoid linking qt3 library

        QT4_AUTOSCAN = 1, # Should the qt tool try to figure out, which sources are to be moc'ed?

        # Some QT specific flags. I don't expect someone wants to
        # manipulate those ...
        QT4_UICFLAGS = CLVar(''),
        QT4_MOCFROMHFLAGS = CLVar(''),
        QT4_MOCFROMCXXFLAGS = CLVar('-i'),
        QT4_QRCFLAGS = '',

        # suffixes/prefixes for the headers / sources to generate
        QT4_UISUFFIX = '.ui',
        QT4_UICDECLPREFIX = 'ui_',
        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'])
#.........这里部分代码省略.........
开发者ID:gbaty,项目名称:sconsx,代码行数:101,代码来源:qt4.py

示例4: generate

def generate(env):
    """Add Builders and construction variables for qt5 to an Environment."""

    suffixes = [
        '-qt5',
        '-qt5.exe',
        '5',
        '5.exe',
        '',
        '.exe',
    ]
    command_suffixes = ['-qt5', '5', '']

    def locateQt5Command(env, command, qtdir) :
        triedPaths = []
        for suffix in suffixes :
            fullpath = os.path.join(qtdir,'bin',command + suffix)
            if os.access(fullpath, os.X_OK) :
                return fullpath
            triedPaths.append(fullpath)

        fullpath = env.Detect([command+s for s in command_suffixes])
        if not (fullpath is None) : return fullpath

        raise Exception("Qt5 command '" + command + "' not found. Tried: " + ', '.join(triedPaths))

    CLVar = SCons.Util.CLVar
    Action = SCons.Action.Action
    Builder = SCons.Builder.Builder

    env['QT5DIR']  = _detect(env)
    # TODO: 'Replace' should be 'SetDefault'
    env.SetDefault(
#S    env.Replace(
        QT5DIR  = _detect(env),
        QT5_BINPATH = os.path.join('$QT5DIR', 'bin'),
        # TODO: This is not reliable to QT5DIR value changes but needed in order to support '-qt5' variants
        QT5_MOC = locateQt5Command(env,'moc', env['QT5DIR']),
        QT5_UIC = locateQt5Command(env,'uic', env['QT5DIR']),
        QT5_RCC = locateQt5Command(env,'rcc', env['QT5DIR']),
        QT5_LUPDATE = locateQt5Command(env,'lupdate', env['QT5DIR']),
        QT5_LRELEASE = locateQt5Command(env,'lrelease', env['QT5DIR']),

        QT5_AUTOSCAN = 1, # Should the qt5 tool try to figure out, which sources are to be moc'ed?
        QT5_AUTOSCAN_STRATEGY = 0, # While scanning for files to moc, should we search for includes in qtsolutions style?
        QT5_GOBBLECOMMENTS = 0, # If set to 1, comments are removed before scanning cxx/h files.
        QT5_CPPDEFINES_PASSTOMOC = 1, # If set to 1, all CPPDEFINES get passed to the moc executable.
        QT5_CLEAN_TS = 0, # If set to 1, translation files (.ts) get cleaned on 'scons -c'
        QT5_AUTOMOC_SCANCPPPATH = 1, # If set to 1, the CPPPATHs (or QT5_AUTOMOC_CPPPATH) get scanned for moc'able files
        QT5_AUTOMOC_CPPPATH = [], # Alternative paths that get scanned for moc files

        # Some Qt5 specific flags. I don't expect someone wants to
        # manipulate those ...
        QT5_UICFLAGS = CLVar(''),
        QT5_MOCFROMHFLAGS = CLVar(''),
        QT5_MOCFROMCXXFLAGS = CLVar('-i'),
        QT5_QRCFLAGS = '',
        QT5_LUPDATEFLAGS = '',
        QT5_LRELEASEFLAGS = '',

        # suffixes/prefixes for the headers / sources to generate
        QT5_UISUFFIX = '.ui',
        QT5_UICDECLPREFIX = 'ui_',
        QT5_UICDECLSUFFIX = '.h',
        QT5_MOCINCPREFIX = '-I',
        QT5_MOCHPREFIX = 'moc_',
        QT5_MOCHSUFFIX = '$CXXFILESUFFIX',
        QT5_MOCCXXPREFIX = '',
        QT5_MOCCXXSUFFIX = '.moc',
        QT5_QRCSUFFIX = '.qrc',
        QT5_QRCCXXSUFFIX = '$CXXFILESUFFIX',
        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...
#.........这里部分代码省略.........
开发者ID:cedrus,项目名称:qt-binaries,代码行数:101,代码来源:qt5.py

示例5: generate

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"],
    )
开发者ID:berkus,项目名称:okl4,代码行数:93,代码来源:qt.py

示例6: generate

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")
开发者ID:barbak,项目名称:sconsProject,代码行数:79,代码来源:qt.py

示例7: generate

def generate(env):
    """Add Builders and construction variables for qt4 to an Environment."""

    def locateQt4Command(env, command, qtdir):
        suffixes = ["-qt4", "-qt4.exe", "4", "4.exe", "", ".exe"]
        triedPaths = []
        for suffix in suffixes:
            fullpath = os.path.join(qtdir, "bin", command + suffix)
            if os.access(fullpath, os.X_OK):
                return fullpath
            triedPaths.append(fullpath)

        fullpath = env.Detect([command + "-qt4", command + "4", command])
        if not (fullpath is None):
            return fullpath

        raise Exception("Qt4 command '" + command + "' not found. Tried: " + ", ".join(triedPaths))

    CLVar = SCons.Util.CLVar
    Action = SCons.Action.Action
    Builder = SCons.Builder.Builder

    env["QT4DIR"] = _detect(env)
    # TODO: 'Replace' should be 'SetDefault'
    #    env.SetDefault(
    env.Replace(
        QT4DIR=_detect(env),
        QT4_BINPATH=os.path.join("$QT4DIR", "bin"),
        # TODO: This is not reliable to QT4DIR value changes but needed in order to support '-qt4' variants
        QT4_MOC=locateQt4Command(env, "moc", env["QT4DIR"]),
        QT4_UIC=locateQt4Command(env, "uic", env["QT4DIR"]),
        QT4_RCC=locateQt4Command(env, "rcc", env["QT4DIR"]),
        QT4_LUPDATE=locateQt4Command(env, "lupdate", env["QT4DIR"]),
        QT4_LRELEASE=locateQt4Command(env, "lrelease", env["QT4DIR"]),
        QT4_AUTOSCAN=1,  # Should the qt4 tool try to figure out, which sources are to be moc'ed?
        QT4_AUTOSCAN_STRATEGY=0,  # While scanning for files to moc, should we search for includes in qtsolutions style?
        QT4_GOBBLECOMMENTS=0,  # If set to 1, comments are removed before scanning cxx/h files.
        QT4_CPPDEFINES_PASSTOMOC=1,  # If set to 1, all CPPDEFINES get passed to the moc executable.
        QT4_CLEAN_TS=0,  # If set to 1, translation files (.ts) get cleaned on 'scons -c'
        QT4_AUTOMOC_SCANCPPPATH=1,  # If set to 1, the CPPPATHs (or QT4_AUTOMOC_CPPPATH) get scanned for moc'able files
        QT4_AUTOMOC_CPPPATH=[],  # Alternative paths that get scanned for moc files
        # Some Qt4 specific flags. I don't expect someone wants to
        # manipulate those ...
        QT4_UICFLAGS=CLVar(""),
        QT4_MOCFROMHFLAGS=CLVar(""),
        QT4_MOCFROMCXXFLAGS=CLVar("-i"),
        QT4_QRCFLAGS="",
        QT4_LUPDATEFLAGS="",
        QT4_LRELEASEFLAGS="",
        # suffixes/prefixes for the headers / sources to generate
        QT4_UISUFFIX=".ui",
        QT4_UICDECLPREFIX="ui_",
        QT4_UICDECLSUFFIX=".h",
        QT4_MOCINCPREFIX="-I",
        QT4_MOCHPREFIX="moc_",
        QT4_MOCHSUFFIX="$CXXFILESUFFIX",
        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",
#.........这里部分代码省略.........
开发者ID:omarzandona,项目名称:Qviv,代码行数:101,代码来源:__init__.py

示例8: generate

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])
开发者ID:Siddharthk,项目名称:opticks,代码行数:90,代码来源:qt4.py

示例9: generate

def generate(env):
    """Add Builders and construction variables for qt to an Environment."""

    def locateQt4Command(env, command, qtdir):
        if len(qtdir) == 0:
            qtdir = "/usr"
        if env["qt5"]:
            suffixes = ["-qt5", "-qt5.exe", "5", "5.exe", "", ".exe"]
        else:
            suffixes = ["-qt4", "-qt4.exe", "4", "4.exe", "", ".exe"]
        triedPaths = []
        for suffix in suffixes:
            fullpath = os.path.join(qtdir, "bin", command + suffix)
            if os.access(fullpath, os.X_OK):
                return fullpath
            triedPaths.append(fullpath)

        fullpath = env.Detect([command + "-qt4", command + "4", command])
        if not (fullpath is None):
            return fullpath

        raise Exception("Qt4 command '" + command + "' not found. Tried: " + ", ".join(triedPaths))

    CLVar = SCons.Util.CLVar
    Action = SCons.Action.Action
    Builder = SCons.Builder.Builder
    splitext = SCons.Util.splitext

    env["QTDIR"] = _detect(env)
    # TODO: 'Replace' should be 'SetDefault'
    # 	env.SetDefault(
    env.Replace(
        QTDIR=_detect(env),
        # TODO: This is not reliable to QTDIR value changes but needed in order to support '-qt4' variants
        QT4_MOC=locateQt4Command(env, "moc", env["QTDIR"]),
        QT4_UIC=locateQt4Command(env, "uic", env["QTDIR"]),
        QT4_RCC=locateQt4Command(env, "rcc", env["QTDIR"]),
        QT4_LUPDATE=locateQt4Command(env, "lupdate", env["QTDIR"]),
        QT4_LRELEASE=locateQt4Command(env, "lrelease", env["QTDIR"]),
        QT4_LIB="",  # KLUDGE to avoid linking qt3 library
        QT4_AUTOSCAN=1,  # Should the qt tool try to figure out, which sources are to be moc'ed?
        # Some QT specific flags. I don't expect someone wants to
        # manipulate those ...
        QT4_UICFLAGS=CLVar(""),
        QT4_MOCFROMHFLAGS=CLVar(""),
        QT4_MOCFROMCXXFLAGS=CLVar("-i"),
        QT4_QRCFLAGS="",
        # suffixes/prefixes for the headers / sources to generate
        QT4_UISUFFIX=".ui",
        QT4_UICDECLPREFIX="ui_",
        QT4_UICDECLSUFFIX=".h",
        QT4_MOCHPREFIX="moc_",
        QT4_MOCHSUFFIX="$CXXFILESUFFIX",
        QT4_MOCCXXPREFIX="",
        QT4_MOCCXXSUFFIX=".moc",
        QT4_QRCSUFFIX=".qrc",
        QT4_QRCCXXSUFFIX="$CXXFILESUFFIX",
        QT4_QRCCXXPREFIX="qrc_",
        QT4_MOCCPPPATH=[],
        QT4_MOCINCFLAGS='$( ${_concat("-I", QT4_MOCCPPPATH, INCSUFFIX, __env__, RDirs)} $)',
        # Commands for the qt support ...
        QT4_UICCOM="$QT4_UIC $QT4_UICFLAGS -o $TARGET $SOURCE",
        # FIXME: The -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED flag is a hack to work
        # around an issue in Qt
        # See https://bugreports.qt-project.org/browse/QTBUG-22829
        QT4_MOCFROMHCOM="$QT4_MOC -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED $QT4_MOCFROMHFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE",
        QT4_MOCFROMCXXCOM=[
            "$QT4_MOC -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED $QT4_MOCFROMCXXFLAGS $QT4_MOCINCFLAGS -o $TARGET $SOURCE",
            Action(checkMocIncluded, None),
        ],
        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)
#.........这里部分代码省略.........
开发者ID:trungtran0689,项目名称:swift,代码行数:101,代码来源:qt4.py


注:本文中的SCons.Builder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。