mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 03:50:40 +02:00
Add --version to the Oven
This commit is contained in:
parent
1b225a777a
commit
be534f2127
3 changed files with 64 additions and 21 deletions
|
@ -24,12 +24,23 @@ static const QString CLI_OUTPUT_PARAMETER = "o";
|
||||||
static const QString CLI_TYPE_PARAMETER = "t";
|
static const QString CLI_TYPE_PARAMETER = "t";
|
||||||
static const QString CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER = "disable-texture-compression";
|
static const QString CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER = "disable-texture-compression";
|
||||||
|
|
||||||
|
QUrl OvenCLIApplication::_inputUrlParameter;
|
||||||
|
QUrl OvenCLIApplication::_outputUrlParameter;
|
||||||
|
QString OvenCLIApplication::_typeParameter;
|
||||||
|
|
||||||
OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) :
|
OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) :
|
||||||
QCoreApplication(argc, argv)
|
QCoreApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
BakerCLI* cli = new BakerCLI(this);
|
||||||
|
QMetaObject::invokeMethod(cli, "bakeFile", Qt::QueuedConnection, Q_ARG(QUrl, _inputUrlParameter),
|
||||||
|
Q_ARG(QString, _outputUrlParameter.toString()), Q_ARG(QString, _typeParameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OvenCLIApplication::parseCommandLine(int argc, char* argv[]) {
|
||||||
// parse the command line parameters
|
// parse the command line parameters
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
|
|
||||||
|
parser.setApplicationDescription("High Fidelity Oven");
|
||||||
parser.addOptions({
|
parser.addOptions({
|
||||||
{ CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" },
|
{ CLI_INPUT_PARAMETER, "Path to file that you would like to bake.", "input" },
|
||||||
{ CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" },
|
{ CLI_OUTPUT_PARAMETER, "Path to folder that will be used as output.", "output" },
|
||||||
|
@ -37,25 +48,45 @@ OvenCLIApplication::OvenCLIApplication(int argc, char* argv[]) :
|
||||||
{ CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER, "Disable texture compression." }
|
{ CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER, "Disable texture compression." }
|
||||||
});
|
});
|
||||||
|
|
||||||
parser.addHelpOption();
|
auto versionOption = parser.addVersionOption();
|
||||||
parser.process(*this);
|
auto helpOption = parser.addHelpOption();
|
||||||
|
|
||||||
if (parser.isSet(CLI_INPUT_PARAMETER) && parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
QStringList arguments;
|
||||||
BakerCLI* cli = new BakerCLI(this);
|
for (int i = 0; i < argc; ++i) {
|
||||||
QUrl inputUrl(QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER)));
|
arguments << argv[i];
|
||||||
QUrl outputUrl(QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER)));
|
|
||||||
QString type = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString::null;
|
|
||||||
|
|
||||||
if (parser.isSet(CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER)) {
|
|
||||||
qDebug() << "Disabling texture compression";
|
|
||||||
TextureBaker::setCompressionEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(cli, "bakeFile", Qt::QueuedConnection, Q_ARG(QUrl, inputUrl),
|
|
||||||
Q_ARG(QString, outputUrl.toString()), Q_ARG(QString, type));
|
|
||||||
} else {
|
|
||||||
parser.showHelp();
|
|
||||||
QCoreApplication::quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!parser.parse(arguments)) {
|
||||||
|
std::cout << parser.errorText().toStdString() << std::endl; // Avoid Qt log spam
|
||||||
|
QCoreApplication mockApp(argc, argv); // required for call to showHelp()
|
||||||
|
parser.showHelp();
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(versionOption)) {
|
||||||
|
parser.showVersion();
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
if (parser.isSet(helpOption)) {
|
||||||
|
QCoreApplication mockApp(argc, argv); // required for call to showHelp()
|
||||||
|
parser.showHelp();
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parser.isSet(CLI_INPUT_PARAMETER) || !parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
||||||
|
std::cout << "Error: Input and Output not set" << std::endl; // Avoid Qt log spam
|
||||||
|
QCoreApplication mockApp(argc, argv); // required for call to showHelp()
|
||||||
|
parser.showHelp();
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
_inputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_INPUT_PARAMETER));
|
||||||
|
_outputUrlParameter = QDir::fromNativeSeparators(parser.value(CLI_OUTPUT_PARAMETER));
|
||||||
|
|
||||||
|
_typeParameter = parser.isSet(CLI_TYPE_PARAMETER) ? parser.value(CLI_TYPE_PARAMETER) : QString::null;
|
||||||
|
|
||||||
|
if (parser.isSet(CLI_DISABLE_TEXTURE_COMPRESSION_PARAMETER)) {
|
||||||
|
qDebug() << "Disabling texture compression";
|
||||||
|
TextureBaker::setCompressionEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,14 @@ class OvenCLIApplication : public QCoreApplication, public Oven {
|
||||||
public:
|
public:
|
||||||
OvenCLIApplication(int argc, char* argv[]);
|
OvenCLIApplication(int argc, char* argv[]);
|
||||||
|
|
||||||
|
static void parseCommandLine(int argc, char* argv[]);
|
||||||
|
|
||||||
static OvenCLIApplication* instance() { return dynamic_cast<OvenCLIApplication*>(QCoreApplication::instance()); }
|
static OvenCLIApplication* instance() { return dynamic_cast<OvenCLIApplication*>(QCoreApplication::instance()); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QUrl _inputUrlParameter;
|
||||||
|
static QUrl _outputUrlParameter;
|
||||||
|
static QString _typeParameter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_OvenCLIApplication_h
|
#endif // hifi_OvenCLIApplication_h
|
||||||
|
|
|
@ -18,14 +18,19 @@
|
||||||
int main (int argc, char** argv) {
|
int main (int argc, char** argv) {
|
||||||
setupHifiApplication("Oven");
|
setupHifiApplication("Oven");
|
||||||
|
|
||||||
// init the settings interface so we can save and load settings
|
|
||||||
Setting::init();
|
|
||||||
|
|
||||||
// figure out if we're launching our GUI application or just the simple command line interface
|
// figure out if we're launching our GUI application or just the simple command line interface
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
|
OvenCLIApplication::parseCommandLine(argc, argv);
|
||||||
|
|
||||||
|
// init the settings interface so we can save and load settings
|
||||||
|
Setting::init();
|
||||||
|
|
||||||
OvenCLIApplication app { argc, argv };
|
OvenCLIApplication app { argc, argv };
|
||||||
return app.exec();
|
return app.exec();
|
||||||
} else {
|
} else {
|
||||||
|
// init the settings interface so we can save and load settings
|
||||||
|
Setting::init();
|
||||||
|
|
||||||
OvenGUIApplication app { argc, argv };
|
OvenGUIApplication app { argc, argv };
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue