Support for the Qt4 libraries and tools:
def options(opt):
opt.load('compiler_cxx qt4')
def configure(conf):
conf.load('compiler_cxx qt4')
conf.env.append_value('CXXFLAGS', ['-g']) # test
def build(bld):
bld(
features = 'qt4 cxx cxxprogram',
uselib = 'QTCORE QTGUI QTOPENGL QTSVG',
source = 'main.cpp textures.qrc aboutDialog.ui',
target = 'window',
)
The C++ files must include the .moc files, which is regarded as the best practice (much faster compilations). This also implies that the include paths have to be set properly. To have the include paths added automatically, use the following:
from waflib.TaskGen import feature, before_method, after_method
@feature('cxx')
@after_method('process_source')
@before_method('apply_incpaths')
def add_includes_paths(self):
incs = set(self.to_list(getattr(self, 'includes', '')))
for x in self.compiled_tasks:
incs.add(x.inputs[0].parent.path_from(self.path))
self.includes = list(incs)
Another tool provides a Qt processing that does not require the moc includes. See http://code.google.com/p/waf/source/browse/trunk/playground/slow_qt/
Interface for receiving logical document content events.
This is the main callback interface in SAX, and the one most important to applications. The order of events in this interface mirrors the order of the information in the document.
Receive notification of character data.
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.
Receive notification of the end of a document.
The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.
Signals the end of an element in non-namespace mode.
The name parameter contains the name of the element type, just as with the startElement event.
Signals the end of an element in namespace mode.
The name parameter contains the name of the element type, just as with the startElementNS event.
End the scope of a prefix-URI mapping.
See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.
Receive notification of ignorable whitespace in element content.
Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.
SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.
The application must not attempt to read from the array outside of the specified range.
Receive notification of a processing instruction.
The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.
A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.
Called by the parser to give the application a locator for locating the origin of document events.
SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.
The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application’s business rules). The information returned by the locator is probably not sufficient for use with a search engine.
Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.
Receive notification of a skipped entity.
The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.
Receive notification of the beginning of a document.
The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).
Signals the start of an element in non-namespace mode.
The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.
Signals the start of an element in namespace mode.
The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.
The uri part of the name tuple is None for elements which have no namespace.
Begin the scope of a prefix-URI Namespace mapping.
The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).
There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.
Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.
File extensions associated to the .moc files
File extension for the resource (.qrc) files
File extension for the user interface (.ui) files
File extensions of C++ files that may require a .moc processing
Bases: waflib.Tools.cxx.cxx
Each C++ file can have zero or several .moc files to create. They are known only when the files are scanned (preprocessor) To avoid scanning the c++ files each time (parsing C/C++), the results are retrieved from the task cache (bld.node_deps/bld.raw_deps). The moc tasks are also created dynamically during the build.
Compute the task signature to make sure the scanner was executed. Create the moc tasks by using waflib.Tools.qt4.qxx.add_moc_tasks() (if necessary), then postpone the task execution (there is no need to recompute the task signature).
Bases: waflib.Task.Task
Update a .ts files from a list of C++ files
Bases: xml.sax.handler.ContentHandler
Parser for .qrc files
Task generator method
Add MOC_FLAGS which may be necessary for moc:
def build(bld):
bld.program(features='qt4', source='main.cpp', target='app', use='QTCORE')
The additional parameters are:
Parameters: |
|
---|---|
Feature : |
Re-map C++ file extensions to the waflib.Tools.qt4.qxx task.
Bases: waflib.Task.Task
Process .qrc files
Bases: waflib.Task.Task
Create .moc files
Bases: waflib.Task.Task
Process .ui files
Bases: waflib.Task.Task
Create .qm files from .ts files
Bases: waflib.Task.Task
Transform .qm files into .rc files
Besides the configuration options, the environment variable QT4_ROOT may be used to give the location of the qt4 libraries (absolute path).
The detection will use the program pkg-config through waflib.Tools.config_c.check_cfg()
Configuration Method bound to waflib.Configure.ConfigurationContext
Decorator: attach new configuration functions to waflib.Build.BuildContext and waflib.Configure.ConfigurationContext. The methods bound will accept a parameter named ‘mandatory’ to disable the configuration errors:
def configure(conf):
conf.find_program('abc', mandatory=False)
Parameters: | f (function) – method to bind |
---|
Configuration Method bound to waflib.Configure.ConfigurationContext
Decorator: register a task generator method that will be executed when the object attribute ‘feature’ contains the corresponding key(s):
from waflib.Task import feature
@feature('myfeature')
def myfunction(self):
print('that is my feature!')
def build(bld):
bld(features='myfeature')
Parameters: | k (list of string) – feature names |
---|
Decorator: register a task generator method which will be executed after the functions of given name(s):
from waflib.TaskGen import feature, after
@feature('myfeature')
@after_method('fun2')
def fun1(self):
print('feature 1!')
@feature('myfeature')
def fun2(self):
print('feature 2!')
def build(bld):
bld(features='myfeature')
Parameters: | k (list of string) – method names |
---|
Decorator: register a task generator method which will be invoked during the processing of source files for the extension given:
from waflib import Task
class mytask(Task):
run_str = 'cp ${SRC} ${TGT}'
@extension('.moo')
def create_maa_file(self, node):
self.create_task('mytask', node, node.change_ext('.maa'))
def build(bld):
bld(source='foo.moo')
Configuration Method bound to waflib.Configure.ConfigurationContext
Configuration Method bound to waflib.Configure.ConfigurationContext
Configuration Method bound to waflib.Configure.ConfigurationContext
Features defined in this module: