Hi,
I have implemented code generation in qmake as shown here: http://wiki.qtcentre.org/index.php?t...cumented_qmake
Now I want to have translateable strings in the generated C++ source files. The only way this works right now is to manually specify all (generated) source files (as well as .ts files) on the command line when calling lupdate. Also I have to make sure to build the project right before calling lupdate... (otherwise, the generated sources might not exist, or might be out of date)...
I would like to change this so that l can just call "lupdate test.pro" and it will automatically figure out the generated source files and build them if needed...
Any ideas on how to do this?
Example code, using "cp" as a code generator :-)
test.pro:
SOURCES=main.cpp
TRANSLATIONS=test_de.ts
GEN_SOURCES = generated.gen
gen.input = GEN_SOURCES
gen.output = ${QMAKE_FILE_BASE}.cpp
gen.commands = cp ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
gen.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += gen
SOURCES=main.cpp
TRANSLATIONS=test_de.ts
GEN_SOURCES = generated.gen
gen.input = GEN_SOURCES
gen.output = ${QMAKE_FILE_BASE}.cpp
gen.commands = cp ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
gen.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += gen
To copy to clipboard, switch view to plain text mode
generated.gen:
#include <QCoreApplication>
#include <iostream>
void helloWorld()
{
std
::cout << qPrintable
( QCoreApplication::translate( "fooBar",
"Hello world!" ) ) << std
::endl;
}
#include <QCoreApplication>
#include <iostream>
void helloWorld()
{
std::cout << qPrintable( QCoreApplication::translate( "fooBar", "Hello world!" ) ) << std::endl;
}
To copy to clipboard, switch view to plain text mode
main.cpp:
#include <QCoreApplication>
void helloWorld();
int main( int argc, char** argv )
{
helloWorld();
return 0;
}
#include <QCoreApplication>
void helloWorld();
int main( int argc, char** argv )
{
QCoreApplication app( argc, argv );
helloWorld();
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks