2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2001-11-27 06:40:31 +03:00
|
|
|
#include "cmFLTKWrapUICommand.h"
|
|
|
|
|
2004-02-22 21:14:59 +03:00
|
|
|
#include "cmSourceFile.h"
|
|
|
|
|
2001-11-27 06:40:31 +03:00
|
|
|
// cmFLTKWrapUICommand
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus&)
|
2001-11-27 06:40:31 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (args.size() < 2) {
|
2001-11-27 06:40:31 +03:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-27 06:40:31 +03:00
|
|
|
|
|
|
|
// what is the current source dir
|
2015-04-16 22:17:41 +03:00
|
|
|
std::string cdir = this->Makefile->GetCurrentSourceDirectory();
|
2005-02-22 18:32:44 +03:00
|
|
|
const char* fluid_exe =
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
|
2001-11-27 06:40:31 +03:00
|
|
|
|
2001-12-11 10:21:18 +03:00
|
|
|
// get parameter for the command
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Target = args[0]; // Target that will use the generated files
|
2001-11-27 06:40:31 +03:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
// get the list of GUI files from which .cxx and .h will be generated
|
2015-04-16 22:33:09 +03:00
|
|
|
std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory();
|
2001-12-21 17:55:57 +03:00
|
|
|
|
2013-01-20 15:28:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
// Some of the generated files are *.h so the directory "GUI"
|
|
|
|
// where they are created have to be added to the include path
|
|
|
|
std::vector<std::string> outputDirectories;
|
|
|
|
outputDirectories.push_back(outputDirectory);
|
|
|
|
this->Makefile->AddIncludeDirectories(outputDirectories);
|
2013-01-20 15:28:59 +04:00
|
|
|
}
|
2001-12-03 02:22:19 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = (args.begin() + 1);
|
|
|
|
i != args.end(); i++) {
|
|
|
|
cmSourceFile* curr = this->Makefile->GetSource(*i);
|
2012-08-13 21:42:58 +04:00
|
|
|
// if we should use the source GUI
|
2001-11-28 22:45:20 +03:00
|
|
|
// to generate .cxx and .h files
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) {
|
2007-06-18 19:59:23 +04:00
|
|
|
std::string outName = outputDirectory;
|
|
|
|
outName += "/";
|
|
|
|
outName += cmSystemTools::GetFilenameWithoutExtension(*i);
|
|
|
|
std::string hname = outName;
|
|
|
|
hname += ".h";
|
2002-06-27 23:57:09 +04:00
|
|
|
std::string origname = cdir + "/" + *i;
|
2001-11-28 22:45:20 +03:00
|
|
|
// add starting depends
|
2003-07-14 17:31:29 +04:00
|
|
|
std::vector<std::string> depends;
|
|
|
|
depends.push_back(origname);
|
2006-04-24 19:30:57 +04:00
|
|
|
depends.push_back(fluid_exe);
|
2007-06-18 19:59:23 +04:00
|
|
|
std::string cxxres = outName;
|
2003-07-14 18:13:30 +04:00
|
|
|
cxxres += ".cxx";
|
2005-02-22 18:32:44 +03:00
|
|
|
|
|
|
|
cmCustomCommandLine commandLine;
|
|
|
|
commandLine.push_back(fluid_exe);
|
|
|
|
commandLine.push_back("-c"); // instructs Fluid to run in command line
|
|
|
|
commandLine.push_back("-h"); // optionally rename .h files
|
|
|
|
commandLine.push_back(hname);
|
|
|
|
commandLine.push_back("-o"); // optionally rename .cxx files
|
|
|
|
commandLine.push_back(cxxres);
|
2016-05-16 17:34:04 +03:00
|
|
|
commandLine.push_back(origname); // name of the GUI fluid file
|
2005-02-22 18:32:44 +03:00
|
|
|
cmCustomCommandLines commandLines;
|
|
|
|
commandLines.push_back(commandLine);
|
|
|
|
|
2003-07-14 17:31:29 +04:00
|
|
|
// Add command for generating the .h and .cxx files
|
2014-02-25 05:32:55 +04:00
|
|
|
std::string no_main_dependency = "";
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* no_comment = CM_NULLPTR;
|
|
|
|
const char* no_working_dir = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
cxxres, depends, no_main_dependency, commandLines, no_comment,
|
|
|
|
no_working_dir);
|
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
hname, depends, no_main_dependency, commandLines, no_comment,
|
|
|
|
no_working_dir);
|
|
|
|
|
|
|
|
cmSourceFile* sf = this->Makefile->GetSource(cxxres);
|
2007-05-28 18:11:44 +04:00
|
|
|
sf->AddDepend(hname.c_str());
|
|
|
|
sf->AddDepend(origname.c_str());
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GeneratedSourcesClasses.push_back(sf);
|
2001-11-27 06:40:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-10 18:09:17 +04:00
|
|
|
|
|
|
|
// create the variable with the list of sources in it
|
2006-03-15 19:02:08 +03:00
|
|
|
size_t lastHeadersClass = this->GeneratedSourcesClasses.size();
|
2005-06-10 18:09:17 +04:00
|
|
|
std::string sourceListValue;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t classNum = 0; classNum < lastHeadersClass; classNum++) {
|
|
|
|
if (classNum) {
|
2005-06-10 18:09:17 +04:00
|
|
|
sourceListValue += ";";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
sourceListValue += this->GeneratedSourcesClasses[classNum]->GetFullPath();
|
|
|
|
}
|
2006-03-15 19:02:08 +03:00
|
|
|
std::string varName = this->Target;
|
2005-06-10 18:09:17 +04:00
|
|
|
varName += "_FLTK_UI_SRCS";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(varName, sourceListValue.c_str());
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2001-11-27 06:40:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
void cmFLTKWrapUICommand::FinalPass()
|
2001-11-27 06:40:31 +03:00
|
|
|
{
|
2005-06-10 18:09:17 +04:00
|
|
|
// people should add the srcs to the target themselves, but the old command
|
|
|
|
// didn't support that, so check and see if they added the files in and if
|
|
|
|
// they didn;t then print a warning and add then anyhow
|
2016-04-01 17:26:08 +03:00
|
|
|
cmTarget* target = this->Makefile->FindLocalNonAliasTarget(this->Target);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!target) {
|
2012-08-13 21:42:58 +04:00
|
|
|
std::string msg =
|
2008-06-23 19:08:57 +04:00
|
|
|
"FLTK_WRAP_UI was called with a target that was never created: ";
|
|
|
|
msg += this->Target;
|
2016-05-16 17:34:04 +03:00
|
|
|
msg += ". The problem was found while processing the source directory: ";
|
2015-04-16 21:06:54 +03:00
|
|
|
msg += this->Makefile->GetCurrentSourceDirectory();
|
2008-06-23 19:08:57 +04:00
|
|
|
msg += ". This FLTK_WRAP_UI call will be ignored.";
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::Message(msg.c_str(), "Warning");
|
2008-06-23 19:08:57 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-27 06:40:31 +03:00
|
|
|
}
|