diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 82e9448..79b7fee 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -18,6 +18,11 @@ # If not already set before, it also sets # _CMAKE_TOOLCHAIN_PREFIX +IF(SYMBIAN) + INCLUDE(CMakeForceCompiler) + CMAKE_FORCE_C_COMPILER(sdk "SDK Compiler") +ENDIF(SYMBIAN) + IF(NOT CMAKE_C_COMPILER) SET(CMAKE_CXX_COMPILER_INIT NOTFOUND) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 87abffa..3f5cebb 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -17,6 +17,11 @@ # If not already set before, it also sets # _CMAKE_TOOLCHAIN_PREFIX +IF(SYMBIAN) + INCLUDE(CMakeForceCompiler) + CMAKE_FORCE_CXX_COMPILER(sdk "SDK Compiler") +ENDIF(SYMBIAN) + IF(NOT CMAKE_CXX_COMPILER) SET(CMAKE_CXX_COMPILER_INIT NOTFOUND) diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index aa3b59b..c64ab6e 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -60,6 +60,10 @@ ELSE(CMAKE_HOST_UNIX) ENDIF(CMAKE_HOST_WIN32) ENDIF(CMAKE_HOST_UNIX) +IF(CMAKE_GENERATOR MATCHES "Symbian SDK .mmp projects") + SET(CMAKE_SYSTEM_NAME "Symbian") +ENDIF(CMAKE_GENERATOR MATCHES "Symbian SDK .mmp projects") + # if a toolchain file is used, the user wants to cross compile. # in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_* # variables around so they can be used in CMakeLists.txt. diff --git a/Modules/CMakeSymbianFindMake.cmake b/Modules/CMakeSymbianFindMake.cmake new file mode 100755 index 0000000..100810d --- /dev/null +++ b/Modules/CMakeSymbianFindMake.cmake @@ -0,0 +1,3 @@ +SET(CMAKE_MAKE_PROGRAM bldmake CACHE STRING "") +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) +SET(SYMBIAN 1) diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 561f5e3..c2f7761 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -12,6 +12,7 @@ SET(APPLE ) SET(UNIX ) SET(CYGWIN ) SET(WIN32 ) +SET(SYMBIAN ) # include Generic system information diff --git a/Modules/Platform/Symbian.cmake b/Modules/Platform/Symbian.cmake new file mode 100644 index 0000000..ff2d255 --- /dev/null +++ b/Modules/Platform/Symbian.cmake @@ -0,0 +1,23 @@ +# Symbian + +SET(SYMBIAN 1) + +IF(CMAKE_HOST_UNIX) + INCLUDE(Platform/UnixPaths) + SET(UNIX ) # why does UnixPath set this? +ELSE(CMAKE_HOST_UNIX) + INCLUDE(Platform/WindowsPaths) +ENDIF(CMAKE_HOST_UNIX) + +SET(CMAKE_STATIC_LIBRARY_PREFIX "") +SET(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") +SET(CMAKE_SHARED_LIBRARY_PREFIX "") # lib +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so +SET(CMAKE_IMPORT_LIBRARY_PREFIX "") +SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib") +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe +SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib") +SET(CMAKE_DL_LIBS "") + +SET(CMAKE_FIND_LIBRARY_PREFIXES "") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b4a04f5..d2c46bf 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -155,6 +155,8 @@ SET(SRCS cmGeneratedFileStream.cxx cmGlobalGenerator.cxx cmGlobalGenerator.h + cmGlobalSymbianMmpGenerator.cxx + cmGlobalSymbianMmpGenerator.h cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h cmGraphAdjacencyList.h @@ -174,6 +176,8 @@ SET(SRCS cmListFileLexer.c cmLocalGenerator.cxx cmLocalGenerator.h + cmLocalSymbianMmpGenerator.cxx + cmLocalSymbianMmpGenerator.h cmLocalUnixMakefileGenerator3.cxx cmMakeDepend.cxx cmMakeDepend.h @@ -201,6 +205,7 @@ SET(SRCS cmSourceFileLocation.h cmSourceGroup.cxx cmSourceGroup.h + cmSymbianResource.h cmSystemTools.cxx cmSystemTools.h cmTarget.cxx diff --git a/Source/cmAddSymbianBitmapCommand.cxx b/Source/cmAddSymbianBitmapCommand.cxx new file mode 100644 index 0000000..de2a7a0 --- /dev/null +++ b/Source/cmAddSymbianBitmapCommand.cxx @@ -0,0 +1,64 @@ +#include "cmAddSymbianBitmapCommand.h" + +bool cmAddSymbianBitmapCommand::InitialPass(std::vector const& args, + cmExecutionStatus&) +{ + if (args.size() < 3) + return false; + + std::vector::const_iterator i = args.begin(); + cmTarget* target = Makefile->FindTarget(i->c_str()); + + if (!target) + { + std::string msg = "Target " + *i + " not found"; + SetError(msg.c_str()); + return false; + } + + cmSymbianResource res; + res.type = cmSymbianResource::BITMAP; + res.target = *(++i); + ++i; + + for (; i != args.end(); ++i) + { + if (*i == "TARGETPATH") + { + if (++i == args.end()) + { + SetError("The TARGETPATH argument must be followed by symbian target path"); + return false; + } + res.targetpath = *i; + } + else if (*i == "HEADER") + { + res.header = true; + } + else if (*i == "SOURCE") + { + if (++i == args.end() || i+1 == args.end()) + { + SetError("The SOURCE argument must be followed by image depth " + "and relative path to the image"); + return false; + } + + cmSymbianBitmapSource image; + image.depth = *i; + image.filename = Makefile->GetStartDirectory(); + image.filename += "/" + *(++i); + res.images.push_back(image); + } + else + { + std::string msg = "Unknown extra parameter \"" + *i +"\""; + SetError(msg.c_str()); + return false; + } + } + + target->AddSymbianResource(res); + return true; +} diff --git a/Source/cmAddSymbianBitmapCommand.h b/Source/cmAddSymbianBitmapCommand.h new file mode 100644 index 0000000..065a886 --- /dev/null +++ b/Source/cmAddSymbianBitmapCommand.h @@ -0,0 +1,33 @@ +#ifndef cmAddSymbianBitmapCommand_h +#define cmAddSymbianBitmapCommand_h + +#include "cmCommand.h" + +class cmAddSymbianBitmapCommand : public cmCommand +{ +public: + virtual cmCommand* Clone() + { + return new cmAddSymbianBitmapCommand; + } + + virtual bool InitialPass(std::vector const &args, + cmExecutionStatus &status); + + virtual const char* GetName() { return "add_symbian_bitmap"; } + + virtual const char* GetTerseDocumentation() + { + return "Add symbian bitmap."; + } + + virtual const char* GetFullDocumentation() + { + return ""; + } + + cmTypeMacro(cmAddSymbianBitmapCommand, cmCommand); +}; + + +#endif diff --git a/Source/cmAddSymbianResourceCommand.cxx b/Source/cmAddSymbianResourceCommand.cxx new file mode 100644 index 0000000..bbb3109 --- /dev/null +++ b/Source/cmAddSymbianResourceCommand.cxx @@ -0,0 +1,78 @@ +#include "cmAddSymbianResourceCommand.h" + +bool cmAddSymbianResourceCommand::InitialPass(std::vector const &args, + cmExecutionStatus&) +{ + if (args.size() < 3) + return false; + + std::vector::const_iterator i = args.begin(); + cmTarget* target = Makefile->FindTarget(i->c_str()); + + if (!target) + { + std::string msg = "Target " + *i + " not found"; + SetError(msg.c_str()); + return false; + } + + cmSymbianResource res; + res.filename = Makefile->GetStartDirectory(); + res.filename += "/" + *(++i); + ++i; + + for (; i != args.end(); ++i) + { + if (*i == "TARGET") + { + if (++i == args.end()) + { + SetError("The TARGET argument must be followed by symbian target file name"); + return false; + } + res.target = *i; + } + else if (*i == "TARGETPATH") + { + if (++i == args.end()) + { + SetError("The TARGETPATH argument must be followed by symbian target path"); + return false; + } + res.targetpath = *i; + } + else if (*i == "HEADER") + { + res.header = true; + } + else if (*i == "LANG") + { + if (++i == args.end()) + { + SetError("The LANG argument must be followed by langueage codes " + "for the symbian resource"); + return false; + } + res.lang = *i; + } + else if (*i == "UID") + { + if (++i == args.end()) + { + SetError("The UID argument must be followed by second and " + "optionally third uid for symbian resource"); + return false; + } + res.uid = *i; + } + else + { + std::string msg = "Unknown extra parameter \"" + *i +"\""; + SetError(msg.c_str()); + return false; + } + } + + target->AddSymbianResource(res); + return true; +} diff --git a/Source/cmAddSymbianResourceCommand.h b/Source/cmAddSymbianResourceCommand.h new file mode 100644 index 0000000..d727a19 --- /dev/null +++ b/Source/cmAddSymbianResourceCommand.h @@ -0,0 +1,33 @@ +#ifndef cmAddSymbianResourceCommand_h +#define cmAddSymbianResourceCommand_h + +#include "cmCommand.h" + +class cmAddSymbianResourceCommand : public cmCommand +{ +public: + virtual cmCommand* Clone() + { + return new cmAddSymbianResourceCommand; + } + + virtual bool InitialPass(std::vector const &args, + cmExecutionStatus &status); + + virtual const char* GetName() { return "add_symbian_resource"; } + + virtual const char* GetTerseDocumentation() + { + return "Add symbian resource."; + } + + virtual const char* GetFullDocumentation() + { + return ""; + } + + cmTypeMacro(cmAddSymbianResourceCommand, cmCommand); +}; + + +#endif diff --git a/Source/cmBootstrapCommands.cxx b/Source/cmBootstrapCommands.cxx index 56ab238..bc406a7 100644 --- a/Source/cmBootstrapCommands.cxx +++ b/Source/cmBootstrapCommands.cxx @@ -26,6 +26,8 @@ #include "cmAddExecutableCommand.cxx" #include "cmAddLibraryCommand.cxx" #include "cmAddSubDirectoryCommand.cxx" +#include "cmAddSymbianBitmapCommand.cxx" +#include "cmAddSymbianResourceCommand.cxx" #include "cmAddTestCommand.cxx" #include "cmBreakCommand.cxx" #include "cmBuildCommand.cxx" @@ -103,6 +105,8 @@ void GetBootstrapCommands(std::list& commands) commands.push_back(new cmAddExecutableCommand); commands.push_back(new cmAddLibraryCommand); commands.push_back(new cmAddSubDirectoryCommand); + commands.push_back(new cmAddSymbianBitmapCommand); + commands.push_back(new cmAddSymbianResourceCommand); commands.push_back(new cmAddTestCommand); commands.push_back(new cmBreakCommand); commands.push_back(new cmBuildCommand); diff --git a/Source/cmGlobalSymbianMmpGenerator.cxx b/Source/cmGlobalSymbianMmpGenerator.cxx new file mode 100644 index 0000000..677ba0d --- /dev/null +++ b/Source/cmGlobalSymbianMmpGenerator.cxx @@ -0,0 +1,60 @@ +#include "cmGlobalSymbianMmpGenerator.h" +#include "cmLocalSymbianMmpGenerator.h" +#include "cmCacheManager.h" +#include "cmMakefile.h" +#include "cmSystemTools.h" +#include "cmake.h" + +#include + +cmGlobalSymbianMmpGenerator::cmGlobalSymbianMmpGenerator() +{ + this->FindMakeProgramFile = "CMakeSymbianFindMake.cmake"; +} + +cmLocalGenerator *cmGlobalSymbianMmpGenerator::CreateLocalGenerator() +{ + cmLocalSymbianMmpGenerator* lg = new cmLocalSymbianMmpGenerator; + lg->SetGlobalGenerator(this); + return lg; +} + +void cmGlobalSymbianMmpGenerator::Generate() +{ + cmGlobalGenerator::Generate(); + + std::string filename = GetCMakeInstance()->GetStartOutputDirectory(); + filename += "/bld.inf"; + std::ofstream bld_inf(filename.c_str()); + bld_inf << "prj_mmpfiles" << std::endl; + + std::vector basedir_components; + cmSystemTools::SplitPath(GetCMakeInstance()->GetStartOutputDirectory(), + basedir_components); + + for (size_t i = 0; i < LocalGenerators.size(); ++i) + { + cmTargets targets = LocalGenerators[i]->GetMakefile()->GetTargets(); + + for (cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + { + if (t->second.GetType() == cmTarget::UTILITY) + bld_inf << "gnumakefile "; + + std::string prj = LocalGenerators[i]->GetMakefile()->GetStartOutputDirectory(); + prj += (prj.length() > 0 ? "/" : ""); + prj += t->first + (t->second.GetType() == cmTarget::UTILITY ? ".mk" : ".mmp"); + bld_inf << LocalGenerators[i]->ConvertToRelativePath(basedir_components, prj.c_str()) << std::endl; + } + } +} + +void cmGlobalSymbianMmpGenerator::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Symbian SDK .mmp project files."; + entry.Full = + "The .mmp files can be used to build a project in usual Symbian " + "way using SDK tools."; +} + diff --git a/Source/cmGlobalSymbianMmpGenerator.h b/Source/cmGlobalSymbianMmpGenerator.h new file mode 100644 index 0000000..38b84ea --- /dev/null +++ b/Source/cmGlobalSymbianMmpGenerator.h @@ -0,0 +1,30 @@ +#ifndef cmGlobalSymbianMmpGenerator_h +#define cmGlobalSymbianMmpGenerator_h + +#include "cmGlobalGenerator.h" + +class cmTarget; + +class cmGlobalSymbianMmpGenerator : public cmGlobalGenerator +{ +public: + static cmGlobalGenerator* New() + {return new cmGlobalSymbianMmpGenerator;} + + virtual cmLocalGenerator *CreateLocalGenerator(); + + virtual const char* GetName() const + { return cmGlobalSymbianMmpGenerator::GetActualName(); } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + virtual void Generate(); + + static const char* GetActualName() + {return "Symbian SDK .mmp projects"; } + +private: + cmGlobalSymbianMmpGenerator(); +}; + +#endif diff --git a/Source/cmLocalSymbianMmpGenerator.cxx b/Source/cmLocalSymbianMmpGenerator.cxx new file mode 100644 index 0000000..5c63bf4 --- /dev/null +++ b/Source/cmLocalSymbianMmpGenerator.cxx @@ -0,0 +1,371 @@ +#include "cmLocalSymbianMmpGenerator.h" +#include "cmGlobalGenerator.h" +#include "cmMakefile.h" +#include "cmTarget.h" +#include "cmSourceFile.h" +#include "cmake.h" + +#include +#include +#include +#include + +#define MMP_COLUMN_WIDTH 20 +#define MMP_INDENT " " + +void cmLocalSymbianMmpGenerator::Generate() +{ + cmTargets::iterator i = Makefile->GetTargets().begin(); + for (; i != Makefile->GetTargets().end(); ++i) + { + if (i->second.GetType() == cmTarget::UTILITY) + { + writeMakefile(i->second); + } + else + { + writeMmp(i->second); + } + } +} + +void cmLocalSymbianMmpGenerator::writeMmp(cmTarget& target) +{ + std::string targetName = target.GetName(); + std::string filename = Makefile->GetStartOutputDirectory(); + filename += "/" + targetName + ".mmp"; + std::ofstream mmp(filename.c_str()); + + writeTargetType(target, mmp); + addGenericOption(target, "UID", mmp); + addGenericOption(target, "SECUREID", mmp); + addGenericOption(target, "VENDORID", mmp); + addGenericOption(target, "EPOCSTACKSIZE", mmp); + addGenericOption(target, "EPOCHEAPSIZE", mmp); + addGenericOption(target, "CAPABILITY", mmp); + mmp << std::endl; + + addDefinitions(target, mmp); + addRawData(target, mmp); + + addResources(target, mmp); + addIncludes(mmp); + addSources(target, mmp); + + if (target.GetType() != cmTarget::STATIC_LIBRARY) + addLibraries(target, mmp); +} + +void cmLocalSymbianMmpGenerator::writeTargetType(cmTarget& target, std::ostream& mmp) +{ + std::string varName = target.GetName(); + varName += "_SYMBIAN_TARGETTYPE"; + const char* targettype = Makefile->GetDefinition(varName.c_str()); + + if (!targettype) + { + switch (target.GetType()) + { + case cmTarget::EXECUTABLE: + targettype = "exe"; + break; + case cmTarget::SHARED_LIBRARY: + targettype = "dll"; + break; + case cmTarget::STATIC_LIBRARY: + targettype = "lib"; + break; + } + } + + mmp << keyword_with_param("TARGET") << target.GetName() + << "." << targettype_extension(targettype) << std::endl; + + mmp << keyword_with_param("TARGETTYPE") << targettype << std::endl; +} + +std::string cmLocalSymbianMmpGenerator::addGenericOption(cmTarget& target, + const std::string& option, + std::ostream& mmp) +{ + std::string varName = target.GetName(); + varName += "_SYMBIAN_" + option; + const char* raw_value = Makefile->GetDefinition(varName.c_str()); + + if (raw_value) + { + std::string value = raw_value; + replaceSemicolons(value, ' '); + mmp << keyword_with_param(option) << value << std::endl; + } + + return raw_value ? raw_value : ""; +} + +void cmLocalSymbianMmpGenerator::addIncludes(std::ostream& mmp) +{ + std::vector& includes = Makefile->GetIncludeDirectories(); + std::vector::iterator inc = includes.begin(); + for (; inc != includes.end(); ++inc) + { + std::string path = ConvertToRelativePath(StartOutputDirectoryComponents, + inc->c_str()); + mmp << keyword_with_param("SYSTEMINCLUDE") << path << std::endl; + } + + if (includes.size() > 0) + { + mmp << std::endl; + } +} + +void cmLocalSymbianMmpGenerator::addDefinitions(cmTarget& target, std::ostream& mmp) +{ + bool need_newline = false; + + if (writeMacros(mmp, Makefile->GetProperty("COMPILE_DEFINITIONS"))) + need_newline = true; + + if (writeMacros(mmp, target.GetProperty("COMPILE_DEFINITIONS"))) + need_newline = true; + + if (need_newline) + mmp << std::endl; +} + +void cmLocalSymbianMmpGenerator::addResources(cmTarget& target, std::ostream& mmp) +{ + const std::vector& resources = target.GetSymbianResources(); + std::vector::const_iterator res = resources.begin(); + for (; res != resources.end(); ++res) + { + if (res->type == cmSymbianResource::GENERIC) + { + writeGenericResource(*res, mmp); + } + else if (res->type == cmSymbianResource::BITMAP) + { + writeBitmap(*res, mmp); + } + } +} + +void cmLocalSymbianMmpGenerator::addSources(cmTarget& target, std::ostream& mmp) +{ + std::vector const& sources = target.GetSourceFiles(); + std::vector::const_iterator src = sources.begin(); + + for (; src != sources.end(); ++src) + { + std::vector::const_iterator ext; + ext = std::find(Makefile->GetHeaderExtensions().begin(), + Makefile->GetHeaderExtensions().end(), + (*src)->GetExtension()); + + // skip headers + if (ext != Makefile->GetHeaderExtensions().end()) + { + continue; + } + + mmp << keyword_with_param("SOURCE"); + mmp << ConvertToRelativePath(StartOutputDirectoryComponents, + (*src)->GetFullPath().c_str()); + mmp << std::endl; + } + + if (sources.size() > 0) + { + mmp << std::endl; + } +} + +void cmLocalSymbianMmpGenerator::addLibraries(cmTarget& target, std::ostream& mmp) +{ + cmTarget::LinkLibraryVectorType libraries = target.GetLinkLibraries(); + cmTarget::LinkLibraryVectorType::iterator lib = libraries.begin(); + for (; lib != libraries.end(); ++lib) + { + if (lib->second != cmTarget::IMPORT) + { + mmp << keyword_with_param("STATICLIBRARY"); + } + else + { + mmp << keyword_with_param("LIBRARY"); + } + mmp << lib->first; + mmp << (cmSystemTools::StringEndsWith(lib->first.c_str(), ".lib") ? "" : ".lib"); + mmp << std::endl; + } + + if (libraries.size() > 0) + { + mmp << std::endl; + } +} + +void cmLocalSymbianMmpGenerator::addRawData(cmTarget& target, std::ostream& mmp) +{ + std::string varName = target.GetName(); + varName += "_SYMBIAN_RAW_DATA"; + const char* raw_value = Makefile->GetDefinition(varName.c_str()); + + if (raw_value) + { + std::string value = raw_value; + replaceSemicolons(value, '\n'); + mmp << value << std::endl; + mmp << std::endl; + } +} + +bool cmLocalSymbianMmpGenerator::writeMacros(std::ostream& mmp, const char* macros) +{ + if (! macros) + return false; + + std::string values = macros; + replaceSemicolons(values, ' '); + mmp << keyword_with_param("MACRO") << values << std::endl; + return true; +} + +void cmLocalSymbianMmpGenerator::writeGenericResource(const cmSymbianResource& res, + std::ostream& mmp) +{ + mmp << keyword_with_param("START RESOURCE"); + mmp << ConvertToRelativePath(StartOutputDirectoryComponents, + res.filename.c_str()); + mmp << std::endl; + + if (!res.target.empty()) + { + mmp << MMP_INDENT << keyword_with_param("TARGET") + << res.target << std::endl; + } + + if (!res.targetpath.empty()) + { + mmp << MMP_INDENT << keyword_with_param("TARGETPATH") + << res.targetpath << std::endl; + } + + if (res.header) + { + mmp << MMP_INDENT << "HEADER" << std::endl; + } + + if (!res.lang.empty()) + { + mmp << MMP_INDENT << keyword_with_param("LANG") + << res.lang << std::endl; + } + + if (!res.uid.empty()) + { + mmp << MMP_INDENT << keyword_with_param("UID") << res.uid << std::endl; + } + + mmp << "END" << std::endl << std::endl; +} + +void cmLocalSymbianMmpGenerator::writeBitmap(const cmSymbianResource& res, + std::ostream& mmp) +{ + mmp << keyword_with_param("START BITMAP") << res.target << std::endl; + + if (!res.targetpath.empty()) + { + mmp << MMP_INDENT << keyword_with_param("TARGETPATH") + << res.targetpath << std::endl; + } + + if (res.header) + { + mmp << MMP_INDENT << "HEADER" << std::endl; + } + + std::list::const_iterator img = res.images.begin(); + for (; img != res.images.end(); ++img) + { + mmp << MMP_INDENT << keyword_with_param("SOURCE"); + mmp << img->depth << " "; + mmp << ConvertToRelativePath(StartOutputDirectoryComponents, + img->filename.c_str()); + mmp << std::endl; + } + + mmp << "END" << std::endl << std::endl; +} + +std::string +cmLocalSymbianMmpGenerator::keyword_with_param(const std::string& option) +{ + std::string keyword = option; + for (unsigned int i = 0; i < MMP_COLUMN_WIDTH - option.length() + 1; ++i) + { + keyword += ' '; + } + + return keyword; +} + +std::string +cmLocalSymbianMmpGenerator::targettype_extension(const std::string& targettype) +{ + return targettype; +} + +void cmLocalSymbianMmpGenerator::writeMakefile(cmTarget& target) +{ + std::string targetName = target.GetName(); + std::string filename = Makefile->GetStartOutputDirectory(); + filename += "/" + targetName + ".mk"; + std::ofstream mk(filename.c_str()); + + mk << "bld:" << std::endl; + + cmCustomCommand* cmd = target.GetSourceFiles()[0]->GetCustomCommand(); + + if (cmd->GetWorkingDirectory()) + { + std::string dir = cmd->GetWorkingDirectory(); +#ifdef _WIN32 + for (unsigned int i = 0; i < dir.size(); ++i) + { + if (dir[i] == '/') + { + dir[i] = '\\'; + } + } +#endif + mk << "\t\tcd " << dir; + } + + cmCustomCommandLines::const_iterator cmdline = cmd->GetCommandLines().begin(); + for (; cmdline != cmd->GetCommandLines().end(); ++cmdline) + { + mk << ";"; + std::vector::const_iterator i = cmdline->begin(); + mk << *(i++); + for (; i != cmdline->end(); ++i) + { + mk << " " << *i; + } + } + + mk << std::endl; + mk << "makmake freeze lib cleanlib clean final resource savespace releaseables:"; + mk << std::endl << std::endl; +} + +void cmLocalSymbianMmpGenerator::replaceSemicolons(std::string& s, char newSeparator) +{ + std::string::size_type semicolon_pos = s.find(';'); + while (semicolon_pos != std::string::npos) + { + s[semicolon_pos] = newSeparator; + semicolon_pos = s.find(';', semicolon_pos); + } +} diff --git a/Source/cmLocalSymbianMmpGenerator.h b/Source/cmLocalSymbianMmpGenerator.h new file mode 100644 index 0000000..dda03c2 --- /dev/null +++ b/Source/cmLocalSymbianMmpGenerator.h @@ -0,0 +1,37 @@ +#ifndef cmLocalSymbianMmpGenerator_h +#define cmLocalSymbianMmpGenerator_h + +#include "cmLocalGenerator.h" +#include "cmTarget.h" + +class cmLocalSymbianMmpGenerator : public cmLocalGenerator +{ +public: + void Generate(); + +private: + void writeMmp(cmTarget& target); + void writeTargetType(cmTarget& target, std::ostream& mmp); + + std::string addGenericOption(cmTarget& target, const std::string& option, + std::ostream& mmp); + void addIncludes(std::ostream& mmp); + void addResources(cmTarget& target, std::ostream& mmp); + void addSources(cmTarget& target, std::ostream& mmp); + void addLibraries(cmTarget& target, std::ostream& mmp); + void addDefinitions(cmTarget& target, std::ostream& mmp); + void addRawData(cmTarget& target, std::ostream& mmp); + + bool writeMacros(std::ostream& mmp, const char* macros); + void writeGenericResource(const cmSymbianResource& res, std::ostream& mmp); + void writeBitmap(const cmSymbianResource& res, std::ostream& mmp); + + static std::string keyword_with_param(const std::string& option); + static std::string targettype_extension(const std::string& targettype); + + void writeMakefile(cmTarget& target); + + static void replaceSemicolons(std::string& s, char newSeparator); +}; + +#endif diff --git a/Source/cmSymbianResource.h b/Source/cmSymbianResource.h new file mode 100644 index 0000000..fe515d8 --- /dev/null +++ b/Source/cmSymbianResource.h @@ -0,0 +1,28 @@ +#ifndef cmSymbianResource_h +#define cmSymbianResource_h + +#include "cmStandardIncludes.h" + +struct cmSymbianBitmapSource +{ + std::string filename; + std::string depth; +}; + +struct cmSymbianResource +{ + enum Type {GENERIC, BITMAP}; + + Type type; + bool header; + std::string lang; + std::string filename; + std::list images; + std::string target; + std::string targetpath; + std::string uid; + + cmSymbianResource() : header(false), type(GENERIC) {} +}; + +#endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 98917fe..658c448 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -747,7 +747,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Check whether this is a DLL platform. this->DLLPlatform = (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") || - this->Makefile->IsOn("MINGW")); + this->Makefile->IsOn("MINGW") || + this->Makefile->IsOn("SYMBIAN")); // Setup default property values. this->SetPropertyDefault("INSTALL_NAME_DIR", ""); @@ -1370,6 +1371,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, case cmTarget::OPTIMIZED: dependencies += "optimized"; break; + case cmTarget::IMPORT: + dependencies += "import"; + break; } dependencies += ";"; dependencies += lib; @@ -1660,6 +1664,10 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, { llt = cmTarget::GENERAL; } + else if (l == "import") + { + llt = cmTarget::IMPORT; + } else { LibraryID lib2(l,llt); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 419adb1..6ed19da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -20,6 +20,7 @@ #include "cmCustomCommand.h" #include "cmPropertyMap.h" #include "cmPolicies.h" +#include "cmSymbianResource.h" class cmake; class cmMakefile; @@ -175,7 +176,7 @@ public: /** * Get the list of the source files used by this target */ - enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; + enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED, IMPORT}; //* how we identify a library, by name and type typedef std::pair LibraryID; @@ -237,6 +238,15 @@ public: ///! Get the utilities used by this target std::setconst& GetUtilities() const { return this->Utilities; } + /** + * Add Symbian resource declaration to the target + */ + void AddSymbianResource(const cmSymbianResource& res) + {this->SymbianResources.push_back(res);} + ///! Get the symbian resources used by this target + const std::vector& GetSymbianResources() + {return this->SymbianResources;} + void AnalyzeLibDependencies( const cmMakefile& mf ); ///! Set/Get a property of this target file @@ -567,6 +577,9 @@ private: friend class cmTargetInternals; cmTargetInternalPointer Internal; + // Symbian resources associated with the target + std::vector SymbianResources; + void ConstructSourceFileFlags(); }; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 96eb4c4..4937b0e 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -16,11 +16,12 @@ =========================================================================*/ #include "cmTargetLinkLibrariesCommand.h" -const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] = +const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[4] = { "general", "debug", - "optimized" + "optimized", + "import" }; // cmTargetLinkLibrariesCommand @@ -106,6 +107,15 @@ bool cmTargetLinkLibrariesCommand llt = cmTarget::GENERAL; haveLLT = true; } + else if(args[i] == "import") + { + if(haveLLT) + { + this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::IMPORT); + } + llt = cmTarget::IMPORT; + haveLLT = true; + } else if(haveLLT) { // The link type was specified by the previous argument. diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index e4161f6..e0431cc 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -107,7 +107,7 @@ public: cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: void LinkLibraryTypeSpecifierWarning(int left, int right); - static const char* LinkLibraryTypeNames[3]; + static const char* LinkLibraryTypeNames[4]; cmTarget* Target; bool DoingInterface; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index cd8974b..5ae87a4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -77,6 +77,7 @@ # include "cmWin32ProcessExecution.h" #else #endif +#include "cmGlobalSymbianMmpGenerator.h" #include "cmGlobalUnixMakefileGenerator3.h" #if defined(CMAKE_HAVE_VS_GENERATORS) @@ -2430,6 +2431,8 @@ void cmake::AddDefaultGenerators() this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] = &cmGlobalMinGWMakefileGenerator::New; #endif + this->Generators[cmGlobalSymbianMmpGenerator::GetActualName()] = + &cmGlobalSymbianMmpGenerator::New; this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = &cmGlobalUnixMakefileGenerator3::New; #ifdef CMAKE_USE_XCODE