? |
Implements IProjectFactory.
Definition at line 99 of file cmt_project.cxx.
References Tag::add(), Project::add(), CmtSystem::cd(), CmtSystem::compress_path(), cmt_string::find(), Project::get_cmtpath(), Project::get_cmtpath_pwd(), Project::get_name(), Project::get_project_file_name(), ProjectReader::get_project_name(), m_first, m_id, m_previous, Tag::mark(), SyntaxParser::parse_project_file_text(), PriorityConfig, Project::projects(), CmtSystem::pwd(), cmt_string::read(), Awk::run(), Project::set_cmtpath(), Project::set_cmtpath_pwd(), Project::set_cmtpath_source(), Project::set_predecessor(), cmt_vector< Project >::size(), and CmtSystem::test_file().
00101 {
00102 cmt_string compressed_path = path;
00103 CmtSystem::compress_path (compressed_path);
00104
00105 static Project::ProjectVector& Projects = Project::projects ();
00106
00107 for (int i = 0; i < Projects.size (); i++)
00108 {
00109 Project& p = Projects[i];
00110
00111 if (p.get_cmtpath () == compressed_path) return;
00112 if (p.get_cmtpath_pwd () == compressed_path) return;
00113 }
00114
00115 Project* project = 0;
00116 Project* cmt = 0;
00117
00118 bool is_current = false;
00119
00120 cmt_string here = CmtSystem::pwd ();
00121 if (!CmtSystem::cd (compressed_path)) return;
00122
00123 cmt_string pwd = CmtSystem::pwd ();
00124 if (here.find (pwd) == 0) is_current = true;
00125
00126 cmt_string text;
00127
00128 if (CmtSystem::cd ("cmt") && CmtSystem::test_file (Project::get_project_file_name ()))
00129 {
00130 text.read (Project::get_project_file_name ());
00131
00132 ProjectReader reader;
00133
00134 reader.run (text);
00135
00136 cmt_string name = reader.get_project_name ();
00137 if (name == "")
00138 {
00139 char buffer[20];
00140 m_id++;
00141 sprintf (buffer, "Project%d", m_id);
00142 name = buffer;
00143 }
00144
00145 project = Project::add (name);
00146
00147 }
00148 else
00149 {
00150 char buffer[20];
00151 if (source == "default path")
00152 {
00153 strcpy (buffer, "CMT");
00154 }
00155 else
00156 {
00157 m_id++;
00158 sprintf (buffer, "Project%d", m_id);
00159 }
00160 project = Project::add (buffer);
00161 }
00162
00163 if (source == "default path")
00164 {
00165 cmt = project;
00166 is_current = false;
00167 }
00168 else
00169 {
00170 if (m_first == 0)
00171 {
00172 m_first = project;
00173 }
00174 }
00175
00176 project->set_cmtpath (compressed_path);
00177 project->set_cmtpath_pwd (pwd);
00178 project->set_cmtpath_source (source);
00179
00180 if (is_current)
00181 {
00182 Tag* tag;
00183
00184 tag = Tag::add (project->get_name (), PriorityConfig, "PROJECT", 0);
00185 tag->mark ();
00186 }
00187
00188 if (m_previous != 0) m_previous->set_predecessor (project);
00189 m_previous = project;
00190
00191 if (text != "")
00192 {
00193 SyntaxParser::parse_project_file_text (text,
00194 Project::get_project_file_name (),
00195 project);
00196 }
00197
00198 CmtSystem::cd (here);
00199 }
|