Hi, I started to add a new generator for VisualDSP++ project files. VisualDSP++ is a IDE for embedded processors (Blackfin, SHARC and TigerSHARC).
The first file to create is the project group xml file which looks like that: <?xml version="1.0" encoding='ISO-8859-1'?> <visualdsp-project-group generated="Wed June 13 16:19:57 2007" version=" 1.0.0.0" active-project="toto"> <project name="tete" file="/home/raph/src/test/tete.dpj"> <dependencies> </dependencies> <project name="toto" file="/home/raph/src/test/toto.dpj"> <dependencies> <dependent-project>tata</dependent-project> </dependencies> <project name="sub" file="/home/raph/src/test/sub/sub.dpj"> <dependencies> </dependencies> </project> </visualdsp-project-group> Then each project has an xml file which look like that: <?xml version="1.0" encoding='ISO-8859-1'?> <visualdsp-project schema="16" name="toto" file="/home/raph/src/CMake/tata/toto.dpj" version="1"> <target> <processor revision="automatic">ADSP-BF533</processor> <extension>.dlb</extension> <type>Library file</type> </target> <configurations active="Debug"> <configuration name="Debug"> <output-dir>.</output-dir> <changed-property-page-flags>0</changed-property-page-flags> <tools> <tool type="Compiler"> <option><![CDATA[ -DOPTIMIZE_CODE_SIZE -DBOOST_ENABLE_ASSERT_HANDLER -threads |-Version>4.5|0|-no-circbuf>1|-eh -rtti>1|-check-init-order>0|-ignore-std>0|-const-read-write>0|-const-strings>0|-no-multiline>1|-D>DSP||-double-size-32>1|-double-size-any>0|-decls-strong>1|]]></option> </tool> </tools> </configuration> </configurations> <files> <file name="/home/raph/src/test/tete.cpp"> </file> <file name="/home/raph/src/test/toto.cpp"> </file> <file name="/home/raph/src/test/titi.cpp"> </file> </files> </visualdsp-project> Those 2 files were generated using this CMakeLists.txt: PROJECT( toto ) SET( CMAKE_SYSTEM_VERSION "automatic" ) SET( CMAKE_SYSTEM_NAME "ADSP-BF533" ) SET( CMAKE_BUILD_TYPE "Debug" ) SET( CMAKE_ACTIVE_PROJECT "tete" ) ADD_DEFINITIONS( -DOPTIMIZE_CODE_SIZE -DBOOST_ENABLE_ASSERT_HANDLER -threads |-Version>4.5|0|-no-circbuf>1|-eh -rtti>1|-check-init-order>0|-ignore-std>0|-const-read-write>0|-const-strings>0|-no-multiline>1|-D>DSP||-double-size-32>1|-double-size-any>0|-decls-strong>1| ) SET( SOURCES toto.cpp titi.cpp ) ADD_LIBRARY( toto ${SOURCES} ) ADD_LIBRARY( tete tete.cpp ) ADD_DEPENDENCIES( toto tata ) SUBDIRS( sub ) The generator is not complete but I'd like to have some feedback about my implementation. Thanks for your help Raphael
#ifndef cmGlobalVisualDSP4Generator_h #define cmGlobalVisualDSP4Generator_h #include "cmGlobalGenerator.h" /** \class cmGlobalVisualDSP4Generator * \brief Base class for global Visual Studio generators. * * cmGlobalVisualDSP4Generator provides functionality common to all * global Visual Studio generators. */ class cmGlobalVisualDSP4Generator : public cmGlobalGenerator { public: cmGlobalVisualDSP4Generator(); static cmGlobalGenerator* New() { return new cmGlobalVisualDSP4Generator; } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalVisualDSP4Generator::GetActualName();} static const char* GetActualName() {return "VisualDSP4";} /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); virtual void Generate(); virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *); virtual ~cmGlobalVisualDSP4Generator(); protected: private: }; #endif
/*========================================================================= Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualDSP4Generator.h,v $ Language: C++ Date: $Date: 2007/05/09 18:41:38 $ Version: $Revision: 1.18 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef cmLocalVisualDSP4Generator_h #define cmLocalVisualDSP4Generator_h #include "cmLocalGenerator.h" class cmMakeDepend; class cmTarget; class cmSourceFile; class cmSourceGroup; class cmCustomCommand; /** \class cmLocalVisualDSP4Generator * */ class cmLocalVisualDSP4Generator : public cmLocalGenerator { public: ///! Set cache only and recurse to false by default. cmLocalVisualDSP4Generator(); virtual ~cmLocalVisualDSP4Generator(); /** * Generate the makefile for this directory. */ virtual void Generate(); private: }; #endif
#include "cmGlobalVisualDSP4Generator.h" #include "cmLocalVisualDSP4Generator.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmTarget.h" #include "cmSourceFile.h" #include "cmSystemTools.h" cmGlobalVisualDSP4Generator::cmGlobalVisualDSP4Generator() { this->FindMakeProgramFile = "CMakeVDSP4FindMake.cmake"; } //---------------------------------------------------------------------------- cmGlobalVisualDSP4Generator::~cmGlobalVisualDSP4Generator() { } void cmGlobalVisualDSP4Generator ::GetDocumentation(cmDocumentationEntry& entry) const { entry.name = this->GetName(); entry.brief = "Generates VisualDSP 4 project files."; entry.full = "TODO"; } ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualDSP4Generator::CreateLocalGenerator() { cmLocalGenerator *lg = new cmLocalVisualDSP4Generator; lg->SetGlobalGenerator(this); return lg; } void cmGlobalVisualDSP4Generator::Generate() { // Run all the local generators. this->cmGlobalGenerator::Generate(); cmGeneratedFileStream fout; bool opened = false; if( this->LocalGenerators.size() > 0 ) { cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); const char* activeProject = mf->GetDefinition( "CMAKE_ACTIVE_PROJECT" ); if( activeProject == 0 ) activeProject = "UNSET"; std::string outputDir=mf->GetStartOutputDirectory(); std::string projectName=mf->GetProjectName(); std::string projectGroupName = outputDir + "/" + projectName + ".dpg"; fout.open(projectGroupName.c_str()); fout << "<?xml version=\"1.0\" encoding='ISO-8859-1'?>\n" << "<visualdsp-project-group generated=\"" << cmSystemTools::GetCurrentDateTime( "%a %B %d %H:%M:%S %Y" ) << "\" " << "version=\"1.0.0.0\" " << "active-project=\"" << activeProject << "\">\n"; opened = true; } unsigned int i; for(i = 0; i < this->LocalGenerators.size(); ++i) { cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); std::string outputDir=mf->GetStartOutputDirectory(); cmTargets targets = mf->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { std::string projectNameFile = outputDir + "/" + l->second.GetName() + ".dpj"; fout << " <project name=\"" << l->second.GetName() << "\" file=\"" << projectNameFile << "\">\n" << " <dependencies>\n"; const std::set<cmStdString>& deps = l->second.GetUtilities(); for(std::set<cmStdString>::const_iterator dep = deps.begin(); dep != deps.end(); ++dep) { fout << " <dependent-project>" << *dep << "</dependent-project>\n"; } fout << " </dependencies>\n"; } } if( opened ) { fout << " </project>\n" << "</visualdsp-project-group>"; } } void cmGlobalVisualDSP4Generator::EnableLanguage( std::vector<std::string>const& languages, cmMakefile *mf) { }
/*========================================================================= Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualDSP4Generator.cxx,v $ Language: C++ Date: $Date: 2007/05/09 18:41:38 $ Version: $Revision: 1.122 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "cmGlobalGenerator.h" #include "cmLocalVisualDSP4Generator.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmSystemTools.h" #include "cmSourceFile.h" #include "cmCacheManager.h" #include "cmake.h" #include <cmsys/RegularExpression.hxx> cmLocalVisualDSP4Generator::cmLocalVisualDSP4Generator() { } cmLocalVisualDSP4Generator::~cmLocalVisualDSP4Generator() { } void cmLocalVisualDSP4Generator::Generate() { std::string outputDir=this->Makefile->GetStartOutputDirectory(); std::string projectDir=this->Makefile->GetHomeDirectory(); std::string projectName=this->Makefile->GetProjectName(); const char* cpuRev = this->Makefile->GetDefinition( "CMAKE_SYSTEM_VERSION" ); if( cpuRev == 0 ) cpuRev = "UNSET"; const char* cpuName = this->Makefile->GetDefinition( "CMAKE_SYSTEM_NAME" ); if( cpuName == 0 ) cpuName = "UNSET"; const char* buildType = this->Makefile->GetDefinition( "CMAKE_BUILD_TYPE" ); if( buildType == 0 ) buildType = "UNSET"; const char* binaryDir = this->Makefile->GetHomeOutputDirectory(); if( binaryDir == 0 ) binaryDir = "UNSET"; //std::vector<std::string> definitions = GetDefinitions std::string compilerFlags( this->Makefile->GetDefineFlags() ); cmTargets& targets = this->Makefile->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { std::string targetName = l->second.GetName(); std::string projectNameFile = outputDir + "/" + targetName + ".dpj"; cmGeneratedFileStream fout2(projectNameFile.c_str()); std::string extension( "unset" ); std::string type( "unset" ); switch( l->second.GetType() ) { case cmTarget::EXECUTABLE: extension = ".ldr"; type = "Loader file"; break; case cmTarget::STATIC_LIBRARY: extension = ".dlb"; type = "Library file"; break; case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_PROGRAMS: case cmTarget::INSTALL_DIRECTORY: break; } fout2 << "<?xml version=\"1.0\" encoding='ISO-8859-1'?>\n" << "<visualdsp-project schema=\"16\" name=\"" << targetName << "\" " << "file=\"" << projectNameFile << "\" version=\"1\">\n" << " <target>\n" << " <processor revision=\"" << cpuRev << "\">" << cpuName << "</processor>\n" << " <extension>" << extension << "</extension>\n" << " <type>" << type << "</type>\n" << " </target>\n"; fout2 << " <configurations active=\"" << buildType << "\">\n" << " <configuration name=\"" << buildType << "\">\n" << " <output-dir>.</output-dir>\n" << " <changed-property-page-flags>0</changed-property-page-flags>\n" << " <tools>\n" << " <tool type=\"Compiler\">\n" << " <option><![CDATA[" << compilerFlags << "]]></option>\n" << " </tool>\n" << " </tools>\n" << " </configuration>\n" << " </configurations>\n"; fout2 << " <files>\n"; const std::vector<cmSourceFile*> sourceFiles = this->Makefile->GetSourceFiles(); for (std::vector<cmSourceFile*>::const_iterator it=sourceFiles.begin(); it!=sourceFiles.end(); it++) { fout2 << " <file name=\"" << (*it)->GetFullPath() << "\">\n" << " </file>\n"; } fout2 << " </files>\n" << "</visualdsp-project>"; } }
_______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake