root/trunk/projectsettings.cpp

Revision 5, 4.6 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 #include "stdafx.h"
2 #include "ElSettings\ProjectSettings.h"
3 #include "Elephant.h"
4
5 bool ProjectSettings::Save()
6 {
7    
8     CMainFrame* mf = static_cast<CMainFrame*>(Globals::theApp.m_pMainWnd);
9    
10     if ( mf )
11     {
12         vector<string> files = mf->GetAllNamedFiles();
13         SetCache("sessionFiles",Join(files,",") );
14     }
15    
16     return ISettings::Save();
17 }
18
19
20 string ProjectSettings::GetFullPathFor(const string & relativePath )
21 {
22     string oldDir = getCurDir();
23     SetCurrentDirectory(relativePath.c_str());
24     string dir = getCurDir();
25     SetCurrentDirectory(oldDir.c_str() );
26    
27     return dir;
28    
29 }
30 void ProjectSettings::AddUniqueProjectNode(const string& _path)
31 {
32
33         string path = LowerCase(_path);
34
35         string pathCompare = StripFileName(path);
36         StripExtension(pathCompare );
37
38         string thisPath = LowerCase(this->path + "\\" + this->name + ".dprj" );
39         if ( thisPath == path ) return ;
40
41         vector<string> projects;
42         Split(GetCache("AddOnProjects"),",",projects);
43        
44         bool found = false;
45        
46         for ( int i = 0 ; i < projects.size(); i++)
47         {
48             string projectItem = StripFileName(projects[i]);
49             StripExtension(projectItem);
50
51             if ( projectItem == pathCompare )
52             {
53                 found = true;
54                 break;
55             }
56             else continue;
57            
58         }
59        
60         if ( !found )
61         {
62             projects.push_back(path);
63         }
64
65         SetCache("AddOnProjects",Join(projects,","));
66
67 }
68
69
70 ProjectError ProjectSettings::CreateProject(const ProjectSpecs& p, int config  )
71 {
72     SetCurrentDirectory(this->path.c_str());
73    
74     string defaultFolder = "Project Files";
75     string defaultConfig = "Default";
76
77     SetCache(defaultConfig + "_versionIdentifiers",p.versionIdentifiers);
78     SetCache(defaultConfig + "_targetName",name);
79     SetCache(defaultConfig + "_debugIdentifiers",p.debugIdentifiers);
80     SetCache(defaultConfig + "_libraries",p.libraries);
81     SetCache(defaultConfig + "_inline",p.inlin );
82     SetCache(defaultConfig + "_allobj",p.allobj );
83     SetCache(defaultConfig + "_allowDeprecated",p.allowDeprecated );
84     SetCache(defaultConfig + "_clean",p.clean );
85     SetCache(defaultConfig + "_debugG",p.debug );
86     SetCache(defaultConfig + "_dll",p.dll );
87     SetCache(defaultConfig + "_full",p.full );
88     SetCache(defaultConfig + "_gui",p.gui );
89     SetCache(defaultConfig + "_lib",p.lib );
90     SetCache(defaultConfig + "_link",p.link );
91     SetCache(defaultConfig + "_obj",p.obj );
92     SetCache(defaultConfig + "_names",p.names );
93     SetCache(defaultConfig + "_release",p.release );
94     SetCache(defaultConfig + "_warnings",p.warnings );
95     SetCache(defaultConfig + "_test",p.test );
96     SetCache(defaultConfig + "_pHooks",p.pHooks );
97     SetCache(defaultConfig + "_verbose",p.verbose );
98     SetCache(defaultConfig + "_optimize",p.optimize );
99     SetCache(defaultConfig + "_nolib",p.nolib );
100     SetCache(defaultConfig + "_nolink",p.nolink );
101     SetCache(defaultConfig + "_full",p.full );
102     SetCache(defaultConfig + "_silent",p.silent );
103     SetCache(defaultConfig + "_gui",p.gui );
104     SetCache(defaultConfig + "_v",p.v );
105     SetCache(defaultConfig + "_unittest",p.unittest );
106     SetCache(defaultConfig + "_M",p.M );
107     SetCache(defaultConfig + "_X",p.X );
108
109
110     SetCache("buildType","0");
111     SetCache("libraries",p.libraries);
112     SetCache("ProjectFolders",defaultFolder);
113     SetCache("Configurations",defaultConfig);
114     SetCache("CurrentConfiguration",defaultConfig);
115    
116     string buildFile = name + "_buildtarget.d";
117     SetCache("BuildMainFile",buildFile);
118
119
120     vector<string> files;
121    
122     string userName = Globals::settings->baseSettings->GetCache("name");
123    
124     files.push_back(buildFile);
125     SetCache(buildFile + "_folderForFile",defaultFolder);
126    
127    
128     int i = 0 ;
129     for (  i = 0 ; i < p.files.size();i++ )
130     {
131         string dest(path + "\\" + StripFileName(p.files[i]) );
132         if ( !CopyTemplateFile(p.files[i].c_str(),dest , userName, this->name ) ) return COULDNT_COPY_FILES;
133         string fileName = StripFileName(p.files[i]);
134         files.push_back(fileName);
135         SetCache(fileName + "_folderForFile",defaultFolder);
136     }
137    
138     SetCache("files",Join(files,","));
139    
140
141     //AfxMessageBox(buildFile.c_str());
142     ofstream out(buildFile.c_str());
143     out << "\n";
144     out << "\n\nversion (build) \n{\n";
145     for ( i = 1 ; i < files.size();i++ )
146     {
147
148         CString str = files[i].substr(0,files[i].length() - 2 ).c_str() ;
149         str.Replace("\\",".");
150        
151         out << "\tprivate import " << str.GetBuffer(0) << ";\n";
152     }
153        
154     vector<string> libraries;
155     Split(p.libraries,",",libraries);
156     if ( libraries.size() )
157     {
158        
159         for (  i = 0 ; i < libraries.size(); i++ )
160         {
161             out << "\tpragma(link,\"" << libraries[i] << "\");\n";
162         }
163
164        
165     }
166
167     out << "}\n";
168     out << std::flush;
169     out.close();
170     //AfxMessageBox("done");
171        
172     Save();
173    
174     return PROJECT_SUCCESS;
175 }
Note: See TracBrowser for help on using the browser.