| [1] | 1 | //-----------------------------------------------------------
|
|---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS
|
|---|
| 3 | // arnault@lal.in2p3.fr
|
|---|
| 4 | // See the complete license in cmt_license.txt "http://www.cecill.info".
|
|---|
| 5 | //-----------------------------------------------------------
|
|---|
| 6 |
|
|---|
| 7 | #include <stdio.h>
|
|---|
| 8 | #include <stdlib.h>
|
|---|
| 9 | #include <string.h>
|
|---|
| 10 | #include <ctype.h>
|
|---|
| 11 |
|
|---|
| 12 | //----------------------------------------------------------
|
|---|
| 13 |
|
|---|
| 14 | #include "cmt_parser.h"
|
|---|
| 15 | #include "cmt_version.h"
|
|---|
| 16 |
|
|---|
| 17 | #include "cmt_database.h"
|
|---|
| 18 | #include "cmt_include.h"
|
|---|
| 19 | #include "cmt_script.h"
|
|---|
| 20 | #include "cmt_generator.h"
|
|---|
| 21 | #include "cmt_system.h"
|
|---|
| 22 | #include "cmt.h"
|
|---|
| 23 | #include "cmt_error.h"
|
|---|
| 24 | #include "cmt_cvs.h"
|
|---|
| 25 | #include "cmt_lock.h"
|
|---|
| 26 | #include "cmt_triggers.h"
|
|---|
| 27 | #include "cmt_model.h"
|
|---|
| 28 | #include "cmt_awk.h"
|
|---|
| 29 | #include "cmt_syntax.h"
|
|---|
| 30 | #include "cmt_install_area.h"
|
|---|
| 31 | #include "cmt_cmtpath_pattern.h"
|
|---|
| 32 | #include "cmt_sequence.h"
|
|---|
| 33 | #include "cmt_map.h"
|
|---|
| 34 | #include "cmt_project.h"
|
|---|
| 35 | #include "cmt_log.h"
|
|---|
| 36 |
|
|---|
| 37 | //----------------------------------------------------------
|
|---|
| 38 | //
|
|---|
| 39 | // Static object definitions for the Cmt class.
|
|---|
| 40 | //
|
|---|
| 41 |
|
|---|
| 42 | ActionType Cmt::m_action;
|
|---|
| 43 | ActionType Cmt::m_help_action;
|
|---|
| 44 | bool Cmt::m_build_nmake;
|
|---|
| 45 | cmt_string Cmt::m_cmt_config;
|
|---|
| 46 | cmt_string Cmt::m_cmt_root;
|
|---|
| 47 | cmt_string Cmt::m_cmt_home;
|
|---|
| 48 | cmt_string Cmt::m_cmt_user_context;
|
|---|
| 49 | cmt_string Cmt::m_cmt_site;
|
|---|
| 50 | cmt_string Cmt::m_cmt_version;
|
|---|
| 51 | int Cmt::m_current_build_strategy = DefaultBuildStrategy;
|
|---|
| 52 | int Cmt::m_current_setup_strategy = DefaultSetupStrategy;
|
|---|
| 53 |
|
|---|
| 54 | cmt_string Cmt::m_current_dir;
|
|---|
| 55 | cmt_string Cmt::m_current_package;
|
|---|
| 56 | cmt_string Cmt::m_current_config;
|
|---|
| 57 | cmt_string Cmt::m_current_path;
|
|---|
| 58 | cmt_string Cmt::m_current_prefix;
|
|---|
| 59 | cmt_string Cmt::m_current_cmtpath;
|
|---|
| 60 | cmt_string Cmt::m_current_offset;
|
|---|
| 61 |
|
|---|
| 62 | AccessMode Cmt::m_current_access = UserMode;
|
|---|
| 63 | CmtDirStyle Cmt::m_current_style = cmt_style;
|
|---|
| 64 | CmtStructuringStyle Cmt::m_current_structuring_style = with_version_directory;
|
|---|
| 65 |
|
|---|
| 66 | cmt_string Cmt::m_current_tag;
|
|---|
| 67 | cmt_string Cmt::m_current_target;
|
|---|
| 68 | cmt_string Cmt::m_current_version;
|
|---|
| 69 |
|
|---|
| 70 | cmt_string Cmt::m_extra_tags;
|
|---|
| 71 |
|
|---|
| 72 | cmt_string Cmt::m_configure_error;
|
|---|
| 73 |
|
|---|
| 74 | bool Cmt::m_debug;
|
|---|
| 75 |
|
|---|
| 76 | cmt_string Cmt::m_default_path;
|
|---|
| 77 | bool Cmt::m_quiet;
|
|---|
| 78 | bool Cmt::m_recursive;
|
|---|
| 79 | CmtScopeFilteringMode Cmt::m_scope_filtering_mode;
|
|---|
| 80 | bool Cmt::m_simulation;
|
|---|
| 81 | bool Cmt::m_standard_macros_done;
|
|---|
| 82 | //----------------------------------------------------------
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | //----------------------------------------------------------
|
|---|
| 86 | //
|
|---|
| 87 | // Utility classes
|
|---|
| 88 | //
|
|---|
| 89 | //----------------------------------------------------------
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * This PathScanner actor simply displays the package name/version/path
|
|---|
| 95 | * It is used by the cmt show packages operation
|
|---|
| 96 | */
|
|---|
| 97 | class PackageViewer : public PathScanner::actor
|
|---|
| 98 | {
|
|---|
| 99 | public:
|
|---|
| 100 | void run (const cmt_string& package,
|
|---|
| 101 | const cmt_string& version,
|
|---|
| 102 | const cmt_string& path);
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | /**
|
|---|
| 107 | * This PathScanner actor accumulates all found packages into a cmt_string_vector
|
|---|
| 108 | * It is used by the broadcast operation
|
|---|
| 109 | */
|
|---|
| 110 | class PackageSelector : public PathScanner::actor
|
|---|
| 111 | {
|
|---|
| 112 | public:
|
|---|
| 113 | PackageSelector (CmtSystem::cmt_string_vector& uses);
|
|---|
| 114 | void run (const cmt_string& package,
|
|---|
| 115 | const cmt_string& version,
|
|---|
| 116 | const cmt_string& path);
|
|---|
| 117 | private:
|
|---|
| 118 | CmtSystem::cmt_string_vector& m_uses;
|
|---|
| 119 | };
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 | /**
|
|---|
| 124 | * This PathScanner actor collects all packages clients of the specified one
|
|---|
| 125 | * It is used by the cmt show clients operation
|
|---|
| 126 | */
|
|---|
| 127 | class ClientCollector : public PathScanner::actor
|
|---|
| 128 | {
|
|---|
| 129 | public:
|
|---|
| 130 | ClientCollector (const cmt_string& package,
|
|---|
| 131 | const cmt_string& version);
|
|---|
| 132 | void run (const cmt_string& package,
|
|---|
| 133 | const cmt_string& version,
|
|---|
| 134 | const cmt_string& path);
|
|---|
| 135 | int count ();
|
|---|
| 136 |
|
|---|
| 137 | private:
|
|---|
| 138 | const cmt_string& m_package;
|
|---|
| 139 | const cmt_string& m_version;
|
|---|
| 140 | int m_count;
|
|---|
| 141 | };
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | //----------------------------------------------------------
|
|---|
| 145 | static int get_build_strategy ()
|
|---|
| 146 | {
|
|---|
| 147 | Project* p = Project::get_current ();
|
|---|
| 148 |
|
|---|
| 149 | int strategy = 0;
|
|---|
| 150 |
|
|---|
| 151 | if (p == 0) strategy = Cmt::get_current_build_strategy ();
|
|---|
| 152 | else strategy = p->get_build_strategy ();
|
|---|
| 153 |
|
|---|
| 154 | return (strategy);
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | //----------------------------------------------------------
|
|---|
| 158 | static int get_setup_strategy ()
|
|---|
| 159 | {
|
|---|
| 160 | Project* p = Project::get_current ();
|
|---|
| 161 |
|
|---|
| 162 | int strategy = 0;
|
|---|
| 163 |
|
|---|
| 164 | if (p == 0) strategy = Cmt::get_current_setup_strategy ();
|
|---|
| 165 | else strategy = p->get_setup_strategy ();
|
|---|
| 166 |
|
|---|
| 167 | return (strategy);
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | //----------------------------------------------------------
|
|---|
| 171 | void PackageViewer::run (const cmt_string& package,
|
|---|
| 172 | const cmt_string& version,
|
|---|
| 173 | const cmt_string& path)
|
|---|
| 174 | {
|
|---|
| 175 | cout << package << " " << version << " " << path << endl;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | //----------------------------------------------------------
|
|---|
| 179 | PackageSelector::PackageSelector (CmtSystem::cmt_string_vector& uses) : m_uses(uses)
|
|---|
| 180 | {
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | //----------------------------------------------------------
|
|---|
| 184 | void PackageSelector::run (const cmt_string& package,
|
|---|
| 185 | const cmt_string& version,
|
|---|
| 186 | const cmt_string& path)
|
|---|
| 187 | {
|
|---|
| 188 | //
|
|---|
| 189 | // this might be called on a package with no version directory.
|
|---|
| 190 | // then simply the version argument is empty.
|
|---|
| 191 | //
|
|---|
| 192 |
|
|---|
| 193 | cmt_string r = CmtSystem::file_separator ();
|
|---|
| 194 | r += "requirements";
|
|---|
| 195 |
|
|---|
| 196 | cmt_string temp;
|
|---|
| 197 |
|
|---|
| 198 | if (version == "")
|
|---|
| 199 | {
|
|---|
| 200 | temp = path;
|
|---|
| 201 | //temp += CmtSystem::file_separator ();
|
|---|
| 202 | //temp += package;
|
|---|
| 203 | temp += CmtSystem::file_separator ();
|
|---|
| 204 | temp += "cmt";
|
|---|
| 205 | temp += r;
|
|---|
| 206 |
|
|---|
| 207 | if (!CmtSystem::test_file (temp)) return;
|
|---|
| 208 | }
|
|---|
| 209 | else
|
|---|
| 210 | {
|
|---|
| 211 | temp = path;
|
|---|
| 212 | //temp += CmtSystem::file_separator ();
|
|---|
| 213 | //temp += package;
|
|---|
| 214 | temp += CmtSystem::file_separator ();
|
|---|
| 215 | temp += version;
|
|---|
| 216 | temp += CmtSystem::file_separator ();
|
|---|
| 217 | temp += "cmt";
|
|---|
| 218 | temp += r;
|
|---|
| 219 |
|
|---|
| 220 | if (!CmtSystem::test_file (temp))
|
|---|
| 221 | {
|
|---|
| 222 | temp = path;
|
|---|
| 223 | //temp += CmtSystem::file_separator ();
|
|---|
| 224 | //temp += package;
|
|---|
| 225 | temp += CmtSystem::file_separator ();
|
|---|
| 226 | temp += version;
|
|---|
| 227 | temp += CmtSystem::file_separator ();
|
|---|
| 228 | temp += "mgr";
|
|---|
| 229 | temp += r;
|
|---|
| 230 |
|
|---|
| 231 | if (!CmtSystem::test_file (temp))
|
|---|
| 232 | {
|
|---|
| 233 | return;
|
|---|
| 234 | }
|
|---|
| 235 | }
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | temp.replace (r.c_str(), "");
|
|---|
| 239 | cmt_string& use = m_uses.add ();
|
|---|
| 240 | use = temp;
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | //----------------------------------------------------------
|
|---|
| 244 | ClientCollector::ClientCollector (const cmt_string& package,
|
|---|
| 245 | const cmt_string& version) :
|
|---|
| 246 | m_package (package), m_version (version), m_count (0)
|
|---|
| 247 | {
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | //----------------------------------------------------------
|
|---|
| 251 | void ClientCollector::run (const cmt_string& package,
|
|---|
| 252 | const cmt_string& version,
|
|---|
| 253 | const cmt_string& path)
|
|---|
| 254 | {
|
|---|
| 255 | cmt_string dir = path;
|
|---|
| 256 | dir += CmtSystem::file_separator ();
|
|---|
| 257 | dir += package;
|
|---|
| 258 | dir += CmtSystem::file_separator ();
|
|---|
| 259 | if (version != "")
|
|---|
| 260 | {
|
|---|
| 261 | dir += version;
|
|---|
| 262 | dir += CmtSystem::file_separator ();
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | cmt_string req;
|
|---|
| 266 |
|
|---|
| 267 | req = dir;
|
|---|
| 268 | req += "cmt";
|
|---|
| 269 | req += CmtSystem::file_separator ();
|
|---|
| 270 | req += "requirements";
|
|---|
| 271 |
|
|---|
| 272 | cmt_string requirements;
|
|---|
| 273 | cmt_string line;
|
|---|
| 274 | CmtSystem::cmt_string_vector words;
|
|---|
| 275 |
|
|---|
| 276 | if (CmtSystem::test_file (req))
|
|---|
| 277 | {
|
|---|
| 278 | requirements.read (req);
|
|---|
| 279 | }
|
|---|
| 280 | else
|
|---|
| 281 | {
|
|---|
| 282 | req = dir;
|
|---|
| 283 | req += "mgr";
|
|---|
| 284 | req += CmtSystem::file_separator ();
|
|---|
| 285 | req += "requirements";
|
|---|
| 286 | if (CmtSystem::test_file (req))
|
|---|
| 287 | {
|
|---|
| 288 | requirements.read (req);
|
|---|
| 289 | }
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | if (requirements != "")
|
|---|
| 293 | {
|
|---|
| 294 | int pos = 0;
|
|---|
| 295 | int max_pos = requirements.size ();
|
|---|
| 296 |
|
|---|
| 297 | while (pos < max_pos)
|
|---|
| 298 | {
|
|---|
| 299 | int cr = requirements.find (pos, "\r\n");
|
|---|
| 300 | int nl = requirements.find (pos, '\n');
|
|---|
| 301 | int first = nl;
|
|---|
| 302 | int length = 1;
|
|---|
| 303 |
|
|---|
| 304 | if (cr != cmt_string::npos)
|
|---|
| 305 | {
|
|---|
| 306 | if (nl == cmt_string::npos)
|
|---|
| 307 | {
|
|---|
| 308 | first = cr;
|
|---|
| 309 | length = 2;
|
|---|
| 310 | }
|
|---|
| 311 | else
|
|---|
| 312 | {
|
|---|
| 313 | first = (nl < cr) ? nl : cr;
|
|---|
| 314 | length = (nl < cr) ? 1 : 2;
|
|---|
| 315 | }
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | if (first == cmt_string::npos)
|
|---|
| 319 | {
|
|---|
| 320 | requirements.substr (pos, line);
|
|---|
| 321 | pos = max_pos;
|
|---|
| 322 | }
|
|---|
| 323 | else if (first > pos)
|
|---|
| 324 | {
|
|---|
| 325 | requirements.substr (pos, first - pos, line);
|
|---|
| 326 | pos = first + length;
|
|---|
| 327 | }
|
|---|
| 328 | else
|
|---|
| 329 | {
|
|---|
| 330 | line.erase (0);
|
|---|
| 331 | pos += length;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | CmtSystem::split (line, " \t", words);
|
|---|
| 335 |
|
|---|
| 336 | if ((words.size () > 2) && (words[0] == "use"))
|
|---|
| 337 | {
|
|---|
| 338 | if ((words[1] == m_package) &&
|
|---|
| 339 | ((words[2] == m_version) || (m_version == "")))
|
|---|
| 340 | {
|
|---|
| 341 | cout << "# " << package << " " << version << " " << path;
|
|---|
| 342 | if (m_version == "")
|
|---|
| 343 | {
|
|---|
| 344 | cout << " (use version " << words[2] << ")";
|
|---|
| 345 | }
|
|---|
| 346 | cout << endl;
|
|---|
| 347 | m_count++;
|
|---|
| 348 | }
|
|---|
| 349 | }
|
|---|
| 350 | }
|
|---|
| 351 | }
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 | //----------------------------------------------------------
|
|---|
| 355 | int ClientCollector::count ()
|
|---|
| 356 | {
|
|---|
| 357 | return (m_count);
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 | //----------------------------------------------------------
|
|---|
| 364 | //
|
|---|
| 365 | // The Cmt methods
|
|---|
| 366 | //
|
|---|
| 367 | //----------------------------------------------------------
|
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 | /**
|
|---|
| 372 | * Append "CONFIG" to the prefix
|
|---|
| 373 | */
|
|---|
| 374 | void Cmt::build_config (const cmt_string& prefix,
|
|---|
| 375 | cmt_string& config)
|
|---|
| 376 | {
|
|---|
| 377 | /*
|
|---|
| 378 | Building the config from <prefix>
|
|---|
| 379 | */
|
|---|
| 380 |
|
|---|
| 381 | config = prefix;
|
|---|
| 382 | config += "CONFIG";
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | //----------------------------------------------------------
|
|---|
| 386 | void Cmt::build_makefile (const cmt_string& target)
|
|---|
| 387 | {
|
|---|
| 388 | Constituent* constituent = 0;
|
|---|
| 389 |
|
|---|
| 390 | if (target.size () > 0)
|
|---|
| 391 | {
|
|---|
| 392 | /*
|
|---|
| 393 | Do genmake for one specific target.
|
|---|
| 394 | */
|
|---|
| 395 | constituent = Constituent::find (target);
|
|---|
| 396 | if (constituent != 0)
|
|---|
| 397 | {
|
|---|
| 398 | constituent->build_makefile (m_simulation);
|
|---|
| 399 | }
|
|---|
| 400 | }
|
|---|
| 401 | else
|
|---|
| 402 | {
|
|---|
| 403 | /*
|
|---|
| 404 | Do genmake for all possible targets.
|
|---|
| 405 | */
|
|---|
| 406 | Constituent::build_all_makefiles (m_simulation);
|
|---|
| 407 | }
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | //----------------------------------------------------------
|
|---|
| 411 | void Cmt::build_msdev_file (const cmt_string& target)
|
|---|
| 412 | {
|
|---|
| 413 | Constituent* constituent = 0;
|
|---|
| 414 |
|
|---|
| 415 | set_standard_macros ();
|
|---|
| 416 |
|
|---|
| 417 | if (target != "")
|
|---|
| 418 | {
|
|---|
| 419 | /*
|
|---|
| 420 | Do genmsdev for one specific target.
|
|---|
| 421 | */
|
|---|
| 422 | constituent = Constituent::find (target);
|
|---|
| 423 | if (constituent != 0)
|
|---|
| 424 | {
|
|---|
| 425 | constituent->build_msdev_file (m_simulation);
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|
| 428 | else
|
|---|
| 429 | {
|
|---|
| 430 | /*
|
|---|
| 431 | Do genmsdev for all possible targets.
|
|---|
| 432 | */
|
|---|
| 433 | Constituent::build_all_msdev_files (m_simulation);
|
|---|
| 434 | }
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | /**
|
|---|
| 438 | Visual Studio.net Support
|
|---|
| 439 | */
|
|---|
| 440 | void Cmt::build_vsnet_file (const cmt_string& target)
|
|---|
| 441 | {
|
|---|
| 442 | Constituent* constituent = 0;
|
|---|
| 443 |
|
|---|
| 444 | set_standard_macros ();
|
|---|
| 445 |
|
|---|
| 446 | if (target != "")
|
|---|
| 447 | {
|
|---|
| 448 | /*
|
|---|
| 449 | Do genvsnet for one specific target.
|
|---|
| 450 | */
|
|---|
| 451 | constituent = Constituent::find (target);
|
|---|
| 452 | if (constituent != 0)
|
|---|
| 453 | {
|
|---|
| 454 | constituent->build_vsnet_file (m_simulation);
|
|---|
| 455 | }
|
|---|
| 456 | }
|
|---|
| 457 | else
|
|---|
| 458 | {
|
|---|
| 459 | /*
|
|---|
| 460 | Do genvsnet for all possible targets.
|
|---|
| 461 | */
|
|---|
| 462 | Constituent::build_all_vsnet_files (m_simulation);
|
|---|
| 463 | }
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | //----------------------------------------------------------
|
|---|
| 467 | bool Cmt::build_nmake ()
|
|---|
| 468 | {
|
|---|
| 469 | return (m_build_nmake);
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | //----------------------------------------------------------
|
|---|
| 473 | void Cmt::build_OS9_makefile (const cmt_string& target)
|
|---|
| 474 | {
|
|---|
| 475 | build_makefile (target);
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | /**
|
|---|
| 479 | * Convert a package name to its upper case copy
|
|---|
| 480 | */
|
|---|
| 481 | void Cmt::build_prefix (const cmt_string& package, cmt_string& prefix)
|
|---|
| 482 | {
|
|---|
| 483 | int pos;
|
|---|
| 484 | char c;
|
|---|
| 485 |
|
|---|
| 486 | /*
|
|---|
| 487 | Building the prefix from <package>
|
|---|
| 488 | */
|
|---|
| 489 |
|
|---|
| 490 | prefix = package;
|
|---|
| 491 |
|
|---|
| 492 | for (pos = 0; pos < package.size (); pos++)
|
|---|
| 493 | {
|
|---|
| 494 | c = package[pos];
|
|---|
| 495 | prefix[pos] = toupper (c);
|
|---|
| 496 | }
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | //----------------------------------------------------------
|
|---|
| 500 | void Cmt::clear ()
|
|---|
| 501 | {
|
|---|
| 502 | m_action = action_none;
|
|---|
| 503 | m_help_action = action_none;
|
|---|
| 504 | m_build_nmake = false;
|
|---|
| 505 | m_cmt_config = "";
|
|---|
| 506 | //m_cmt_path.clear ();
|
|---|
| 507 | //m_cmt_path_pwds.clear ();
|
|---|
| 508 | //m_cmt_path_sources.clear ();
|
|---|
| 509 | m_cmt_root = "";
|
|---|
| 510 | m_cmt_version = "";
|
|---|
| 511 | m_current_build_strategy = DefaultBuildStrategy;
|
|---|
| 512 | m_current_setup_strategy = DefaultSetupStrategy;
|
|---|
| 513 | m_current_dir = "";
|
|---|
| 514 | m_current_package = "";
|
|---|
| 515 | m_current_config = "";
|
|---|
| 516 | m_current_path = "";
|
|---|
| 517 | m_current_prefix = "";
|
|---|
| 518 | m_current_cmtpath = "";
|
|---|
| 519 | m_current_offset = "";
|
|---|
| 520 |
|
|---|
| 521 | m_current_access = DeveloperMode;
|
|---|
| 522 |
|
|---|
| 523 | m_current_tag = "";
|
|---|
| 524 | m_current_target = "";
|
|---|
| 525 | m_current_version = "";
|
|---|
| 526 | m_default_path = "";
|
|---|
| 527 | m_quiet = false;
|
|---|
| 528 | m_recursive = false;
|
|---|
| 529 |
|
|---|
| 530 | m_scope_filtering_mode = default_filtering_mode;
|
|---|
| 531 | m_simulation = false;
|
|---|
| 532 |
|
|---|
| 533 | m_standard_macros_done = false;
|
|---|
| 534 |
|
|---|
| 535 | Database::clear ();
|
|---|
| 536 | Include::clear_all ();
|
|---|
| 537 | Script::clear_all ();
|
|---|
| 538 | CmtError::clear ();
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | //----------------------------------------------------------
|
|---|
| 542 | void Cmt::configure ()
|
|---|
| 543 | {
|
|---|
| 544 | static bool configured = false;
|
|---|
| 545 |
|
|---|
| 546 | if (configured) return;
|
|---|
| 547 |
|
|---|
| 548 | m_cmt_version = "";
|
|---|
| 549 | m_current_dir = "";
|
|---|
| 550 | m_current_package = "";
|
|---|
| 551 | m_current_prefix = "";
|
|---|
| 552 | m_current_config = "";
|
|---|
| 553 | m_current_path = "";
|
|---|
| 554 | m_current_cmtpath = "";
|
|---|
| 555 | m_current_offset = "";
|
|---|
| 556 |
|
|---|
| 557 | m_current_tag = "";
|
|---|
| 558 | m_current_version = "";
|
|---|
| 559 |
|
|---|
| 560 | m_configure_error = "";
|
|---|
| 561 |
|
|---|
| 562 | m_debug = false;
|
|---|
| 563 | if (getenv ("CMTDEBUG") != 0) m_debug = true;
|
|---|
| 564 |
|
|---|
| 565 | m_default_path = "";
|
|---|
| 566 |
|
|---|
| 567 | configure_default_path ();
|
|---|
| 568 | configure_version_tag ();
|
|---|
| 569 | configure_uname_tag ();
|
|---|
| 570 | configure_hosttype_tag ();
|
|---|
| 571 | configure_config_tag ();
|
|---|
| 572 | configure_site_tag (0);
|
|---|
| 573 | configure_home (0);
|
|---|
| 574 | configure_current_dir ();
|
|---|
| 575 | configure_current_package ();
|
|---|
| 576 | configure_current_structuring_style ();
|
|---|
| 577 |
|
|---|
| 578 | Use& use = Use::current();
|
|---|
| 579 |
|
|---|
| 580 | use.set (m_current_package,
|
|---|
| 581 | m_current_version,
|
|---|
| 582 | m_current_path,
|
|---|
| 583 | "",
|
|---|
| 584 | "");
|
|---|
| 585 |
|
|---|
| 586 | use.style = m_current_style;
|
|---|
| 587 |
|
|---|
| 588 | use.change_path (m_current_path);
|
|---|
| 589 |
|
|---|
| 590 | if (CmtError::has_pending_error ())
|
|---|
| 591 | {
|
|---|
| 592 | m_configure_error = CmtError::get_last_error ();
|
|---|
| 593 | }
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | //----------------------------------------------------------
|
|---|
| 597 | void Cmt::configure_cmt_path (Use* use)
|
|---|
| 598 | {
|
|---|
| 599 | cmt_string s;
|
|---|
| 600 |
|
|---|
| 601 | Symbol* symbol = Symbol::find ("CMTPATH");
|
|---|
| 602 | if (symbol != 0)
|
|---|
| 603 | {
|
|---|
| 604 | bool show_set_hidden = false;
|
|---|
| 605 |
|
|---|
| 606 | if (Cmt::m_action == action_show_set)
|
|---|
| 607 | {
|
|---|
| 608 | show_set_hidden = true;
|
|---|
| 609 | Cmt::m_action = action_none;
|
|---|
| 610 | }
|
|---|
| 611 |
|
|---|
| 612 | s = symbol->build_macro_value ();
|
|---|
| 613 | Symbol::expand (s);
|
|---|
| 614 |
|
|---|
| 615 | if (show_set_hidden)
|
|---|
| 616 | {
|
|---|
| 617 | show_set_hidden = false;
|
|---|
| 618 | Cmt::m_action = action_show_set;
|
|---|
| 619 | }
|
|---|
| 620 | }
|
|---|
| 621 |
|
|---|
| 622 | IProjectFactory& factory = ProjectFactory::instance ();
|
|---|
| 623 | factory.reset ();
|
|---|
| 624 |
|
|---|
| 625 | CmtSystem::get_cmt_paths (factory, s);
|
|---|
| 626 | if (m_cmt_user_context != "") factory.create_project (m_cmt_user_context, "CMTUSERCONTEXT");
|
|---|
| 627 | if (m_cmt_home != "") factory.create_project (m_cmt_home, "CMTHOME");
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | //----------------------------------------------------------
|
|---|
| 631 | void Cmt::configure_config_tag ()
|
|---|
| 632 | {
|
|---|
| 633 | m_cmt_config = CmtSystem::get_cmt_config ();
|
|---|
| 634 | if (m_cmt_config != "")
|
|---|
| 635 | {
|
|---|
| 636 | Tag* tag;
|
|---|
| 637 |
|
|---|
| 638 | tag = Tag::add (m_cmt_config, PriorityConfig, "CMTCONFIG", 0);
|
|---|
| 639 | tag->mark ();
|
|---|
| 640 | }
|
|---|
| 641 | }
|
|---|
| 642 |
|
|---|
| 643 | //----------------------------------------------------------
|
|---|
| 644 | void Cmt::configure_current_cmtpath ()
|
|---|
| 645 | {
|
|---|
| 646 | Use& current_use = Use::current ();
|
|---|
| 647 |
|
|---|
| 648 | m_current_cmtpath = "";
|
|---|
| 649 | m_current_offset = "";
|
|---|
| 650 |
|
|---|
| 651 | m_current_cmtpath = Project::find_in_cmt_paths (current_use.path);
|
|---|
| 652 |
|
|---|
| 653 | if (m_current_cmtpath != "")
|
|---|
| 654 | {
|
|---|
| 655 | static const cmt_string empty_string;
|
|---|
| 656 | static const cmt_string fs = CmtSystem::file_separator ();
|
|---|
| 657 |
|
|---|
| 658 | m_current_offset = current_use.path;
|
|---|
| 659 |
|
|---|
| 660 | /**
|
|---|
| 661 | try to remove this current CMTPATH entry from path. This
|
|---|
| 662 | has a meaning when the specified path already contains an
|
|---|
| 663 | absolute path.
|
|---|
| 664 | */
|
|---|
| 665 |
|
|---|
| 666 | m_current_offset.replace (m_current_cmtpath, empty_string);
|
|---|
| 667 | if (m_current_offset[0] == CmtSystem::file_separator ())
|
|---|
| 668 | {
|
|---|
| 669 | // Just in case there is a part left after removing the cmtpath entry
|
|---|
| 670 |
|
|---|
| 671 | m_current_offset.replace (fs, empty_string);
|
|---|
| 672 | }
|
|---|
| 673 | }
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | class CmtMountFilterParser : public FAwk
|
|---|
| 677 | {
|
|---|
| 678 | public:
|
|---|
| 679 |
|
|---|
| 680 | CmtMountFilterParser ()
|
|---|
| 681 | {
|
|---|
| 682 | reset ();
|
|---|
| 683 | }
|
|---|
| 684 |
|
|---|
| 685 | void reset ()
|
|---|
| 686 | {
|
|---|
| 687 | m_current_dir = CmtSystem::pwd ();
|
|---|
| 688 | m_done = false;
|
|---|
| 689 | m_prefix = "";
|
|---|
| 690 | }
|
|---|
| 691 |
|
|---|
| 692 | bool is_done () const
|
|---|
| 693 | {
|
|---|
| 694 | return (m_done);
|
|---|
| 695 | }
|
|---|
| 696 |
|
|---|
| 697 | const cmt_string& get_current_dir () const
|
|---|
| 698 | {
|
|---|
| 699 | return (m_current_dir);
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 | void set_prefix (const cmt_string& prefix)
|
|---|
| 703 | {
|
|---|
| 704 | m_prefix = prefix;
|
|---|
| 705 | }
|
|---|
| 706 |
|
|---|
| 707 | void filter (const cmt_string& line)
|
|---|
| 708 | {
|
|---|
| 709 | //cout << "line=" << line << endl;
|
|---|
| 710 |
|
|---|
| 711 | if (m_done)
|
|---|
| 712 | {
|
|---|
| 713 | stop ();
|
|---|
| 714 | return;
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | CmtSystem::cmt_string_vector words;
|
|---|
| 718 |
|
|---|
| 719 | CmtSystem::split (line, " \t", words);
|
|---|
| 720 |
|
|---|
| 721 | int requested = 2;
|
|---|
| 722 |
|
|---|
| 723 | if (m_prefix != "")
|
|---|
| 724 | {
|
|---|
| 725 | requested++;
|
|---|
| 726 | }
|
|---|
| 727 |
|
|---|
| 728 | if (words.size () < requested) return;
|
|---|
| 729 |
|
|---|
| 730 | int n = 0;
|
|---|
| 731 |
|
|---|
| 732 | if (m_prefix != "")
|
|---|
| 733 | {
|
|---|
| 734 | if (words[n] != m_prefix) return;
|
|---|
| 735 | n++;
|
|---|
| 736 | }
|
|---|
| 737 |
|
|---|
| 738 | cmt_string& path_name = words[n];
|
|---|
| 739 | cmt_string& replacement = words[n+1];
|
|---|
| 740 |
|
|---|
| 741 | if (m_current_dir.find (path_name) != cmt_string::npos)
|
|---|
| 742 | {
|
|---|
| 743 | m_current_dir.replace (path_name, replacement);
|
|---|
| 744 | m_done = true;
|
|---|
| 745 | stop ();
|
|---|
| 746 | }
|
|---|
| 747 | }
|
|---|
| 748 |
|
|---|
| 749 | private:
|
|---|
| 750 | bool m_done;
|
|---|
| 751 | cmt_string m_prefix;
|
|---|
| 752 | cmt_string m_current_dir;
|
|---|
| 753 | };
|
|---|
| 754 |
|
|---|
| 755 | //----------------------------------------------------------
|
|---|
| 756 | void Cmt::configure_current_dir ()
|
|---|
| 757 | {
|
|---|
| 758 | cmt_string file_name;
|
|---|
| 759 |
|
|---|
| 760 | /*
|
|---|
| 761 | Building current_dir :
|
|---|
| 762 |
|
|---|
| 763 | o we first get the physical value (using getwd)
|
|---|
| 764 | o then this value is possibly filtered using the
|
|---|
| 765 | cmt_mount_filter file.
|
|---|
| 766 | */
|
|---|
| 767 |
|
|---|
| 768 | CmtMountFilterParser mount_filter;
|
|---|
| 769 |
|
|---|
| 770 | /**
|
|---|
| 771 | First try with ${CMTROOT}/mgr/cmt_mount_filter
|
|---|
| 772 | with no prefix on lines
|
|---|
| 773 | */
|
|---|
| 774 |
|
|---|
| 775 | file_name = m_default_path;
|
|---|
| 776 | if (file_name != "")
|
|---|
| 777 | {
|
|---|
| 778 | file_name += CmtSystem::file_separator ();
|
|---|
| 779 | file_name += "CMT";
|
|---|
| 780 | file_name += CmtSystem::file_separator ();
|
|---|
| 781 | file_name += m_cmt_version;
|
|---|
| 782 | file_name += CmtSystem::file_separator ();
|
|---|
| 783 | file_name += "mgr";
|
|---|
| 784 | file_name += CmtSystem::file_separator ();
|
|---|
| 785 | }
|
|---|
| 786 |
|
|---|
| 787 | file_name += "cmt_mount_filter";
|
|---|
| 788 |
|
|---|
| 789 | mount_filter.run (file_name);
|
|---|
| 790 |
|
|---|
| 791 | /**
|
|---|
| 792 | Now try with .cmtrc
|
|---|
| 793 | with "mount_filter" keyword
|
|---|
| 794 | */
|
|---|
| 795 |
|
|---|
| 796 | mount_filter.set_prefix ("mount_filter");
|
|---|
| 797 |
|
|---|
| 798 | mount_filter.run (".cmtrc");
|
|---|
| 799 |
|
|---|
| 800 | /**
|
|---|
| 801 | Now try with ${HOME}/.cmtrc
|
|---|
| 802 | with "mount_filter" keyword
|
|---|
| 803 | */
|
|---|
| 804 |
|
|---|
| 805 | if (CmtSystem::get_home_directory (file_name))
|
|---|
| 806 | {
|
|---|
| 807 | file_name += CmtSystem::file_separator ();
|
|---|
| 808 | file_name += ".cmtrc";
|
|---|
| 809 | mount_filter.run (file_name);
|
|---|
| 810 | }
|
|---|
| 811 |
|
|---|
| 812 | m_current_dir = mount_filter.get_current_dir ();
|
|---|
| 813 | }
|
|---|
| 814 |
|
|---|
| 815 | //----------------------------------------------------------
|
|---|
| 816 | void Cmt::configure_current_package ()
|
|---|
| 817 | {
|
|---|
| 818 | /*
|
|---|
| 819 | Build current_package and current_prefix.
|
|---|
| 820 |
|
|---|
| 821 | This is only possible if we are within the cmt/mgr branch of a
|
|---|
| 822 | standard directory tree (i.e. <package>/<version>/cmt or mgr)
|
|---|
| 823 | */
|
|---|
| 824 |
|
|---|
| 825 | cmt_string req = "..";
|
|---|
| 826 | req += CmtSystem::file_separator ();
|
|---|
| 827 | req += "cmt";
|
|---|
| 828 | req += CmtSystem::file_separator ();
|
|---|
| 829 | req += "requirements";
|
|---|
| 830 |
|
|---|
| 831 | if (CmtSystem::test_file (req))
|
|---|
| 832 | {
|
|---|
| 833 | m_current_style = cmt_style;
|
|---|
| 834 | }
|
|---|
| 835 | else
|
|---|
| 836 | {
|
|---|
| 837 | cmt_string req = "..";
|
|---|
| 838 | req += CmtSystem::file_separator ();
|
|---|
| 839 | req += "mgr";
|
|---|
| 840 | req += CmtSystem::file_separator ();
|
|---|
| 841 | req += "requirements";
|
|---|
| 842 |
|
|---|
| 843 | if (CmtSystem::test_file (req))
|
|---|
| 844 | {
|
|---|
| 845 | m_current_style = mgr_style;
|
|---|
| 846 | }
|
|---|
| 847 | else
|
|---|
| 848 | {
|
|---|
| 849 | // This package is probably a standalone one
|
|---|
| 850 | m_current_style = none_style;
|
|---|
| 851 | }
|
|---|
| 852 | }
|
|---|
| 853 |
|
|---|
| 854 |
|
|---|
| 855 | if (m_current_style != none_style)
|
|---|
| 856 | {
|
|---|
| 857 | //
|
|---|
| 858 | // Here there is a ../cmt or ../mgr branch in front of us
|
|---|
| 859 | // and there is a requirements file there
|
|---|
| 860 | //
|
|---|
| 861 |
|
|---|
| 862 | cmt_string up_dir;
|
|---|
| 863 | cmt_string up_branch;
|
|---|
| 864 |
|
|---|
| 865 | CmtSystem::dirname (m_current_dir, up_dir);
|
|---|
| 866 | CmtSystem::basename (up_dir, up_branch);
|
|---|
| 867 |
|
|---|
| 868 | cmt_string version_file = "..";
|
|---|
| 869 | version_file += CmtSystem::file_separator ();
|
|---|
| 870 | version_file += "cmt";
|
|---|
| 871 | version_file += CmtSystem::file_separator ();
|
|---|
| 872 | version_file += "version.cmt";
|
|---|
| 873 |
|
|---|
| 874 | if (CmtSystem::test_file (version_file))
|
|---|
| 875 | {
|
|---|
| 876 | //
|
|---|
| 877 | // There is an explicit version descriptor. This one takes precedence
|
|---|
| 878 | // and forces the structuring style to no directory
|
|---|
| 879 | //
|
|---|
| 880 |
|
|---|
| 881 | m_current_package = up_branch;
|
|---|
| 882 | CmtSystem::dirname (up_dir, m_current_path);
|
|---|
| 883 |
|
|---|
| 884 | if (m_current_version.read (version_file))
|
|---|
| 885 | {
|
|---|
| 886 | int pos;
|
|---|
| 887 |
|
|---|
| 888 | pos = m_current_version.find ('\n');
|
|---|
| 889 | if (pos != cmt_string::npos) m_current_version.erase (pos);
|
|---|
| 890 | pos = m_current_version.find ('\r');
|
|---|
| 891 | if (pos != cmt_string::npos) m_current_version.erase (pos);
|
|---|
| 892 | }
|
|---|
| 893 | else
|
|---|
| 894 | {
|
|---|
| 895 | m_current_version = "v*";
|
|---|
| 896 | }
|
|---|
| 897 |
|
|---|
| 898 | if (m_debug)
|
|---|
| 899 | {
|
|---|
| 900 | cout << "Cmt::configure_current_package>" << endl
|
|---|
| 901 | << " m_current_package " << m_current_package << endl
|
|---|
| 902 | << " m_current_version " << m_current_version << endl
|
|---|
| 903 | << " m_current_dir " << m_current_dir << endl
|
|---|
| 904 | << " pwd " << CmtSystem::pwd ()
|
|---|
| 905 | << endl;
|
|---|
| 906 | }
|
|---|
| 907 |
|
|---|
| 908 | m_current_style = no_version_style;
|
|---|
| 909 | }
|
|---|
| 910 | else if (CmtSystem::is_version_directory (up_branch))
|
|---|
| 911 | {
|
|---|
| 912 | // The up branch IS a version directory.
|
|---|
| 913 |
|
|---|
| 914 | m_current_version = up_branch;
|
|---|
| 915 | CmtSystem::dirname (up_dir, up_dir);
|
|---|
| 916 | CmtSystem::basename (up_dir, m_current_package);
|
|---|
| 917 | CmtSystem::dirname (up_dir, m_current_path);
|
|---|
| 918 | }
|
|---|
| 919 | else
|
|---|
| 920 | {
|
|---|
| 921 | // No version descriptor
|
|---|
| 922 | // No version directory. The version is defaulted to v*
|
|---|
| 923 |
|
|---|
| 924 | CmtSystem::basename (up_dir, m_current_package);
|
|---|
| 925 | m_current_version = "v*";
|
|---|
| 926 | CmtSystem::dirname (up_dir, m_current_path);
|
|---|
| 927 |
|
|---|
| 928 | m_current_style = no_version_style;
|
|---|
| 929 | }
|
|---|
| 930 |
|
|---|
| 931 | build_prefix (m_current_package, m_current_prefix);
|
|---|
| 932 | build_config (m_current_prefix, m_current_config);
|
|---|
| 933 | }
|
|---|
| 934 | else
|
|---|
| 935 | {
|
|---|
| 936 | m_current_package = "cmt_standalone";
|
|---|
| 937 | m_current_version = "";
|
|---|
| 938 | m_current_path = m_current_dir;
|
|---|
| 939 | build_prefix (m_current_package, m_current_prefix);
|
|---|
| 940 | build_config (m_current_prefix, m_current_config);
|
|---|
| 941 | m_current_style = none_style;
|
|---|
| 942 | }
|
|---|
| 943 |
|
|---|
| 944 | //cout << "configure_current_package> current style=" << m_current_style << endl;
|
|---|
| 945 | }
|
|---|
| 946 |
|
|---|
| 947 | //----------------------------------------------------------
|
|---|
| 948 | void Cmt::configure_current_structuring_style ()
|
|---|
| 949 | {
|
|---|
| 950 | cmt_string s;
|
|---|
| 951 |
|
|---|
| 952 | s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
|
|---|
| 953 | if (s == "without_version_directory")
|
|---|
| 954 | {
|
|---|
| 955 | m_current_structuring_style = without_version_directory;
|
|---|
| 956 | }
|
|---|
| 957 | }
|
|---|
| 958 |
|
|---|
| 959 | //----------------------------------------------------------
|
|---|
| 960 | void Cmt::configure_default_path ()
|
|---|
| 961 | {
|
|---|
| 962 | m_default_path = CmtSystem::get_cmt_root ();
|
|---|
| 963 | CmtSystem::get_cmt_version (m_cmt_version);
|
|---|
| 964 | m_cmt_root = m_default_path;
|
|---|
| 965 | m_cmt_root += CmtSystem::file_separator ();
|
|---|
| 966 | m_cmt_root += "CMT";
|
|---|
| 967 | m_cmt_root += CmtSystem::file_separator ();
|
|---|
| 968 | m_cmt_root += m_cmt_version;
|
|---|
| 969 | }
|
|---|
| 970 |
|
|---|
| 971 | //----------------------------------------------------------
|
|---|
| 972 | void Cmt::configure_home (Use* use)
|
|---|
| 973 | {
|
|---|
| 974 | m_cmt_home = "";
|
|---|
| 975 |
|
|---|
| 976 | Symbol* symbol = Symbol::find ("CMTHOME");
|
|---|
| 977 | if (symbol != 0)
|
|---|
| 978 | {
|
|---|
| 979 | m_cmt_home = symbol->build_macro_value ();
|
|---|
| 980 | Symbol::expand (m_cmt_home);
|
|---|
| 981 | }
|
|---|
| 982 | else if (CmtSystem::testenv ("CMTHOME"))
|
|---|
| 983 | {
|
|---|
| 984 | m_cmt_home = CmtSystem::getenv ("CMTHOME");
|
|---|
| 985 | }
|
|---|
| 986 |
|
|---|
| 987 | if ((m_cmt_home != "") && !CmtSystem::test_directory (m_cmt_home))
|
|---|
| 988 | {
|
|---|
| 989 | m_cmt_home = "";
|
|---|
| 990 | }
|
|---|
| 991 |
|
|---|
| 992 | configure_user_context (0);
|
|---|
| 993 | }
|
|---|
| 994 |
|
|---|
| 995 | //----------------------------------------------------------
|
|---|
| 996 | void Cmt::configure_user_context (Use* use)
|
|---|
| 997 | {
|
|---|
| 998 | m_cmt_user_context = "";
|
|---|
| 999 |
|
|---|
| 1000 | Symbol* symbol = Symbol::find ("CMTUSERCONTEXT");
|
|---|
| 1001 | if (symbol != 0)
|
|---|
| 1002 | {
|
|---|
| 1003 | m_cmt_user_context = symbol->build_macro_value ();
|
|---|
| 1004 | Symbol::expand (m_cmt_user_context);
|
|---|
| 1005 | }
|
|---|
| 1006 | else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
|
|---|
| 1007 | {
|
|---|
| 1008 | m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
|
|---|
| 1009 | }
|
|---|
| 1010 |
|
|---|
| 1011 | if ((m_cmt_user_context != "") && !CmtSystem::test_directory (m_cmt_user_context))
|
|---|
| 1012 | {
|
|---|
| 1013 | m_cmt_user_context = "";
|
|---|
| 1014 | }
|
|---|
| 1015 |
|
|---|
| 1016 | if (m_debug) cout << "configure_user_context> user_context=" << m_cmt_user_context << endl;
|
|---|
| 1017 |
|
|---|
| 1018 | configure_cmt_path (0);
|
|---|
| 1019 | }
|
|---|
| 1020 |
|
|---|
| 1021 | //----------------------------------------------------------
|
|---|
| 1022 | void Cmt::configure_hosttype_tag ()
|
|---|
| 1023 | {
|
|---|
| 1024 | cmt_string hosttype;
|
|---|
| 1025 |
|
|---|
| 1026 | CmtSystem::get_hosttype (hosttype);
|
|---|
| 1027 |
|
|---|
| 1028 | if (hosttype != "")
|
|---|
| 1029 | {
|
|---|
| 1030 | Tag* tag;
|
|---|
| 1031 |
|
|---|
| 1032 | tag = Tag::add (hosttype, PriorityUname, "HOSTTYPE", 0);
|
|---|
| 1033 | tag->mark ();
|
|---|
| 1034 | }
|
|---|
| 1035 | }
|
|---|
| 1036 |
|
|---|
| 1037 | //----------------------------------------------------------
|
|---|
| 1038 | void Cmt::configure_site_tag (Use* use)
|
|---|
| 1039 | {
|
|---|
| 1040 | Symbol* symbol = Symbol::find ("CMTSITE");
|
|---|
| 1041 | if (symbol != 0)
|
|---|
| 1042 | {
|
|---|
| 1043 | m_cmt_site = symbol->build_macro_value ();
|
|---|
| 1044 | Symbol::expand (m_cmt_site);
|
|---|
| 1045 | }
|
|---|
| 1046 | else
|
|---|
| 1047 | {
|
|---|
| 1048 | m_cmt_site = CmtSystem::get_cmt_site ();
|
|---|
| 1049 | }
|
|---|
| 1050 |
|
|---|
| 1051 | if (m_cmt_site != "")
|
|---|
| 1052 | {
|
|---|
| 1053 | cmt_string s = "CMTSITE";
|
|---|
| 1054 |
|
|---|
| 1055 | if (use != 0)
|
|---|
| 1056 | {
|
|---|
| 1057 | s += " in ";
|
|---|
| 1058 | }
|
|---|
| 1059 |
|
|---|
| 1060 | Tag* tag;
|
|---|
| 1061 |
|
|---|
| 1062 | tag = Tag::add (m_cmt_site, PrioritySite, s, use);
|
|---|
| 1063 | tag->mark ();
|
|---|
| 1064 | }
|
|---|
| 1065 | }
|
|---|
| 1066 |
|
|---|
| 1067 | //----------------------------------------------------------
|
|---|
| 1068 | void Cmt::restore_all_tags (Use* use)
|
|---|
| 1069 | {
|
|---|
| 1070 | //cerr << "restore_all_tags" << endl;
|
|---|
| 1071 |
|
|---|
| 1072 | Cmt::configure_tags (use);
|
|---|
| 1073 |
|
|---|
| 1074 | /*
|
|---|
| 1075 | Then get existing extra tags
|
|---|
| 1076 | */
|
|---|
| 1077 |
|
|---|
| 1078 | if (CmtSystem::testenv ("CMTEXTRATAGS"))
|
|---|
| 1079 | {
|
|---|
| 1080 | cmt_string s = "CMTEXTRATAGS";
|
|---|
| 1081 |
|
|---|
| 1082 | if (use != 0)
|
|---|
| 1083 | {
|
|---|
| 1084 | s += " in ";
|
|---|
| 1085 | }
|
|---|
| 1086 |
|
|---|
| 1087 | Tag* tag;
|
|---|
| 1088 | CmtSystem::cmt_string_vector words;
|
|---|
| 1089 |
|
|---|
| 1090 | cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS");
|
|---|
| 1091 |
|
|---|
| 1092 | CmtSystem::split (tags, " \t,", words);
|
|---|
| 1093 |
|
|---|
| 1094 | Cmt::m_extra_tags = ",";
|
|---|
| 1095 |
|
|---|
| 1096 | for (int i = 0; i < words.size (); i++)
|
|---|
| 1097 | {
|
|---|
| 1098 | const cmt_string& a = words[i];
|
|---|
| 1099 |
|
|---|
| 1100 | Cmt::m_extra_tags += a;
|
|---|
| 1101 | Cmt::m_extra_tags += ",";
|
|---|
| 1102 |
|
|---|
| 1103 | tag = Tag::add (a, PriorityUserTag, s, use);
|
|---|
| 1104 |
|
|---|
| 1105 | tag->mark ();
|
|---|
| 1106 | }
|
|---|
| 1107 | }
|
|---|
| 1108 | }
|
|---|
| 1109 |
|
|---|
| 1110 | //----------------------------------------------------------
|
|---|
| 1111 | void Cmt::configure_tags (Use* use)
|
|---|
| 1112 | {
|
|---|
| 1113 | cmt_string config_tag;
|
|---|
| 1114 |
|
|---|
| 1115 | Log;
|
|---|
| 1116 |
|
|---|
| 1117 | //if (m_debug) cout << "configure_tags0> current_tag=" << m_current_tag << endl;
|
|---|
| 1118 |
|
|---|
| 1119 | log << "current_tag=" << m_current_tag << log_endl;
|
|---|
| 1120 |
|
|---|
| 1121 | Symbol* symbol = Symbol::find ("CMTCONFIG");
|
|---|
| 1122 | if (symbol != 0)
|
|---|
| 1123 | {
|
|---|
| 1124 | bool show_set_hidden = false;
|
|---|
| 1125 |
|
|---|
| 1126 | if (Cmt::m_action == action_show_set)
|
|---|
| 1127 | {
|
|---|
| 1128 | show_set_hidden = true;
|
|---|
| 1129 | Cmt::m_action = action_none;
|
|---|
| 1130 | }
|
|---|
| 1131 |
|
|---|
| 1132 | config_tag = symbol->build_macro_value ();
|
|---|
| 1133 | Symbol::expand (config_tag);
|
|---|
| 1134 |
|
|---|
| 1135 | if (show_set_hidden)
|
|---|
| 1136 | {
|
|---|
| 1137 | show_set_hidden = false;
|
|---|
| 1138 | Cmt::m_action = action_show_set;
|
|---|
| 1139 | }
|
|---|
| 1140 | }
|
|---|
| 1141 | else if (CmtSystem::testenv ("CMTCONFIG"))
|
|---|
| 1142 | {
|
|---|
| 1143 | config_tag = CmtSystem::getenv ("CMTCONFIG");
|
|---|
| 1144 | }
|
|---|
| 1145 | else if (CmtSystem::testenv ("CMTBIN"))
|
|---|
| 1146 | {
|
|---|
| 1147 | config_tag = CmtSystem::getenv ("CMTBIN");
|
|---|
| 1148 | }
|
|---|
| 1149 |
|
|---|
| 1150 | if (config_tag == "")
|
|---|
| 1151 | {
|
|---|
| 1152 | CmtSystem::get_uname (config_tag);
|
|---|
| 1153 | }
|
|---|
| 1154 |
|
|---|
| 1155 | //if (m_debug) cout << "configure_tags> current_tag=" << m_current_tag << endl;
|
|---|
| 1156 | log << "current_tag=" << m_current_tag << log_endl;
|
|---|
| 1157 |
|
|---|
| 1158 | cmt_string s = "CMTCONFIG";
|
|---|
| 1159 |
|
|---|
| 1160 | if (use != 0)
|
|---|
| 1161 | {
|
|---|
| 1162 | s += " in ";
|
|---|
| 1163 | }
|
|---|
| 1164 |
|
|---|
| 1165 | Tag* tag;
|
|---|
| 1166 |
|
|---|
| 1167 | tag = Tag::add (config_tag, PriorityConfig, s, use);
|
|---|
| 1168 | tag->mark ();
|
|---|
| 1169 |
|
|---|
| 1170 | //m_current_tag = config_tag;
|
|---|
| 1171 | }
|
|---|
| 1172 |
|
|---|
| 1173 | //----------------------------------------------------------
|
|---|
| 1174 | void Cmt::configure_uname_tag ()
|
|---|
| 1175 | {
|
|---|
| 1176 | cmt_string uname;
|
|---|
| 1177 |
|
|---|
| 1178 | CmtSystem::get_uname (uname);
|
|---|
| 1179 |
|
|---|
| 1180 | if (uname != "")
|
|---|
| 1181 | {
|
|---|
| 1182 | Tag* tag;
|
|---|
| 1183 |
|
|---|
| 1184 | tag = Tag::add (uname, PriorityUname, "uname", 0);
|
|---|
| 1185 | tag->mark ();
|
|---|
| 1186 | }
|
|---|
| 1187 | }
|
|---|
| 1188 |
|
|---|
| 1189 | //----------------------------------------------------------
|
|---|
| 1190 | void Cmt::configure_version_tag ()
|
|---|
| 1191 | {
|
|---|
| 1192 | int v = 0;
|
|---|
| 1193 | int r = 0;
|
|---|
| 1194 | int p = 0;
|
|---|
| 1195 |
|
|---|
| 1196 | CmtSystem::is_version_directory (CMTVERSION, v, r, p);
|
|---|
| 1197 |
|
|---|
| 1198 | Tag* tag;
|
|---|
| 1199 |
|
|---|
| 1200 | static char temp[80];
|
|---|
| 1201 |
|
|---|
| 1202 | sprintf (temp, "CMTv%d", v);
|
|---|
| 1203 |
|
|---|
| 1204 | tag = Tag::add (temp, PriorityVersion, "CMTVERSION", 0);
|
|---|
| 1205 | tag->mark ();
|
|---|
| 1206 |
|
|---|
| 1207 | sprintf (temp, "CMTr%d", r);
|
|---|
| 1208 |
|
|---|
| 1209 | tag = Tag::add (temp, PriorityVersion, "CMTVERSION", 0);
|
|---|
| 1210 | tag->mark ();
|
|---|
| 1211 |
|
|---|
| 1212 | sprintf (temp, "CMTp%d", p);
|
|---|
| 1213 |
|
|---|
| 1214 | tag = Tag::add (temp, PriorityVersion, "CMTVERSION", 0);
|
|---|
| 1215 | tag->mark ();
|
|---|
| 1216 |
|
|---|
| 1217 | }
|
|---|
| 1218 |
|
|---|
| 1219 | //----------------------------------------------------------
|
|---|
| 1220 | //
|
|---|
| 1221 | // Actions
|
|---|
| 1222 | //
|
|---|
| 1223 | //----------------------------------------------------------
|
|---|
| 1224 |
|
|---|
| 1225 | class AwkActor : public Awk
|
|---|
| 1226 | {
|
|---|
| 1227 | public:
|
|---|
| 1228 |
|
|---|
| 1229 | void filter (const cmt_string& line)
|
|---|
| 1230 | {
|
|---|
| 1231 | cout << line << endl;
|
|---|
| 1232 | }
|
|---|
| 1233 | };
|
|---|
| 1234 |
|
|---|
| 1235 | //----------------------------------------------------------
|
|---|
| 1236 | void Cmt::do_awk (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1237 | {
|
|---|
| 1238 | if (arguments.size () < 1)
|
|---|
| 1239 | {
|
|---|
| 1240 | cerr << "#CMT> cmt awk <file> <pattern>" << endl;
|
|---|
| 1241 | return;
|
|---|
| 1242 | }
|
|---|
| 1243 |
|
|---|
| 1244 | const cmt_string& file = arguments[0];
|
|---|
| 1245 | const cmt_string& pattern = arguments[1];
|
|---|
| 1246 | cmt_string text;
|
|---|
| 1247 |
|
|---|
| 1248 | text.read (file);
|
|---|
| 1249 |
|
|---|
| 1250 | static AwkActor a;
|
|---|
| 1251 |
|
|---|
| 1252 | cmt_regexp exp (pattern);
|
|---|
| 1253 |
|
|---|
| 1254 | a.run (text, exp);
|
|---|
| 1255 | }
|
|---|
| 1256 |
|
|---|
| 1257 | //----------------------------------------------------------
|
|---|
| 1258 | void Cmt::do_broadcast (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 1259 | int argc,
|
|---|
| 1260 | char* argv[])
|
|---|
| 1261 | {
|
|---|
| 1262 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 1263 |
|
|---|
| 1264 | CmtSystem::cmt_string_vector uses;
|
|---|
| 1265 | CmtSystem::cmt_string_vector packages;
|
|---|
| 1266 | CmtSystem::cmt_string_vector versions;
|
|---|
| 1267 | CmtSystem::cmt_string_vector path_selections;
|
|---|
| 1268 | CmtSystem::cmt_string_vector selections;
|
|---|
| 1269 | CmtSystem::cmt_string_vector exclusions;
|
|---|
| 1270 | cmt_string begin;
|
|---|
| 1271 | cmt_string command;
|
|---|
| 1272 | bool is_cmt = false;
|
|---|
| 1273 | int first = 0;
|
|---|
| 1274 | int i;
|
|---|
| 1275 | bool ignore_errors = false;
|
|---|
| 1276 | bool all_packages = false;
|
|---|
| 1277 |
|
|---|
| 1278 | bool local = true;
|
|---|
| 1279 |
|
|---|
| 1280 | for (i = 0; i < arguments.size (); i++)
|
|---|
| 1281 | {
|
|---|
| 1282 | const cmt_string& w = arguments[i];
|
|---|
| 1283 |
|
|---|
| 1284 | if (command == "")
|
|---|
| 1285 | {
|
|---|
| 1286 | if (w.substr (0, 13) == "-all_packages")
|
|---|
| 1287 | {
|
|---|
| 1288 | local = false;
|
|---|
| 1289 | all_packages = true;
|
|---|
| 1290 | }
|
|---|
| 1291 | else if (w.substr (0, 7) == "-depth=")
|
|---|
| 1292 | {
|
|---|
| 1293 | local = false;
|
|---|
| 1294 |
|
|---|
| 1295 | cmt_string depth_str;
|
|---|
| 1296 | int depth_value = 0;
|
|---|
| 1297 |
|
|---|
| 1298 | w.substr (7, depth_str);
|
|---|
| 1299 | if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
|
|---|
| 1300 | (depth_value < 1))
|
|---|
| 1301 | {
|
|---|
| 1302 | // Syntax error
|
|---|
| 1303 | // We shall restrict to packages found within
|
|---|
| 1304 | // the <depth_value> first elements of CMTPATH.
|
|---|
| 1305 | // If CMTPATH is empty, nothing is selected.
|
|---|
| 1306 | // depth=1 is equivalent to local
|
|---|
| 1307 | }
|
|---|
| 1308 |
|
|---|
| 1309 | Project::fill_selection (depth_value, path_selections);
|
|---|
| 1310 | }
|
|---|
| 1311 | else if (w.substr (0, 9) == "-exclude=")
|
|---|
| 1312 | {
|
|---|
| 1313 | cmt_string exclusion;
|
|---|
| 1314 |
|
|---|
| 1315 | w.substr (9, exclusion);
|
|---|
| 1316 |
|
|---|
| 1317 | int size = exclusion.size ();
|
|---|
| 1318 |
|
|---|
| 1319 | if (size >= 2)
|
|---|
| 1320 | {
|
|---|
| 1321 | if (((exclusion[0] == '"') && (exclusion[size - 1] == '"')) ||
|
|---|
| 1322 | ((exclusion[0] == '\'') && (exclusion[size - 1] == '\'')))
|
|---|
| 1323 | {
|
|---|
| 1324 | exclusion.erase (size - 1);
|
|---|
| 1325 | exclusion.erase (0, 1);
|
|---|
| 1326 | }
|
|---|
| 1327 |
|
|---|
| 1328 | CmtSystem::split (exclusion, " \t", exclusions);
|
|---|
| 1329 | }
|
|---|
| 1330 | }
|
|---|
| 1331 | else if (w.substr (0, 7) == "-global")
|
|---|
| 1332 | {
|
|---|
| 1333 | path_selections.clear ();
|
|---|
| 1334 |
|
|---|
| 1335 | local = false;
|
|---|
| 1336 | }
|
|---|
| 1337 | else if (w.substr (0, 6) == "-local")
|
|---|
| 1338 | {
|
|---|
| 1339 | local = true;
|
|---|
| 1340 | }
|
|---|
| 1341 | else if (w.substr (0, 8) == "-select=")
|
|---|
| 1342 | {
|
|---|
| 1343 | cmt_string selection;
|
|---|
| 1344 |
|
|---|
| 1345 | w.substr (8, selection);
|
|---|
| 1346 |
|
|---|
| 1347 | int size = selection.size ();
|
|---|
| 1348 |
|
|---|
| 1349 | if (size >= 2)
|
|---|
| 1350 | {
|
|---|
| 1351 | if (((selection[0] == '"') && (selection[size - 1] == '"')) ||
|
|---|
| 1352 | ((selection[0] == '\'') && (selection[size - 1] == '\'')))
|
|---|
| 1353 | {
|
|---|
| 1354 | selection.erase (size - 1);
|
|---|
| 1355 | selection.erase (0, 1);
|
|---|
| 1356 | }
|
|---|
| 1357 |
|
|---|
| 1358 | CmtSystem::split (selection, " \t", selections);
|
|---|
| 1359 | }
|
|---|
| 1360 | }
|
|---|
| 1361 | else if (w.substr (0, 7) == "-begin=")
|
|---|
| 1362 | {
|
|---|
| 1363 | w.substr (7, begin);
|
|---|
| 1364 | }
|
|---|
| 1365 | else
|
|---|
| 1366 | {
|
|---|
| 1367 | command = w;
|
|---|
| 1368 | }
|
|---|
| 1369 | }
|
|---|
| 1370 | else
|
|---|
| 1371 | {
|
|---|
| 1372 | command += " ";
|
|---|
| 1373 | command += w;
|
|---|
| 1374 | }
|
|---|
| 1375 |
|
|---|
| 1376 | }
|
|---|
| 1377 |
|
|---|
| 1378 | if (local)
|
|---|
| 1379 | {
|
|---|
| 1380 | Project::fill_selection (1, path_selections);
|
|---|
| 1381 | }
|
|---|
| 1382 |
|
|---|
| 1383 | if (command[0] == '-')
|
|---|
| 1384 | {
|
|---|
| 1385 | ignore_errors = true;
|
|---|
| 1386 | command.erase (0, 1);
|
|---|
| 1387 | }
|
|---|
| 1388 |
|
|---|
| 1389 | //if (command.substr (0, 3) == "cmt") is_cmt = true;
|
|---|
| 1390 |
|
|---|
| 1391 | if (all_packages)
|
|---|
| 1392 | {
|
|---|
| 1393 | PackageSelector selector (uses);
|
|---|
| 1394 | PathScanner scanner;
|
|---|
| 1395 | Project::scan_paths (scanner, selector);
|
|---|
| 1396 | }
|
|---|
| 1397 | else
|
|---|
| 1398 | {
|
|---|
| 1399 | for (i = Uses.size () - 1; i >= 0; i--)
|
|---|
| 1400 | {
|
|---|
| 1401 | Use* use = Uses[i];
|
|---|
| 1402 |
|
|---|
| 1403 | if (use->discarded) continue;
|
|---|
| 1404 |
|
|---|
| 1405 | if (!use->located ())
|
|---|
| 1406 | {
|
|---|
| 1407 | if (!Cmt::m_quiet)
|
|---|
| 1408 | {
|
|---|
| 1409 | cerr << "#CMT> package " << use->get_package_name () <<
|
|---|
| 1410 | " " << use->version << " " << use->path <<
|
|---|
| 1411 | " not found" <<
|
|---|
| 1412 | endl;
|
|---|
| 1413 | }
|
|---|
| 1414 | }
|
|---|
| 1415 | else
|
|---|
| 1416 | {
|
|---|
| 1417 | if (use->get_package_name () != "CMT")
|
|---|
| 1418 | {
|
|---|
| 1419 | cmt_string& s = uses.add ();
|
|---|
| 1420 |
|
|---|
| 1421 | use->get_full_path (s);
|
|---|
| 1422 |
|
|---|
| 1423 | s += CmtSystem::file_separator ();
|
|---|
| 1424 | if (use->style == mgr_style) s += "mgr";
|
|---|
| 1425 | else s += "cmt";
|
|---|
| 1426 |
|
|---|
| 1427 | cmt_string& v = versions.add ();
|
|---|
| 1428 | v = use->version;
|
|---|
| 1429 |
|
|---|
| 1430 | cmt_string& p = packages.add ();
|
|---|
| 1431 | p = use->get_package_name ();
|
|---|
| 1432 |
|
|---|
| 1433 | //cout << ">>> adding " << s << " to selection" << endl;
|
|---|
| 1434 | }
|
|---|
| 1435 | }
|
|---|
| 1436 | }
|
|---|
| 1437 |
|
|---|
| 1438 | {
|
|---|
| 1439 | cmt_string& s = uses.add ();
|
|---|
| 1440 |
|
|---|
| 1441 | Use* use = &(Use::current ());
|
|---|
| 1442 |
|
|---|
| 1443 | if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
|
|---|
| 1444 | {
|
|---|
| 1445 | s = CmtSystem::pwd ();
|
|---|
| 1446 | }
|
|---|
| 1447 | else
|
|---|
| 1448 | {
|
|---|
| 1449 | use->get_full_path (s);
|
|---|
| 1450 |
|
|---|
| 1451 | s += CmtSystem::file_separator ();
|
|---|
| 1452 |
|
|---|
| 1453 | if (use->style == mgr_style) s += "mgr";
|
|---|
| 1454 | else s += "cmt";
|
|---|
| 1455 | }
|
|---|
| 1456 |
|
|---|
| 1457 | cmt_string& v = versions.add ();
|
|---|
| 1458 | v = use->version;
|
|---|
| 1459 |
|
|---|
| 1460 | cmt_string& p = packages.add ();
|
|---|
| 1461 | p = use->get_package_name ();
|
|---|
| 1462 |
|
|---|
| 1463 | //cout << ">>> adding current " << s << " to selection" << endl;
|
|---|
| 1464 | }
|
|---|
| 1465 | }
|
|---|
| 1466 |
|
|---|
| 1467 | bool started = false;
|
|---|
| 1468 |
|
|---|
| 1469 | if (begin == "") started = true;
|
|---|
| 1470 |
|
|---|
| 1471 | Symbol::all_set ();
|
|---|
| 1472 |
|
|---|
| 1473 | for (i = 0; i < uses.size (); i++)
|
|---|
| 1474 | {
|
|---|
| 1475 | const cmt_string& s = uses[i];
|
|---|
| 1476 | const cmt_string& v = versions[i];
|
|---|
| 1477 | const cmt_string& p = packages[i];
|
|---|
| 1478 | cmt_string cmtpath;
|
|---|
| 1479 |
|
|---|
| 1480 | bool ok = true;
|
|---|
| 1481 | bool selected = true;
|
|---|
| 1482 | bool excluded = false;
|
|---|
| 1483 |
|
|---|
| 1484 | if (path_selections.size () > 0)
|
|---|
| 1485 | {
|
|---|
| 1486 | selected = false;
|
|---|
| 1487 |
|
|---|
| 1488 | for (int j = 0; j < path_selections.size (); j++)
|
|---|
| 1489 | {
|
|---|
| 1490 | const cmt_string& sel = path_selections[j];
|
|---|
| 1491 |
|
|---|
| 1492 | if (s.find (sel) != cmt_string::npos)
|
|---|
| 1493 | {
|
|---|
| 1494 | cmtpath = sel;
|
|---|
| 1495 | selected = true;
|
|---|
| 1496 | break;
|
|---|
| 1497 | }
|
|---|
| 1498 | }
|
|---|
| 1499 |
|
|---|
| 1500 | ok = selected;
|
|---|
| 1501 | }
|
|---|
| 1502 |
|
|---|
| 1503 | if (ok)
|
|---|
| 1504 | {
|
|---|
| 1505 | if (selections.size () > 0)
|
|---|
| 1506 | {
|
|---|
| 1507 | selected = false;
|
|---|
| 1508 |
|
|---|
| 1509 | for (int j = 0; j < selections.size (); j++)
|
|---|
| 1510 | {
|
|---|
| 1511 | const cmt_string& sel = selections[j];
|
|---|
| 1512 |
|
|---|
| 1513 | if (s.find (sel) != cmt_string::npos)
|
|---|
| 1514 | {
|
|---|
| 1515 | selected = true;
|
|---|
| 1516 | break;
|
|---|
| 1517 | }
|
|---|
| 1518 | }
|
|---|
| 1519 |
|
|---|
| 1520 | ok = selected;
|
|---|
| 1521 | }
|
|---|
| 1522 | }
|
|---|
| 1523 |
|
|---|
| 1524 | if (ok && !started)
|
|---|
| 1525 | {
|
|---|
| 1526 | if (s.find (begin) != cmt_string::npos)
|
|---|
| 1527 | {
|
|---|
| 1528 | started = true;
|
|---|
| 1529 | ok = true;
|
|---|
| 1530 | }
|
|---|
| 1531 | else
|
|---|
| 1532 | {
|
|---|
| 1533 | ok = false;
|
|---|
| 1534 | }
|
|---|
| 1535 | }
|
|---|
| 1536 |
|
|---|
| 1537 |
|
|---|
| 1538 | if (ok)
|
|---|
| 1539 | {
|
|---|
| 1540 | excluded = false;
|
|---|
| 1541 |
|
|---|
| 1542 | for (int j = 0; j < exclusions.size (); j++)
|
|---|
| 1543 | {
|
|---|
| 1544 | const cmt_string& exc = exclusions[j];
|
|---|
| 1545 |
|
|---|
| 1546 | if (s.find (exc) != cmt_string::npos)
|
|---|
| 1547 | {
|
|---|
| 1548 | excluded = true;
|
|---|
| 1549 | break;
|
|---|
| 1550 | }
|
|---|
| 1551 | }
|
|---|
| 1552 |
|
|---|
| 1553 | if (excluded) ok = false;
|
|---|
| 1554 | }
|
|---|
| 1555 |
|
|---|
| 1556 | if (!ok)
|
|---|
| 1557 | {
|
|---|
| 1558 | continue;
|
|---|
| 1559 | }
|
|---|
| 1560 |
|
|---|
| 1561 |
|
|---|
| 1562 |
|
|---|
| 1563 | if (!CmtSystem::cd (s))
|
|---|
| 1564 | {
|
|---|
| 1565 | if (s.find ("cmt_standalone") != cmt_string::npos)
|
|---|
| 1566 | {
|
|---|
| 1567 | cerr << "#CMT> Currently not in a CMT package" << endl;
|
|---|
| 1568 | }
|
|---|
| 1569 | else
|
|---|
| 1570 | {
|
|---|
| 1571 | cerr << "#CMT> Cannot move to the package in " << s << " (" << i+1 << "/"
|
|---|
| 1572 | << uses.size () << ")"<< endl;
|
|---|
| 1573 | }
|
|---|
| 1574 |
|
|---|
| 1575 | if (!ignore_errors) break;
|
|---|
| 1576 |
|
|---|
| 1577 | continue;
|
|---|
| 1578 | }
|
|---|
| 1579 |
|
|---|
| 1580 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1581 | {
|
|---|
| 1582 | cerr << "#CMT> Ignore locked package in " << s << " (" << i+1 << "/"
|
|---|
| 1583 | << uses.size () << ")" << endl;
|
|---|
| 1584 | continue;
|
|---|
| 1585 | }
|
|---|
| 1586 |
|
|---|
| 1587 | if (cmtpath == "")
|
|---|
| 1588 | {
|
|---|
| 1589 | cmt_string sel = CmtSystem::pwd ();
|
|---|
| 1590 | cmtpath = Project::find_in_cmt_paths (sel);
|
|---|
| 1591 | }
|
|---|
| 1592 |
|
|---|
| 1593 | cmt_string cmd = command;
|
|---|
| 1594 | static const cmt_string version_template = "<version>";
|
|---|
| 1595 | cmd.replace_all (version_template, v);
|
|---|
| 1596 |
|
|---|
| 1597 | static const cmt_string package_template = "<package>";
|
|---|
| 1598 | cmd.replace_all (package_template, p);
|
|---|
| 1599 |
|
|---|
| 1600 | static const cmt_string cmtpath_template = "<package_cmtpath>";
|
|---|
| 1601 | cmd.replace_all (cmtpath_template, cmtpath);
|
|---|
| 1602 |
|
|---|
| 1603 | static const cmt_string offset_template = "<package_offset>";
|
|---|
| 1604 |
|
|---|
| 1605 | static const cmt_string empty_string;
|
|---|
| 1606 | static const cmt_string fs = CmtSystem::file_separator ();
|
|---|
| 1607 | cmt_string offset = s;
|
|---|
| 1608 | offset.replace (cmtpath, empty_string);
|
|---|
| 1609 | if (offset[0] == CmtSystem::file_separator ())
|
|---|
| 1610 | {
|
|---|
| 1611 | offset.replace (fs, empty_string);
|
|---|
| 1612 | }
|
|---|
| 1613 | CmtSystem::dirname (offset, offset);
|
|---|
| 1614 |
|
|---|
| 1615 | cmt_string n;
|
|---|
| 1616 | CmtSystem::basename (offset, n);
|
|---|
| 1617 | if (n == p)
|
|---|
| 1618 | {
|
|---|
| 1619 | CmtSystem::dirname (offset, offset);
|
|---|
| 1620 | }
|
|---|
| 1621 | else
|
|---|
| 1622 | {
|
|---|
| 1623 | CmtSystem::dirname (offset, offset);
|
|---|
| 1624 | CmtSystem::dirname (offset, offset);
|
|---|
| 1625 | }
|
|---|
| 1626 |
|
|---|
| 1627 | cmd.replace_all (offset_template, offset);
|
|---|
| 1628 |
|
|---|
| 1629 |
|
|---|
| 1630 | cout << "#--------------------------------------------------------------" << endl;
|
|---|
| 1631 | cout << "# Now trying [" << cmd << "] in " << s << " (" << i+1 << "/" << uses.size ()
|
|---|
| 1632 | << ")" << endl;
|
|---|
| 1633 | cout << "#--------------------------------------------------------------" << endl;
|
|---|
| 1634 |
|
|---|
| 1635 | if (is_cmt)
|
|---|
| 1636 | {
|
|---|
| 1637 | //
|
|---|
| 1638 | // There is a bug in the recursive use of the parser. Macros are not set correctly.
|
|---|
| 1639 | // Thus the recursive optimization is now discarded.
|
|---|
| 1640 | //
|
|---|
| 1641 | if (parser (cmd) != 0)
|
|---|
| 1642 | {
|
|---|
| 1643 | CmtError::set (CmtError::execution_error, cmd);
|
|---|
| 1644 | break;
|
|---|
| 1645 | }
|
|---|
| 1646 | }
|
|---|
| 1647 | else
|
|---|
| 1648 | {
|
|---|
| 1649 | int status = CmtSystem::execute (cmd);
|
|---|
| 1650 |
|
|---|
| 1651 | //cerr << "do_broadcast> status=" << status << " ignore_errors=" << ignore_errors << endl;
|
|---|
| 1652 |
|
|---|
| 1653 | if ((status != 0) && !ignore_errors)
|
|---|
| 1654 | //if ((status != 0) && !ignore_errors)
|
|---|
| 1655 | {
|
|---|
| 1656 | if (status != 2) CmtError::set (CmtError::execution_error, cmd);
|
|---|
| 1657 | break;
|
|---|
| 1658 | }
|
|---|
| 1659 | }
|
|---|
| 1660 | }
|
|---|
| 1661 | }
|
|---|
| 1662 |
|
|---|
| 1663 | //----------------------------------------------------------
|
|---|
| 1664 | void Cmt::do_build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 1665 | int argc,
|
|---|
| 1666 | char* argv[])
|
|---|
| 1667 | {
|
|---|
| 1668 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1669 | {
|
|---|
| 1670 | CmtError::set (CmtError::conflicting_lock, "build_constituent_makefile>");
|
|---|
| 1671 | return;
|
|---|
| 1672 | }
|
|---|
| 1673 | if (arguments.size () > 0)
|
|---|
| 1674 | {
|
|---|
| 1675 | set_standard_macros ();
|
|---|
| 1676 | Generator::build_constituent_makefile (arguments[0]);
|
|---|
| 1677 | }
|
|---|
| 1678 | }
|
|---|
| 1679 |
|
|---|
| 1680 | //----------------------------------------------------------
|
|---|
| 1681 | void Cmt::do_build_constituents_makefile (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 1682 | int argc,
|
|---|
| 1683 | char* argv[])
|
|---|
| 1684 | {
|
|---|
| 1685 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1686 | {
|
|---|
| 1687 | CmtError::set (CmtError::conflicting_lock, "build_constituents_makefile>");
|
|---|
| 1688 | return;
|
|---|
| 1689 | }
|
|---|
| 1690 | set_standard_macros ();
|
|---|
| 1691 |
|
|---|
| 1692 | Generator::build_constituents_makefile (m_current_package, arguments);
|
|---|
| 1693 | }
|
|---|
| 1694 |
|
|---|
| 1695 | //----------------------------------------------------------
|
|---|
| 1696 | void Cmt::do_build_dependencies (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 1697 | int argc,
|
|---|
| 1698 | char* argv[])
|
|---|
| 1699 | {
|
|---|
| 1700 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1701 | {
|
|---|
| 1702 | CmtError::set (CmtError::conflicting_lock, "build_dependencies>");
|
|---|
| 1703 | return;
|
|---|
| 1704 | }
|
|---|
| 1705 | if (arguments.size () > 0)
|
|---|
| 1706 | {
|
|---|
| 1707 | set_standard_macros ();
|
|---|
| 1708 |
|
|---|
| 1709 | while (argc > 0)
|
|---|
| 1710 | {
|
|---|
| 1711 | if (strcmp (argv[0], "dependencies") != 0)
|
|---|
| 1712 | {
|
|---|
| 1713 | argc--;
|
|---|
| 1714 | argv++;
|
|---|
| 1715 | }
|
|---|
| 1716 | else
|
|---|
| 1717 | {
|
|---|
| 1718 | argc--;
|
|---|
| 1719 | argv++;
|
|---|
| 1720 | argc--;
|
|---|
| 1721 | argv++;
|
|---|
| 1722 |
|
|---|
| 1723 | Generator::build_dependencies (arguments[0], argc, argv);
|
|---|
| 1724 |
|
|---|
| 1725 | break;
|
|---|
| 1726 | }
|
|---|
| 1727 | }
|
|---|
| 1728 | }
|
|---|
| 1729 | }
|
|---|
| 1730 |
|
|---|
| 1731 | //----------------------------------------------------------
|
|---|
| 1732 | void Cmt::do_build_library_links ()
|
|---|
| 1733 | {
|
|---|
| 1734 | cmt_string cmtinstallarea = "";
|
|---|
| 1735 | cmt_string tag = "";
|
|---|
| 1736 | cmt_string shlibsuffix;
|
|---|
| 1737 | cmt_string symlinkcmd;
|
|---|
| 1738 |
|
|---|
| 1739 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1740 | {
|
|---|
| 1741 | CmtError::set (CmtError::conflicting_lock, "build_library_links>");
|
|---|
| 1742 | return;
|
|---|
| 1743 | }
|
|---|
| 1744 |
|
|---|
| 1745 | set_standard_macros ();
|
|---|
| 1746 |
|
|---|
| 1747 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 1748 | Use& current_use = Use::current ();
|
|---|
| 1749 | int i;
|
|---|
| 1750 |
|
|---|
| 1751 | {
|
|---|
| 1752 | Symbol* macro = Symbol::find ("shlibsuffix");
|
|---|
| 1753 | if (macro == 0) return;
|
|---|
| 1754 | shlibsuffix = macro->build_macro_value ();
|
|---|
| 1755 | Symbol::expand (shlibsuffix);
|
|---|
| 1756 | }
|
|---|
| 1757 |
|
|---|
| 1758 | {
|
|---|
| 1759 | Symbol* macro = Symbol::find ("cmt_symlink_command");
|
|---|
| 1760 | if (macro != 0)
|
|---|
| 1761 | {
|
|---|
| 1762 | symlinkcmd = macro->build_macro_value ();
|
|---|
| 1763 | Symbol::expand (symlinkcmd);
|
|---|
| 1764 | }
|
|---|
| 1765 | }
|
|---|
| 1766 |
|
|---|
| 1767 | if ((get_build_strategy () & InstallAreaMask) == WithInstallArea)
|
|---|
| 1768 | {
|
|---|
| 1769 | const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
|
|---|
| 1770 |
|
|---|
| 1771 | //cout << "#IA2>" << endl;
|
|---|
| 1772 |
|
|---|
| 1773 | cmt_string s1 = ia_mgr.get_installarea ();
|
|---|
| 1774 |
|
|---|
| 1775 | {
|
|---|
| 1776 | Symbol* symbol = Symbol::find ("CMTINSTALLAREA");
|
|---|
| 1777 | if (symbol != 0)
|
|---|
| 1778 | {
|
|---|
| 1779 | s1 = symbol->build_macro_value ();
|
|---|
| 1780 | Symbol::expand (s1);
|
|---|
| 1781 | }
|
|---|
| 1782 | }
|
|---|
| 1783 |
|
|---|
| 1784 | cmtinstallarea = s1;
|
|---|
| 1785 |
|
|---|
| 1786 | cmt_string s2;
|
|---|
| 1787 |
|
|---|
| 1788 | {
|
|---|
| 1789 | Symbol* macro = Symbol::find ("tag");
|
|---|
| 1790 | if (macro != 0)
|
|---|
| 1791 | {
|
|---|
| 1792 | s2 = macro->build_macro_value ();
|
|---|
| 1793 | Symbol::expand (s2);
|
|---|
| 1794 | }
|
|---|
| 1795 | }
|
|---|
| 1796 |
|
|---|
| 1797 | tag = s2;
|
|---|
| 1798 |
|
|---|
| 1799 | cmt_string s = s1;
|
|---|
| 1800 | s += CmtSystem::file_separator ();
|
|---|
| 1801 | s += s2;
|
|---|
| 1802 | s += CmtSystem::file_separator ();
|
|---|
| 1803 | s += "lib";
|
|---|
| 1804 |
|
|---|
| 1805 | CmtSystem::mkdir (s);
|
|---|
| 1806 | }
|
|---|
| 1807 |
|
|---|
| 1808 | current_use.build_library_links (cmtinstallarea, tag, shlibsuffix, symlinkcmd);
|
|---|
| 1809 |
|
|---|
| 1810 | for (i = 0; i < Uses.size (); i++)
|
|---|
| 1811 | {
|
|---|
| 1812 | Use* use = Uses[i];
|
|---|
| 1813 |
|
|---|
| 1814 | if (use == 0) continue;
|
|---|
| 1815 | if (use->discarded) continue;
|
|---|
| 1816 |
|
|---|
| 1817 | if (use->get_package_name () == "CMT") continue;
|
|---|
| 1818 | if (use->get_package_name () == current_use.get_package_name ()) continue;
|
|---|
| 1819 |
|
|---|
| 1820 | use->build_library_links (cmtinstallarea, tag, shlibsuffix, symlinkcmd);
|
|---|
| 1821 | }
|
|---|
| 1822 | }
|
|---|
| 1823 |
|
|---|
| 1824 | //----------------------------------------------------------
|
|---|
| 1825 | void Cmt::do_build_make_setup ()
|
|---|
| 1826 | {
|
|---|
| 1827 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1828 | {
|
|---|
| 1829 | CmtError::set (CmtError::conflicting_lock, "build_make_setup>");
|
|---|
| 1830 | return;
|
|---|
| 1831 | }
|
|---|
| 1832 | set_standard_macros ();
|
|---|
| 1833 | Generator::build_make_setup (m_current_package);
|
|---|
| 1834 | }
|
|---|
| 1835 |
|
|---|
| 1836 | //----------------------------------------------------------
|
|---|
| 1837 | void Cmt::do_build_msdev (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1838 | {
|
|---|
| 1839 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1840 | {
|
|---|
| 1841 | CmtError::set (CmtError::conflicting_lock, "build_msdev>");
|
|---|
| 1842 | return;
|
|---|
| 1843 | }
|
|---|
| 1844 |
|
|---|
| 1845 | if (true)
|
|---|
| 1846 | {
|
|---|
| 1847 | set_standard_macros ();
|
|---|
| 1848 | if (arguments.size () > 0) build_msdev_file (arguments[0]);
|
|---|
| 1849 | else build_msdev_file ("");
|
|---|
| 1850 | }
|
|---|
| 1851 | }
|
|---|
| 1852 |
|
|---|
| 1853 | void Cmt::do_build_CMT_pacman ()
|
|---|
| 1854 | {
|
|---|
| 1855 | cmt_string pacman_file;
|
|---|
| 1856 |
|
|---|
| 1857 | pacman_file = m_cmt_root;
|
|---|
| 1858 | pacman_file += CmtSystem::file_separator ();
|
|---|
| 1859 | pacman_file += "mgr";
|
|---|
| 1860 | pacman_file += CmtSystem::file_separator ();
|
|---|
| 1861 | pacman_file += "CMT.pacman";
|
|---|
| 1862 |
|
|---|
| 1863 | cmt_string pacman;
|
|---|
| 1864 | cmt_string pattern = "<version>";
|
|---|
| 1865 | cmt_string replacement = CMTVERSION;
|
|---|
| 1866 |
|
|---|
| 1867 | pacman.read (pacman_file);
|
|---|
| 1868 |
|
|---|
| 1869 | pacman.replace_all (pattern, replacement);
|
|---|
| 1870 |
|
|---|
| 1871 | cout << pacman << endl;
|
|---|
| 1872 | }
|
|---|
| 1873 |
|
|---|
| 1874 | // Visual Studio.net Support
|
|---|
| 1875 | //----------------------------------------------------------
|
|---|
| 1876 | void Cmt::do_build_vsnet (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1877 | {
|
|---|
| 1878 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1879 | {
|
|---|
| 1880 | CmtError::set (CmtError::conflicting_lock, "build_vsnet>");
|
|---|
| 1881 | return;
|
|---|
| 1882 | }
|
|---|
| 1883 |
|
|---|
| 1884 | if (true)
|
|---|
| 1885 | {
|
|---|
| 1886 | set_standard_macros ();
|
|---|
| 1887 | if (arguments.size () > 0) build_vsnet_file (arguments[0]);
|
|---|
| 1888 | else build_vsnet_file ("");
|
|---|
| 1889 | }
|
|---|
| 1890 | }
|
|---|
| 1891 |
|
|---|
| 1892 | //----------------------------------------------------------
|
|---|
| 1893 | void Cmt::do_build_os9_makefile (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1894 | {
|
|---|
| 1895 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1896 | {
|
|---|
| 1897 | CmtError::set (CmtError::conflicting_lock, "build_os9_makefile>");
|
|---|
| 1898 | return;
|
|---|
| 1899 | }
|
|---|
| 1900 |
|
|---|
| 1901 | if (arguments.size () > 0)
|
|---|
| 1902 | {
|
|---|
| 1903 | set_standard_macros ();
|
|---|
| 1904 | build_OS9_makefile (arguments[0]);
|
|---|
| 1905 | }
|
|---|
| 1906 | }
|
|---|
| 1907 |
|
|---|
| 1908 | //----------------------------------------------------------
|
|---|
| 1909 | void Cmt::do_build_prototype (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1910 | {
|
|---|
| 1911 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1912 | {
|
|---|
| 1913 | CmtError::set (CmtError::conflicting_lock, "build_prototype>");
|
|---|
| 1914 | return;
|
|---|
| 1915 | }
|
|---|
| 1916 |
|
|---|
| 1917 | if (arguments.size () > 0)
|
|---|
| 1918 | {
|
|---|
| 1919 | set_standard_macros ();
|
|---|
| 1920 | Generator::build_prototype (arguments[0]);
|
|---|
| 1921 | }
|
|---|
| 1922 | }
|
|---|
| 1923 |
|
|---|
| 1924 | //----------------------------------------------------------
|
|---|
| 1925 | void Cmt::do_build_readme (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1926 | {
|
|---|
| 1927 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1928 | {
|
|---|
| 1929 | CmtError::set (CmtError::conflicting_lock, "build_readme>");
|
|---|
| 1930 | return;
|
|---|
| 1931 | }
|
|---|
| 1932 |
|
|---|
| 1933 | set_standard_macros ();
|
|---|
| 1934 | Generator::build_readme (arguments);
|
|---|
| 1935 | }
|
|---|
| 1936 |
|
|---|
| 1937 | //----------------------------------------------------------
|
|---|
| 1938 | void Cmt::do_build_tag_makefile ()
|
|---|
| 1939 | {
|
|---|
| 1940 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1941 | {
|
|---|
| 1942 | CmtError::set (CmtError::conflicting_lock, "build_tag_makefile>");
|
|---|
| 1943 | return;
|
|---|
| 1944 | }
|
|---|
| 1945 |
|
|---|
| 1946 | print_macros (Make);
|
|---|
| 1947 | }
|
|---|
| 1948 |
|
|---|
| 1949 | //----------------------------------------------------------
|
|---|
| 1950 | void Cmt::do_build_temporary_name ()
|
|---|
| 1951 | {
|
|---|
| 1952 | cmt_string name = CmtSystem::get_temporary_name ();
|
|---|
| 1953 | cout << name << endl;
|
|---|
| 1954 | }
|
|---|
| 1955 |
|
|---|
| 1956 | //----------------------------------------------------------
|
|---|
| 1957 | void Cmt::do_build_triggers (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1958 | {
|
|---|
| 1959 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1960 | {
|
|---|
| 1961 | CmtError::set (CmtError::conflicting_lock, "build_tag_makefile>");
|
|---|
| 1962 | return;
|
|---|
| 1963 | }
|
|---|
| 1964 |
|
|---|
| 1965 | if (arguments.size () > 0)
|
|---|
| 1966 | {
|
|---|
| 1967 | set_standard_macros ();
|
|---|
| 1968 | TriggerGenerator::run (arguments[0]);
|
|---|
| 1969 | }
|
|---|
| 1970 | }
|
|---|
| 1971 |
|
|---|
| 1972 | //----------------------------------------------------------
|
|---|
| 1973 | void Cmt::do_build_windefs (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1974 | {
|
|---|
| 1975 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 1976 | {
|
|---|
| 1977 | CmtError::set (CmtError::conflicting_lock, "build_windefs>");
|
|---|
| 1978 | return;
|
|---|
| 1979 | }
|
|---|
| 1980 |
|
|---|
| 1981 | if (arguments.size () > 0)
|
|---|
| 1982 | {
|
|---|
| 1983 | set_standard_macros ();
|
|---|
| 1984 | Generator::build_windefs (arguments[0]);
|
|---|
| 1985 | }
|
|---|
| 1986 | }
|
|---|
| 1987 |
|
|---|
| 1988 | //----------------------------------------------------------
|
|---|
| 1989 | void Cmt::do_check_configuration ()
|
|---|
| 1990 | {
|
|---|
| 1991 | }
|
|---|
| 1992 |
|
|---|
| 1993 | //----------------------------------------------------------
|
|---|
| 1994 | void Cmt::do_check_files (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 1995 | {
|
|---|
| 1996 | if (arguments.size () >= 2)
|
|---|
| 1997 | {
|
|---|
| 1998 | cmt_string first_file = arguments[0];
|
|---|
| 1999 | cmt_string second_file = arguments[1];
|
|---|
| 2000 |
|
|---|
| 2001 | if (first_file == "") return;
|
|---|
| 2002 | if (second_file == "") return;
|
|---|
| 2003 |
|
|---|
| 2004 | CmtSystem::compare_and_update_files (first_file, second_file);
|
|---|
| 2005 | }
|
|---|
| 2006 | }
|
|---|
| 2007 |
|
|---|
| 2008 | //----------------------------------------------------------
|
|---|
| 2009 | void Cmt::do_check_version (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2010 | {
|
|---|
| 2011 | if (arguments.size () > 0)
|
|---|
| 2012 | {
|
|---|
| 2013 | cmt_string name = arguments[0];
|
|---|
| 2014 |
|
|---|
| 2015 | if (name == "") return;
|
|---|
| 2016 | int v = 0;
|
|---|
| 2017 | int r = 0;
|
|---|
| 2018 | int p = 0;
|
|---|
| 2019 |
|
|---|
| 2020 | bool ok = CmtSystem::is_version_directory (name, v, r, p);
|
|---|
| 2021 |
|
|---|
| 2022 | if (ok)
|
|---|
| 2023 | {
|
|---|
| 2024 | cout << "# " << name << " is version " << v << " release " << r << " patch " << p << endl;
|
|---|
| 2025 | }
|
|---|
| 2026 | else
|
|---|
| 2027 | {
|
|---|
| 2028 | cout << "# " << name << " is not a version tag" << endl;
|
|---|
| 2029 | }
|
|---|
| 2030 | }
|
|---|
| 2031 | }
|
|---|
| 2032 |
|
|---|
| 2033 | //----------------------------------------------------------
|
|---|
| 2034 | void Cmt::do_checkout (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2035 | {
|
|---|
| 2036 | Cvs::checkout (arguments);
|
|---|
| 2037 | }
|
|---|
| 2038 |
|
|---|
| 2039 | //----------------------------------------------------------
|
|---|
| 2040 | void Cmt::do_cleanup (PrintMode& mode)
|
|---|
| 2041 | {
|
|---|
| 2042 | print_clean (mode);
|
|---|
| 2043 | }
|
|---|
| 2044 |
|
|---|
| 2045 | //----------------------------------------------------------
|
|---|
| 2046 | void Cmt::do_config ()
|
|---|
| 2047 | {
|
|---|
| 2048 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 2049 | {
|
|---|
| 2050 | CmtError::set (CmtError::conflicting_lock, "config>");
|
|---|
| 2051 | return;
|
|---|
| 2052 | }
|
|---|
| 2053 |
|
|---|
| 2054 | //Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 2055 |
|
|---|
| 2056 | if (m_debug)
|
|---|
| 2057 | {
|
|---|
| 2058 | cout << "Cmt::do_config> " << endl;
|
|---|
| 2059 | cout << "pwd " << CmtSystem::pwd () << endl;
|
|---|
| 2060 | cout << "current_dir " << m_current_dir << endl;
|
|---|
| 2061 | cout << "default_path " << m_default_path << endl;
|
|---|
| 2062 | cout << "cmt config " <<
|
|---|
| 2063 | m_current_package << " " <<
|
|---|
| 2064 | m_current_version << " " <<
|
|---|
| 2065 | m_current_path << endl;
|
|---|
| 2066 | }
|
|---|
| 2067 |
|
|---|
| 2068 | if (m_current_package == "CMT") return;
|
|---|
| 2069 | if (m_current_package == "methods") return;
|
|---|
| 2070 |
|
|---|
| 2071 | cmt_string branch;
|
|---|
| 2072 |
|
|---|
| 2073 | CmtSystem::basename (m_current_dir, branch);
|
|---|
| 2074 |
|
|---|
| 2075 | if ((branch != "mgr") && (branch != "cmt"))
|
|---|
| 2076 | {
|
|---|
| 2077 |
|
|---|
| 2078 | //
|
|---|
| 2079 | // Here we are in a standalone package (ie completely unstructured)
|
|---|
| 2080 | //
|
|---|
| 2081 |
|
|---|
| 2082 | if (CmtSystem::test_file ("requirements"))
|
|---|
| 2083 | {
|
|---|
| 2084 | cout << "------------------------------------------" << endl;
|
|---|
| 2085 | cout << "Configuring environment for standalone package." << endl;
|
|---|
| 2086 | cout << "CMT version " << m_cmt_version << "." << endl;
|
|---|
| 2087 | cout << "System is " << m_cmt_config << endl;
|
|---|
| 2088 | cout << "------------------------------------------" << endl;
|
|---|
| 2089 |
|
|---|
| 2090 | install_test_setup_scripts ();
|
|---|
| 2091 | install_test_cleanup_scripts ();
|
|---|
| 2092 |
|
|---|
| 2093 | Generator::build_default_makefile ();
|
|---|
| 2094 | }
|
|---|
| 2095 | else
|
|---|
| 2096 | {
|
|---|
| 2097 | cout << "==============================================" << endl;
|
|---|
| 2098 | cout << "cmt config must be operated either upon "
|
|---|
| 2099 | "an existing package" << endl;
|
|---|
| 2100 | cout << " (ie. when a requirements file already exists)" << endl;
|
|---|
| 2101 | cout << " > cd ..." << endl;
|
|---|
| 2102 | cout << " > cmt config" << endl;
|
|---|
| 2103 | cout << "or to create a new package" << endl;
|
|---|
| 2104 | cout << " > cmt config <package> <version> [<path>]" << endl;
|
|---|
| 2105 | cout << "==============================================" << endl;
|
|---|
| 2106 | }
|
|---|
| 2107 |
|
|---|
| 2108 | return;
|
|---|
| 2109 | }
|
|---|
| 2110 |
|
|---|
| 2111 | configure_current_package ();
|
|---|
| 2112 |
|
|---|
| 2113 | Generator::build_default_makefile ();
|
|---|
| 2114 |
|
|---|
| 2115 | CmtSystem::cmt_string_vector makes;
|
|---|
| 2116 | cmt_regexp expression ("[.]n?make(sav)?$");
|
|---|
| 2117 |
|
|---|
| 2118 | CmtSystem::scan_dir (".", expression, makes);
|
|---|
| 2119 |
|
|---|
| 2120 | if (makes.size () > 0)
|
|---|
| 2121 | {
|
|---|
| 2122 | cout << "Removing all previous make fragments from " << branch << endl;
|
|---|
| 2123 |
|
|---|
| 2124 | for (int i = 0; i < makes.size (); i++)
|
|---|
| 2125 | {
|
|---|
| 2126 | const cmt_string& s = makes[i];
|
|---|
| 2127 | CmtSystem::remove_file (s);
|
|---|
| 2128 | }
|
|---|
| 2129 | }
|
|---|
| 2130 |
|
|---|
| 2131 | CmtSystem::cd ("..");
|
|---|
| 2132 |
|
|---|
| 2133 | CmtSystem::scan_dir (m_cmt_config, expression, makes);
|
|---|
| 2134 |
|
|---|
| 2135 | if (makes.size () > 0)
|
|---|
| 2136 | {
|
|---|
| 2137 | cout << "Removing all previous make fragments from "
|
|---|
| 2138 | << m_cmt_config << endl;
|
|---|
| 2139 |
|
|---|
| 2140 | for (int i = 0; i < makes.size (); i++)
|
|---|
| 2141 | {
|
|---|
| 2142 | const cmt_string& s = makes[i];
|
|---|
| 2143 | CmtSystem::remove_file (s);
|
|---|
| 2144 | }
|
|---|
| 2145 | }
|
|---|
| 2146 |
|
|---|
| 2147 | /*
|
|---|
| 2148 | // cout << "Try a cleanup of the installation area " << endl;
|
|---|
| 2149 |
|
|---|
| 2150 | //
|
|---|
| 2151 | // Try a cleanup of the installation area
|
|---|
| 2152 | //
|
|---|
| 2153 | if ((get_build_strategy () & InstallAreaMask) == WithInstallArea)
|
|---|
| 2154 | {
|
|---|
| 2155 | CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
|
|---|
| 2156 |
|
|---|
| 2157 | //cout << "#IA3>" << endl;
|
|---|
| 2158 |
|
|---|
| 2159 | if ((get_setup_strategy () & SetupCleanupMask) == SetupCleanup)
|
|---|
| 2160 | {
|
|---|
| 2161 | ia_mgr.config ();
|
|---|
| 2162 | }
|
|---|
| 2163 | }
|
|---|
| 2164 | */
|
|---|
| 2165 |
|
|---|
| 2166 | CmtSystem::cd (branch);
|
|---|
| 2167 |
|
|---|
| 2168 | Use& use = Use::current ();
|
|---|
| 2169 |
|
|---|
| 2170 | use.set (m_current_package,
|
|---|
| 2171 | m_current_version,
|
|---|
| 2172 | m_current_path,
|
|---|
| 2173 | "",
|
|---|
| 2174 | "");
|
|---|
| 2175 |
|
|---|
| 2176 | use.change_path (m_current_path);
|
|---|
| 2177 | use.style = m_current_style;
|
|---|
| 2178 |
|
|---|
| 2179 | //cout << "do_config> current style=" << m_current_style << endl;
|
|---|
| 2180 |
|
|---|
| 2181 | m_quiet = true;
|
|---|
| 2182 |
|
|---|
| 2183 | if (!reach_current_package ())
|
|---|
| 2184 | {
|
|---|
| 2185 | cout << "Cannot read the requirements file" << endl;
|
|---|
| 2186 | return;
|
|---|
| 2187 | }
|
|---|
| 2188 |
|
|---|
| 2189 | install_setup_scripts ();
|
|---|
| 2190 | install_cleanup_scripts ();
|
|---|
| 2191 |
|
|---|
| 2192 | CmtSystem::cd ("..");
|
|---|
| 2193 |
|
|---|
| 2194 | Branch::BranchVector& branches = Branch::branches ();
|
|---|
| 2195 |
|
|---|
| 2196 | int i;
|
|---|
| 2197 |
|
|---|
| 2198 | for (i = 0; i < branches.size (); i++)
|
|---|
| 2199 | {
|
|---|
| 2200 | const Branch& branch = branches[i];
|
|---|
| 2201 | const cmt_string& branch_name = branch.name ();
|
|---|
| 2202 |
|
|---|
| 2203 | if (!CmtSystem::test_directory (branch_name))
|
|---|
| 2204 | {
|
|---|
| 2205 | if (!CmtSystem::mkdir (branch_name))
|
|---|
| 2206 | {
|
|---|
| 2207 | cout << "Cannot create the " << branch_name <<" branch" << endl;
|
|---|
| 2208 | }
|
|---|
| 2209 | else
|
|---|
| 2210 | {
|
|---|
| 2211 | cout << "Installing the " << branch_name << " directory" << endl;
|
|---|
| 2212 | }
|
|---|
| 2213 | }
|
|---|
| 2214 | else
|
|---|
| 2215 | {
|
|---|
| 2216 | cout << branch_name << " directory already installed" << endl;
|
|---|
| 2217 | }
|
|---|
| 2218 | }
|
|---|
| 2219 | }
|
|---|
| 2220 |
|
|---|
| 2221 | //----------------------------------------------------------
|
|---|
| 2222 | void Cmt::do_create (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2223 | {
|
|---|
| 2224 | if (arguments.size () < 2) return;
|
|---|
| 2225 |
|
|---|
| 2226 | const cmt_string& package = arguments[0];
|
|---|
| 2227 | const cmt_string& version = arguments[1];
|
|---|
| 2228 | cmt_string offset;
|
|---|
| 2229 | if (arguments.size () >= 3) offset = arguments[2];
|
|---|
| 2230 |
|
|---|
| 2231 | if (m_debug)
|
|---|
| 2232 | {
|
|---|
| 2233 | cout << "do_create>m_current_package=" << m_current_package << endl;
|
|---|
| 2234 | cout << "do_create>package=" << package << endl;
|
|---|
| 2235 | }
|
|---|
| 2236 |
|
|---|
| 2237 | //if (m_current_package == "CMT") return;
|
|---|
| 2238 | //if (m_current_package == "methods") return;
|
|---|
| 2239 |
|
|---|
| 2240 | cmt_string the_path;
|
|---|
| 2241 |
|
|---|
| 2242 | the_path = CmtSystem::pwd ();
|
|---|
| 2243 |
|
|---|
| 2244 | if (offset != "")
|
|---|
| 2245 | {
|
|---|
| 2246 | if (!CmtSystem::absolute_path (offset))
|
|---|
| 2247 | {
|
|---|
| 2248 | // offset is really a relative offset
|
|---|
| 2249 | the_path += CmtSystem::file_separator ();
|
|---|
| 2250 | the_path += offset;
|
|---|
| 2251 | }
|
|---|
| 2252 | else // absolute path
|
|---|
| 2253 | {
|
|---|
| 2254 | the_path = offset;
|
|---|
| 2255 | }
|
|---|
| 2256 | }
|
|---|
| 2257 |
|
|---|
| 2258 | CmtSystem::compress_path (the_path);
|
|---|
| 2259 |
|
|---|
| 2260 | // Now 'the_path' contains the complete path where the package will be created
|
|---|
| 2261 |
|
|---|
| 2262 | cout << "------------------------------------------" << endl;
|
|---|
| 2263 | cout << "Configuring environment for package " << package <<
|
|---|
| 2264 | " version " << version << "." << endl;
|
|---|
| 2265 | cout << "CMT version " << m_cmt_version << "." << endl;
|
|---|
| 2266 | cout << "Root set to " << the_path << "." << endl;
|
|---|
| 2267 | cout << "System is " << m_cmt_config << endl;
|
|---|
| 2268 | cout << "------------------------------------------" << endl;
|
|---|
| 2269 |
|
|---|
| 2270 | if (!CmtSystem::test_directory (the_path))
|
|---|
| 2271 | {
|
|---|
| 2272 | if (!CmtSystem::mkdir (the_path))
|
|---|
| 2273 | {
|
|---|
| 2274 | cout << "Cannot create the path directory" << endl;
|
|---|
| 2275 | return;
|
|---|
| 2276 | }
|
|---|
| 2277 | else
|
|---|
| 2278 | {
|
|---|
| 2279 | cout << "Installing the path directory" << endl;
|
|---|
| 2280 | }
|
|---|
| 2281 | }
|
|---|
| 2282 |
|
|---|
| 2283 | CmtSystem::cd (the_path);
|
|---|
| 2284 |
|
|---|
| 2285 | if (!CmtSystem::test_directory (package))
|
|---|
| 2286 | {
|
|---|
| 2287 | if (!CmtSystem::mkdir (package))
|
|---|
| 2288 | {
|
|---|
| 2289 | cout << "Cannot create the package directory" << endl;
|
|---|
| 2290 | return;
|
|---|
| 2291 | }
|
|---|
| 2292 | else
|
|---|
| 2293 | {
|
|---|
| 2294 | cout << "Installing the package directory" << endl;
|
|---|
| 2295 | }
|
|---|
| 2296 | }
|
|---|
| 2297 | else
|
|---|
| 2298 | {
|
|---|
| 2299 | cout << "Package directory already installed" << endl;
|
|---|
| 2300 | }
|
|---|
| 2301 |
|
|---|
| 2302 | CmtSystem::cd (package);
|
|---|
| 2303 |
|
|---|
| 2304 | if (m_current_structuring_style == with_version_directory)
|
|---|
| 2305 | {
|
|---|
| 2306 | if (!CmtSystem::test_directory (version))
|
|---|
| 2307 | {
|
|---|
| 2308 | if (!CmtSystem::mkdir (version))
|
|---|
| 2309 | {
|
|---|
| 2310 | cout << "Cannot create the version directory" << endl;
|
|---|
| 2311 | return;
|
|---|
| 2312 | }
|
|---|
| 2313 | else
|
|---|
| 2314 | {
|
|---|
| 2315 | cout << "Installing the version directory" << endl;
|
|---|
| 2316 | }
|
|---|
| 2317 | }
|
|---|
| 2318 | else
|
|---|
| 2319 | {
|
|---|
| 2320 | cout << "Version directory already installed" << endl;
|
|---|
| 2321 | }
|
|---|
| 2322 |
|
|---|
| 2323 | CmtSystem::cd (version);
|
|---|
| 2324 | }
|
|---|
| 2325 | else
|
|---|
| 2326 | {
|
|---|
| 2327 | cout << "Version directory will not be created due to structuring style" << endl;
|
|---|
| 2328 | }
|
|---|
| 2329 |
|
|---|
| 2330 | if (!CmtSystem::test_directory ("cmt"))
|
|---|
| 2331 | {
|
|---|
| 2332 | if (!CmtSystem::test_directory ("mgr"))
|
|---|
| 2333 | {
|
|---|
| 2334 | if (!CmtSystem::mkdir ("cmt"))
|
|---|
| 2335 | {
|
|---|
| 2336 | cout << "Cannot create the cmt directory" << endl;
|
|---|
| 2337 | return;
|
|---|
| 2338 | }
|
|---|
| 2339 | else
|
|---|
| 2340 | {
|
|---|
| 2341 | if (m_current_structuring_style == with_version_directory)
|
|---|
| 2342 | {
|
|---|
| 2343 | m_current_style = cmt_style;
|
|---|
| 2344 | }
|
|---|
| 2345 | else
|
|---|
| 2346 | {
|
|---|
| 2347 | m_current_style = no_version_style;
|
|---|
| 2348 | }
|
|---|
| 2349 |
|
|---|
| 2350 | cout << "Installing the cmt directory" << endl;
|
|---|
| 2351 | }
|
|---|
| 2352 | }
|
|---|
| 2353 | else
|
|---|
| 2354 | {
|
|---|
| 2355 | if (m_current_structuring_style == with_version_directory)
|
|---|
| 2356 | {
|
|---|
| 2357 | m_current_style = mgr_style;
|
|---|
| 2358 | }
|
|---|
| 2359 | else
|
|---|
| 2360 | {
|
|---|
| 2361 | m_current_style = no_version_style;
|
|---|
| 2362 | }
|
|---|
| 2363 |
|
|---|
| 2364 | cout << "Mgr directory already installed" << endl;
|
|---|
| 2365 | }
|
|---|
| 2366 | }
|
|---|
| 2367 | else
|
|---|
| 2368 | {
|
|---|
| 2369 | if (m_current_structuring_style == with_version_directory)
|
|---|
| 2370 | {
|
|---|
| 2371 | m_current_style = cmt_style;
|
|---|
| 2372 | }
|
|---|
| 2373 | else
|
|---|
| 2374 | {
|
|---|
| 2375 | m_current_style = no_version_style;
|
|---|
| 2376 | }
|
|---|
| 2377 |
|
|---|
| 2378 | cout << "Cmt directory already installed" << endl;
|
|---|
| 2379 | }
|
|---|
| 2380 |
|
|---|
| 2381 | if (!CmtSystem::test_directory ("src"))
|
|---|
| 2382 | {
|
|---|
| 2383 | if (!CmtSystem::mkdir ("src"))
|
|---|
| 2384 | {
|
|---|
| 2385 | cout << "Cannot create the src directory" << endl;
|
|---|
| 2386 | return;
|
|---|
| 2387 | }
|
|---|
| 2388 | else
|
|---|
| 2389 | {
|
|---|
| 2390 | cout << "Installing the src directory" << endl;
|
|---|
| 2391 | }
|
|---|
| 2392 | }
|
|---|
| 2393 | else
|
|---|
| 2394 | {
|
|---|
| 2395 | cout << "src directory already installed" << endl;
|
|---|
| 2396 | }
|
|---|
| 2397 |
|
|---|
| 2398 | switch (m_current_style)
|
|---|
| 2399 | {
|
|---|
| 2400 | case cmt_style:
|
|---|
| 2401 | case no_version_style:
|
|---|
| 2402 | CmtSystem::cd ("cmt");
|
|---|
| 2403 | break;
|
|---|
| 2404 | case mgr_style:
|
|---|
| 2405 | CmtSystem::cd ("mgr");
|
|---|
| 2406 | break;
|
|---|
| 2407 | }
|
|---|
| 2408 |
|
|---|
| 2409 | Generator::build_default_makefile ();
|
|---|
| 2410 |
|
|---|
| 2411 | if (!CmtSystem::test_file ("requirements"))
|
|---|
| 2412 | {
|
|---|
| 2413 | // create an empty requirement file.
|
|---|
| 2414 | ofstream f ("requirements");
|
|---|
| 2415 | if (f)
|
|---|
| 2416 | {
|
|---|
| 2417 | f << "package " << package << endl;
|
|---|
| 2418 | f << endl;
|
|---|
| 2419 | f.close ();
|
|---|
| 2420 | }
|
|---|
| 2421 | }
|
|---|
| 2422 |
|
|---|
| 2423 | if (m_current_structuring_style == without_version_directory)
|
|---|
| 2424 | {
|
|---|
| 2425 | ofstream f ("version.cmt");
|
|---|
| 2426 | if (f)
|
|---|
| 2427 | {
|
|---|
| 2428 | f << version << endl;
|
|---|
| 2429 | f.close ();
|
|---|
| 2430 | }
|
|---|
| 2431 | }
|
|---|
| 2432 |
|
|---|
| 2433 | m_current_package = package;
|
|---|
| 2434 | m_current_version = version;
|
|---|
| 2435 | m_current_path = the_path;
|
|---|
| 2436 | m_current_dir = CmtSystem::pwd ();
|
|---|
| 2437 |
|
|---|
| 2438 | do_config ();
|
|---|
| 2439 | }
|
|---|
| 2440 |
|
|---|
| 2441 | //----------------------------------------------------------
|
|---|
| 2442 | void Cmt::do_create_project (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2443 | {
|
|---|
| 2444 | if (arguments.size () < 1) return;
|
|---|
| 2445 |
|
|---|
| 2446 | const cmt_string& project = arguments[0];
|
|---|
| 2447 |
|
|---|
| 2448 | Project::create (project);
|
|---|
| 2449 | }
|
|---|
| 2450 |
|
|---|
| 2451 | //----------------------------------------------------------
|
|---|
| 2452 | void Cmt::do_cvsbranches (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2453 | {
|
|---|
| 2454 | Cvs::branches (arguments[0]);
|
|---|
| 2455 | }
|
|---|
| 2456 |
|
|---|
| 2457 | //----------------------------------------------------------
|
|---|
| 2458 | void Cmt::do_cvssubpackages (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2459 | {
|
|---|
| 2460 | Cvs::subpackages (arguments[0]);
|
|---|
| 2461 | }
|
|---|
| 2462 |
|
|---|
| 2463 | //----------------------------------------------------------
|
|---|
| 2464 | void Cmt::do_cvstags (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2465 | {
|
|---|
| 2466 | Cvs::tags (arguments);
|
|---|
| 2467 | }
|
|---|
| 2468 |
|
|---|
| 2469 | //----------------------------------------------------------
|
|---|
| 2470 | void Cmt::do_do (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2471 | {
|
|---|
| 2472 | if (arguments.size () > 0)
|
|---|
| 2473 | {
|
|---|
| 2474 | set_standard_macros ();
|
|---|
| 2475 | Symbol::all_set ();
|
|---|
| 2476 |
|
|---|
| 2477 | Symbol* symbol = Symbol::find (arguments[0]);
|
|---|
| 2478 |
|
|---|
| 2479 | if (symbol == 0)
|
|---|
| 2480 | {
|
|---|
| 2481 | CmtError::set (CmtError::symbol_not_found, arguments[0]);
|
|---|
| 2482 | return;
|
|---|
| 2483 | }
|
|---|
| 2484 |
|
|---|
| 2485 | /*
|
|---|
| 2486 | We then look for all <name>=<value> pairs
|
|---|
| 2487 | */
|
|---|
| 2488 | for (int i = 1; i < arguments.size (); i++)
|
|---|
| 2489 | {
|
|---|
| 2490 | cmt_string s = arguments[i];
|
|---|
| 2491 | int pos = s.find ("=");
|
|---|
| 2492 | if (pos == cmt_string::npos) break;
|
|---|
| 2493 | if (pos == 0) break;
|
|---|
| 2494 |
|
|---|
| 2495 | cmt_string name;
|
|---|
| 2496 | cmt_string value;
|
|---|
| 2497 |
|
|---|
| 2498 | s.substr (0, pos, name);
|
|---|
| 2499 | s.substr (pos + 1, value);
|
|---|
| 2500 |
|
|---|
| 2501 | int size = value.size ();
|
|---|
| 2502 |
|
|---|
| 2503 | if (size >= 2)
|
|---|
| 2504 | {
|
|---|
| 2505 | if (((value[0] == '"') && (value[size - 1] == '"')) ||
|
|---|
| 2506 | ((value[0] == '\'') && (value[size - 1] == '\'')))
|
|---|
| 2507 | {
|
|---|
| 2508 | value.erase (size - 1);
|
|---|
| 2509 | value.erase (0, 1);
|
|---|
| 2510 | }
|
|---|
| 2511 | }
|
|---|
| 2512 |
|
|---|
| 2513 | cmt_string r = "macro ";
|
|---|
| 2514 | r += name;
|
|---|
| 2515 | r += " \"";
|
|---|
| 2516 | r += value;
|
|---|
| 2517 | r += "\"";
|
|---|
| 2518 |
|
|---|
| 2519 | Use* current_use = &(Use::current ());
|
|---|
| 2520 |
|
|---|
| 2521 | SyntaxParser::parse_requirements_line (r, current_use);
|
|---|
| 2522 | }
|
|---|
| 2523 |
|
|---|
| 2524 | cmt_string cmd = symbol->build_macro_value ();
|
|---|
| 2525 | Symbol::expand (cmd);
|
|---|
| 2526 |
|
|---|
| 2527 | cout << "Execute action " << arguments[0] << " => " << cmd << endl;
|
|---|
| 2528 |
|
|---|
| 2529 | CmtSystem::execute (cmd);
|
|---|
| 2530 | }
|
|---|
| 2531 | }
|
|---|
| 2532 |
|
|---|
| 2533 | //----------------------------------------------------------
|
|---|
| 2534 | void Cmt::do_expand_model (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2535 | {
|
|---|
| 2536 | set_standard_macros ();
|
|---|
| 2537 |
|
|---|
| 2538 | if ((arguments[0] == "-strict") && (arguments.size () > 1))
|
|---|
| 2539 | {
|
|---|
| 2540 | CmtModel::strict_expand (arguments[1]);
|
|---|
| 2541 | }
|
|---|
| 2542 | else if ((arguments[0] == "-test") && (arguments.size () > 2))
|
|---|
| 2543 | {
|
|---|
| 2544 | CmtModel::test_regexp (arguments[1], arguments[2]);
|
|---|
| 2545 | }
|
|---|
| 2546 | else if (arguments.size () > 0)
|
|---|
| 2547 | {
|
|---|
| 2548 | CmtModel::expand (arguments[0]);
|
|---|
| 2549 | }
|
|---|
| 2550 | }
|
|---|
| 2551 |
|
|---|
| 2552 | /**
|
|---|
| 2553 | * Handle free filtering of text files containing $(xxx) or ${xxx} patterns
|
|---|
| 2554 | *
|
|---|
| 2555 | * Substitution is performed against CMT macros and environment variables.
|
|---|
| 2556 | *
|
|---|
| 2557 | * Arguments:
|
|---|
| 2558 | *
|
|---|
| 2559 | * cmt filter input-file-name output-file-name
|
|---|
| 2560 | *
|
|---|
| 2561 | */
|
|---|
| 2562 | void Cmt::do_filter (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2563 | {
|
|---|
| 2564 | if (arguments.size () < 2) return;
|
|---|
| 2565 |
|
|---|
| 2566 | cmt_string& input = arguments[0];
|
|---|
| 2567 | cmt_string& output = arguments[1];
|
|---|
| 2568 |
|
|---|
| 2569 | if (!CmtSystem::test_file (input))
|
|---|
| 2570 | {
|
|---|
| 2571 | cerr << "#CMT> File " << input << " not found" << endl;
|
|---|
| 2572 | return;
|
|---|
| 2573 | }
|
|---|
| 2574 |
|
|---|
| 2575 | cmt_string text;
|
|---|
| 2576 |
|
|---|
| 2577 | text.read (input);
|
|---|
| 2578 |
|
|---|
| 2579 | set_standard_macros ();
|
|---|
| 2580 |
|
|---|
| 2581 | Symbol::expand (text);
|
|---|
| 2582 |
|
|---|
| 2583 | FILE* file = fopen (output, "wb");
|
|---|
| 2584 | if (file == NULL)
|
|---|
| 2585 | {
|
|---|
| 2586 | cerr << "#CMT> Cannot write filtered file " << output << endl;
|
|---|
| 2587 | }
|
|---|
| 2588 | else
|
|---|
| 2589 | {
|
|---|
| 2590 | text.write (file);
|
|---|
| 2591 | fclose (file);
|
|---|
| 2592 | }
|
|---|
| 2593 | }
|
|---|
| 2594 |
|
|---|
| 2595 | //----------------------------------------------------------
|
|---|
| 2596 | void Cmt::do_help (ActionType help_action)
|
|---|
| 2597 | {
|
|---|
| 2598 | if (help_action == action_none)
|
|---|
| 2599 | {
|
|---|
| 2600 | CommandParser::show_all ();
|
|---|
| 2601 | }
|
|---|
| 2602 | else
|
|---|
| 2603 | {
|
|---|
| 2604 | CommandParser::show (help_action);
|
|---|
| 2605 | }
|
|---|
| 2606 | }
|
|---|
| 2607 |
|
|---|
| 2608 | //----------------------------------------------------------
|
|---|
| 2609 | void Cmt::do_lock (const cmt_string& package,
|
|---|
| 2610 | const cmt_string& version,
|
|---|
| 2611 | const cmt_string& path)
|
|---|
| 2612 | {
|
|---|
| 2613 | //(unsused) Use& use = Use::current();
|
|---|
| 2614 |
|
|---|
| 2615 | cout << "try to lock package " << package << " in " << CmtSystem::pwd () << endl;
|
|---|
| 2616 |
|
|---|
| 2617 | set_standard_macros ();
|
|---|
| 2618 |
|
|---|
| 2619 | CmtLock::status status = CmtLock::lock ();
|
|---|
| 2620 | }
|
|---|
| 2621 |
|
|---|
| 2622 | //----------------------------------------------------------
|
|---|
| 2623 | void Cmt::do_remove (const cmt_string& package,
|
|---|
| 2624 | const cmt_string& version,
|
|---|
| 2625 | const cmt_string& path)
|
|---|
| 2626 | {
|
|---|
| 2627 | //Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 2628 |
|
|---|
| 2629 | if (m_current_package == "CMT") return;
|
|---|
| 2630 | if (m_current_package == "methods") return;
|
|---|
| 2631 |
|
|---|
| 2632 | cmt_string the_path;
|
|---|
| 2633 |
|
|---|
| 2634 | //the_path = m_default_path;
|
|---|
| 2635 | the_path = CmtSystem::pwd ();
|
|---|
| 2636 |
|
|---|
| 2637 | if (path != "")
|
|---|
| 2638 | {
|
|---|
| 2639 | if (!CmtSystem::absolute_path (path))
|
|---|
| 2640 | {
|
|---|
| 2641 | // path is just a suffix
|
|---|
| 2642 | the_path += CmtSystem::file_separator ();
|
|---|
| 2643 | the_path += path;
|
|---|
| 2644 | }
|
|---|
| 2645 | else // absolute path
|
|---|
| 2646 | {
|
|---|
| 2647 | the_path = path;
|
|---|
| 2648 | }
|
|---|
| 2649 | }
|
|---|
| 2650 |
|
|---|
| 2651 | CmtSystem::compress_path (the_path);
|
|---|
| 2652 |
|
|---|
| 2653 | cout << "------------------------------------------" << endl;
|
|---|
| 2654 | cout << "Removing package " << package <<
|
|---|
| 2655 | " version " << version << "." << endl;
|
|---|
| 2656 | cout << "CMT version " << m_cmt_version << "." << endl;
|
|---|
| 2657 | cout << "Root set to " << the_path << "." << endl;
|
|---|
| 2658 | cout << "System is " << m_cmt_config << endl;
|
|---|
| 2659 | cout << "------------------------------------------" << endl;
|
|---|
| 2660 |
|
|---|
| 2661 | the_path += CmtSystem::file_separator ();
|
|---|
| 2662 | the_path += package;
|
|---|
| 2663 |
|
|---|
| 2664 | if (!CmtSystem::cd (the_path))
|
|---|
| 2665 | {
|
|---|
| 2666 | cout << "Path " << the_path << " not reachable" << endl;
|
|---|
| 2667 | return;
|
|---|
| 2668 | }
|
|---|
| 2669 |
|
|---|
| 2670 | if (CmtSystem::test_directory (version))
|
|---|
| 2671 | {
|
|---|
| 2672 | if (CmtSystem::remove_directory (version))
|
|---|
| 2673 | {
|
|---|
| 2674 | cout << "Version " << version << " has been removed from " << the_path << endl;
|
|---|
| 2675 | CmtSystem::cmt_string_vector contents;
|
|---|
| 2676 | CmtSystem::scan_dir (".", contents);
|
|---|
| 2677 | if (contents.size () == 0)
|
|---|
| 2678 | {
|
|---|
| 2679 | CmtSystem::cd ("..");
|
|---|
| 2680 | if (CmtSystem::remove_directory (package))
|
|---|
| 2681 | {
|
|---|
| 2682 | cout << "Package " << package << " has no more versions. Thus it has been removed."<< endl;
|
|---|
| 2683 | }
|
|---|
| 2684 | }
|
|---|
| 2685 | }
|
|---|
| 2686 | else
|
|---|
| 2687 | {
|
|---|
| 2688 | cout << "Impossible to remove version " << version << " from " << the_path << endl;
|
|---|
| 2689 | }
|
|---|
| 2690 | }
|
|---|
| 2691 | else if (CmtSystem::test_directory ("cmt"))
|
|---|
| 2692 | {
|
|---|
| 2693 | CmtSystem::cd ("cmt");
|
|---|
| 2694 |
|
|---|
| 2695 | cmt_string v;
|
|---|
| 2696 |
|
|---|
| 2697 | v.read ("version.cmt");
|
|---|
| 2698 | if (v == version)
|
|---|
| 2699 | {
|
|---|
| 2700 | CmtSystem::cd ("..");
|
|---|
| 2701 | if (!CmtSystem::remove_directory ("cmt"))
|
|---|
| 2702 | {
|
|---|
| 2703 | cout << "Unstructured version " << version
|
|---|
| 2704 | << " has been removed from " << the_path << endl;
|
|---|
| 2705 | }
|
|---|
| 2706 | else
|
|---|
| 2707 | {
|
|---|
| 2708 | cout << "Impossible to remove unstructured version " << version
|
|---|
| 2709 | << " from " << the_path << endl;
|
|---|
| 2710 | }
|
|---|
| 2711 | }
|
|---|
| 2712 | else
|
|---|
| 2713 | {
|
|---|
| 2714 | cout << "Version " << version << " not found" << endl;
|
|---|
| 2715 | }
|
|---|
| 2716 | }
|
|---|
| 2717 | else
|
|---|
| 2718 | {
|
|---|
| 2719 | cout << "Version " << version << " not found" << endl;
|
|---|
| 2720 | }
|
|---|
| 2721 | }
|
|---|
| 2722 |
|
|---|
| 2723 | //----------------------------------------------------------
|
|---|
| 2724 | void Cmt::do_remove_library_links ()
|
|---|
| 2725 | {
|
|---|
| 2726 | if (CmtLock::check () == CmtLock::locked_by_another_user)
|
|---|
| 2727 | {
|
|---|
| 2728 | CmtError::set (CmtError::conflicting_lock, "remove_library_links>");
|
|---|
| 2729 | return;
|
|---|
| 2730 | }
|
|---|
| 2731 |
|
|---|
| 2732 | set_standard_macros ();
|
|---|
| 2733 |
|
|---|
| 2734 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 2735 | Use& current_use = Use::current ();
|
|---|
| 2736 | int i;
|
|---|
| 2737 | cmt_string shlibsuffix;
|
|---|
| 2738 | cmt_string symunlink;
|
|---|
| 2739 |
|
|---|
| 2740 | {
|
|---|
| 2741 | Symbol* macro = Symbol::find ("shlibsuffix");
|
|---|
| 2742 | if (macro == 0) return;
|
|---|
| 2743 | shlibsuffix = macro->build_macro_value ();
|
|---|
| 2744 | Symbol::expand (shlibsuffix);
|
|---|
| 2745 | }
|
|---|
| 2746 |
|
|---|
| 2747 | {
|
|---|
| 2748 | Symbol* macro = Symbol::find ("symunlink");
|
|---|
| 2749 | if (macro == 0) return;
|
|---|
| 2750 | symunlink = macro->build_macro_value ();
|
|---|
| 2751 | Symbol::expand (symunlink);
|
|---|
| 2752 | }
|
|---|
| 2753 |
|
|---|
| 2754 | for (i = 0; i < Uses.size (); i++)
|
|---|
| 2755 | {
|
|---|
| 2756 | Use* use = Uses[i];
|
|---|
| 2757 |
|
|---|
| 2758 | if (use->discarded) continue;
|
|---|
| 2759 |
|
|---|
| 2760 | if (!use->located ())
|
|---|
| 2761 | {
|
|---|
| 2762 | if (!m_quiet)
|
|---|
| 2763 | {
|
|---|
| 2764 | cerr << "#CMT> package " << use->get_package_name () <<
|
|---|
| 2765 | " " << use->version << " " << use->path <<
|
|---|
| 2766 | " not found" <<
|
|---|
| 2767 | endl;
|
|---|
| 2768 | }
|
|---|
| 2769 | }
|
|---|
| 2770 | else
|
|---|
| 2771 | {
|
|---|
| 2772 | if (use->get_package_name () == "CMT") continue;
|
|---|
| 2773 | if (use->get_package_name () == current_use.get_package_name ()) continue;
|
|---|
| 2774 |
|
|---|
| 2775 | cmt_string s;
|
|---|
| 2776 |
|
|---|
| 2777 | s = use->get_package_name ();
|
|---|
| 2778 | s += "_libraries";
|
|---|
| 2779 |
|
|---|
| 2780 | Symbol* libraries_macro = Symbol::find (s);
|
|---|
| 2781 |
|
|---|
| 2782 | if (libraries_macro == 0) continue;
|
|---|
| 2783 |
|
|---|
| 2784 | cmt_string libraries = libraries_macro->build_macro_value ();
|
|---|
| 2785 | Symbol::expand (libraries);
|
|---|
| 2786 |
|
|---|
| 2787 | static CmtSystem::cmt_string_vector values;
|
|---|
| 2788 |
|
|---|
| 2789 | CmtSystem::split (libraries, " \t", values);
|
|---|
| 2790 |
|
|---|
| 2791 | for (int j = 0; j < values.size (); j++)
|
|---|
| 2792 | {
|
|---|
| 2793 | const cmt_string& library = values[j];
|
|---|
| 2794 |
|
|---|
| 2795 | static cmt_string libname;
|
|---|
| 2796 | static cmt_string name;
|
|---|
| 2797 |
|
|---|
| 2798 | // Is it a simple name or a complete path?
|
|---|
| 2799 |
|
|---|
| 2800 | libname = library;
|
|---|
| 2801 | Symbol::expand (libname);
|
|---|
| 2802 |
|
|---|
| 2803 | if (CmtSystem::absolute_path (libname))
|
|---|
| 2804 | {
|
|---|
| 2805 | /**
|
|---|
| 2806 | * We assume here that "library" contains a complete path.
|
|---|
| 2807 | * (including the complete syntax libxxx.so)
|
|---|
| 2808 | */
|
|---|
| 2809 |
|
|---|
| 2810 | cmt_string suffix;
|
|---|
| 2811 | CmtSystem::basename (library, name);
|
|---|
| 2812 | }
|
|---|
| 2813 | else
|
|---|
| 2814 | {
|
|---|
| 2815 | /**
|
|---|
| 2816 | * Here we expect that only the base name of the library
|
|---|
| 2817 | * is given : ie it should not contain the "lib" prefix,
|
|---|
| 2818 | * nor the suffix .so, nor any path prefix.
|
|---|
| 2819 | * This of course should generally correspond to a constituent name.
|
|---|
| 2820 | */
|
|---|
| 2821 |
|
|---|
| 2822 | name = "lib";
|
|---|
| 2823 | name += libname;
|
|---|
| 2824 | name += ".";
|
|---|
| 2825 | name += shlibsuffix;
|
|---|
| 2826 | }
|
|---|
| 2827 |
|
|---|
| 2828 | Symbol::expand (libname);
|
|---|
| 2829 |
|
|---|
| 2830 | if ((get_build_strategy () & InstallAreaMask) == WithInstallArea)
|
|---|
| 2831 | {
|
|---|
| 2832 | const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
|
|---|
| 2833 |
|
|---|
| 2834 | //cout << "#IA4>" << endl;
|
|---|
| 2835 |
|
|---|
| 2836 | cmt_string s1 = ia_mgr.get_installarea ();
|
|---|
| 2837 |
|
|---|
| 2838 | {
|
|---|
| 2839 | Symbol* symbol = Symbol::find ("CMTINSTALLAREA");
|
|---|
| 2840 | if (symbol != 0)
|
|---|
| 2841 | {
|
|---|
| 2842 | s1 = symbol->build_macro_value ();
|
|---|
| 2843 | Symbol::expand (s1);
|
|---|
| 2844 | }
|
|---|
| 2845 | }
|
|---|
| 2846 |
|
|---|
| 2847 | cmt_string s2;
|
|---|
| 2848 |
|
|---|
| 2849 | {
|
|---|
| 2850 | Symbol* macro = Symbol::find ("tag");
|
|---|
| 2851 | if (macro != 0)
|
|---|
| 2852 | {
|
|---|
| 2853 | s2 = macro->build_macro_value ();
|
|---|
| 2854 | Symbol::expand (s2);
|
|---|
| 2855 | }
|
|---|
| 2856 | }
|
|---|
| 2857 |
|
|---|
| 2858 | // Now deleting the reference file
|
|---|
| 2859 |
|
|---|
| 2860 | s = symunlink;
|
|---|
| 2861 | s += " ";
|
|---|
| 2862 | s += s1;
|
|---|
| 2863 | s += CmtSystem::file_separator ();
|
|---|
| 2864 | s += s2;
|
|---|
| 2865 | s += CmtSystem::file_separator ();
|
|---|
| 2866 | s += "lib";
|
|---|
| 2867 | s += CmtSystem::file_separator ();
|
|---|
| 2868 | s += name;
|
|---|
| 2869 | s += ".cmtref";
|
|---|
| 2870 | s += " ";
|
|---|
| 2871 | s += s1;
|
|---|
| 2872 | s += CmtSystem::file_separator ();
|
|---|
| 2873 | s += s2;
|
|---|
| 2874 | s += CmtSystem::file_separator ();
|
|---|
| 2875 | s += "lib";
|
|---|
| 2876 | s += CmtSystem::file_separator ();
|
|---|
| 2877 | s += name;
|
|---|
| 2878 | }
|
|---|
| 2879 | else
|
|---|
| 2880 | {
|
|---|
| 2881 | s = symunlink;
|
|---|
| 2882 | s += " ../$(";
|
|---|
| 2883 | s += current_use.get_package_name ();
|
|---|
| 2884 | s += "_tag)/";
|
|---|
| 2885 | s += name;
|
|---|
| 2886 | }
|
|---|
| 2887 |
|
|---|
| 2888 | Symbol::expand (s);
|
|---|
| 2889 |
|
|---|
| 2890 | if (!m_quiet) cout << s << endl;
|
|---|
| 2891 | int status = CmtSystem::execute (s);
|
|---|
| 2892 |
|
|---|
| 2893 | if (status != 0)
|
|---|
| 2894 | {
|
|---|
| 2895 | if (status != 2) CmtError::set (CmtError::execution_error, s);
|
|---|
| 2896 |
|
|---|
| 2897 | cerr << "#CMT> Cannot remove the symbolic link " << s << endl;
|
|---|
| 2898 |
|
|---|
| 2899 | break;
|
|---|
| 2900 | }
|
|---|
| 2901 | }
|
|---|
| 2902 | }
|
|---|
| 2903 | }
|
|---|
| 2904 | }
|
|---|
| 2905 |
|
|---|
| 2906 | //----------------------------------------------------------
|
|---|
| 2907 | void Cmt::do_run (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2908 | {
|
|---|
| 2909 | if (arguments.size () > 0)
|
|---|
| 2910 | {
|
|---|
| 2911 | set_standard_macros ();
|
|---|
| 2912 | Symbol::all_set ();
|
|---|
| 2913 |
|
|---|
| 2914 | cmt_string cmd;
|
|---|
| 2915 |
|
|---|
| 2916 | for (int i = 0; i < arguments.size (); i++)
|
|---|
| 2917 | {
|
|---|
| 2918 | cmd += arguments[i];
|
|---|
| 2919 | cmd += " ";
|
|---|
| 2920 | }
|
|---|
| 2921 |
|
|---|
| 2922 | CmtSystem::execute (cmd);
|
|---|
| 2923 | }
|
|---|
| 2924 | }
|
|---|
| 2925 |
|
|---|
| 2926 | //----------------------------------------------------------
|
|---|
| 2927 | void Cmt::do_run_sequence (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2928 | {
|
|---|
| 2929 | if (arguments.size () == 0) cerr << "#CMT> run_sequence: no sequence specified" << endl;
|
|---|
| 2930 |
|
|---|
| 2931 | SequenceRunner runner;
|
|---|
| 2932 |
|
|---|
| 2933 | cout << "# cmt run_sequence: sequence " << arguments[0] << endl;
|
|---|
| 2934 |
|
|---|
| 2935 | runner.run (arguments[0]);
|
|---|
| 2936 | }
|
|---|
| 2937 |
|
|---|
| 2938 | //----------------------------------------------------------
|
|---|
| 2939 | void Cmt::do_set_version (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2940 | {
|
|---|
| 2941 | if (arguments.size () == 0) cerr << "#CMT> set version: no version specified" << endl;
|
|---|
| 2942 |
|
|---|
| 2943 | const cmt_string& version = arguments[0];
|
|---|
| 2944 |
|
|---|
| 2945 | int v, r, p;
|
|---|
| 2946 |
|
|---|
| 2947 | if (!CmtSystem::is_version_directory (version, v, r, p))
|
|---|
| 2948 | {
|
|---|
| 2949 | cerr << "#CMT> set version " << version << " is not a correct version syntax" << endl;
|
|---|
| 2950 | return;
|
|---|
| 2951 | }
|
|---|
| 2952 |
|
|---|
| 2953 | if ((v == -1) || (r == -1) || (p == -1))
|
|---|
| 2954 | {
|
|---|
| 2955 | cerr << "#CMT> set version " << version
|
|---|
| 2956 | << " You cannot use wild card to set a version" << endl;
|
|---|
| 2957 | return;
|
|---|
| 2958 | }
|
|---|
| 2959 |
|
|---|
| 2960 | // We want to install the version.cmt file
|
|---|
| 2961 |
|
|---|
| 2962 | // We first check we are in a cmt branch
|
|---|
| 2963 | cmt_string h = CmtSystem::pwd ();
|
|---|
| 2964 | cmt_string branch;
|
|---|
| 2965 | CmtSystem::basename (h, branch);
|
|---|
| 2966 |
|
|---|
| 2967 | if (branch != "cmt")
|
|---|
| 2968 | {
|
|---|
| 2969 | cerr << "#CMT> set version " << version << " must be applied in a cmt directory"
|
|---|
| 2970 | << endl;
|
|---|
| 2971 | return;
|
|---|
| 2972 | }
|
|---|
| 2973 |
|
|---|
| 2974 | CmtSystem::dirname (h, h);
|
|---|
| 2975 | CmtSystem::basename (h, branch);
|
|---|
| 2976 |
|
|---|
| 2977 | if (branch == version)
|
|---|
| 2978 | {
|
|---|
| 2979 | cerr << "#CMT> set version " << version << " is already available as a version directory"
|
|---|
| 2980 | << endl;
|
|---|
| 2981 | return;
|
|---|
| 2982 | }
|
|---|
| 2983 |
|
|---|
| 2984 | cout << "Writing version file : " << version << endl;
|
|---|
| 2985 |
|
|---|
| 2986 | version.write ("version.cmt");
|
|---|
| 2987 | }
|
|---|
| 2988 |
|
|---|
| 2989 | //----------------------------------------------------------
|
|---|
| 2990 | void Cmt::do_set_versions (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 2991 | {
|
|---|
| 2992 | CmtSystem::cmt_string_vector args;
|
|---|
| 2993 |
|
|---|
| 2994 | args = arguments;
|
|---|
| 2995 | {
|
|---|
| 2996 | cmt_string& s = args.add ();
|
|---|
| 2997 | s = "cmt";
|
|---|
| 2998 | }
|
|---|
| 2999 | {
|
|---|
| 3000 | cmt_string& s = args.add ();
|
|---|
| 3001 | s = "set";
|
|---|
| 3002 | }
|
|---|
| 3003 | {
|
|---|
| 3004 | cmt_string& s = args.add ();
|
|---|
| 3005 | s = "version";
|
|---|
| 3006 | }
|
|---|
| 3007 | {
|
|---|
| 3008 | cmt_string& s = args.add ();
|
|---|
| 3009 | s = "<version>";
|
|---|
| 3010 | }
|
|---|
| 3011 |
|
|---|
| 3012 | m_action = action_broadcast;
|
|---|
| 3013 |
|
|---|
| 3014 | do_broadcast (args, 0, 0);
|
|---|
| 3015 | }
|
|---|
| 3016 |
|
|---|
| 3017 | //----------------------------------------------------------
|
|---|
| 3018 | void Cmt::do_setup (PrintMode& mode)
|
|---|
| 3019 | {
|
|---|
| 3020 | print (mode);
|
|---|
| 3021 |
|
|---|
| 3022 | //
|
|---|
| 3023 | // Try a cleanup of the installation area
|
|---|
| 3024 | //
|
|---|
| 3025 | if ((get_build_strategy () & InstallAreaMask) == WithInstallArea)
|
|---|
| 3026 | {
|
|---|
| 3027 | CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
|
|---|
| 3028 |
|
|---|
| 3029 | //cout << "#IA5>" << endl;
|
|---|
| 3030 |
|
|---|
| 3031 | ia_mgr.setup ();
|
|---|
| 3032 |
|
|---|
| 3033 | /*
|
|---|
| 3034 | if ((get_setup_strategy () & SetupCleanupMask) == SetupCleanup)
|
|---|
| 3035 | {
|
|---|
| 3036 | const cmt_string& installarea = ia_mgr.get_installarea ();
|
|---|
| 3037 |
|
|---|
| 3038 | if (installarea != "")
|
|---|
| 3039 | {
|
|---|
| 3040 | cmt_string q;
|
|---|
| 3041 |
|
|---|
| 3042 | switch (mode)
|
|---|
| 3043 | {
|
|---|
| 3044 | case Sh :
|
|---|
| 3045 | case Csh :
|
|---|
| 3046 | q = "\'";
|
|---|
| 3047 | break;
|
|---|
| 3048 | default :
|
|---|
| 3049 | break;
|
|---|
| 3050 | }
|
|---|
| 3051 |
|
|---|
| 3052 | if (!m_quiet)
|
|---|
| 3053 | {
|
|---|
| 3054 | cout << "echo " << q
|
|---|
| 3055 | << "# Doing cleanup in the installation area " << installarea
|
|---|
| 3056 | << q << endl;
|
|---|
| 3057 | }
|
|---|
| 3058 | }
|
|---|
| 3059 |
|
|---|
| 3060 | ia_mgr.config ();
|
|---|
| 3061 | }
|
|---|
| 3062 | */
|
|---|
| 3063 | }
|
|---|
| 3064 | }
|
|---|
| 3065 |
|
|---|
| 3066 | //----------------------------------------------------------
|
|---|
| 3067 | void Cmt::do_show_action (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3068 | PrintMode& mode)
|
|---|
| 3069 | {
|
|---|
| 3070 | cmt_string target;
|
|---|
| 3071 |
|
|---|
| 3072 | if (arguments.size () > 0) target = arguments[0];
|
|---|
| 3073 |
|
|---|
| 3074 | Symbol* symbol;
|
|---|
| 3075 |
|
|---|
| 3076 | set_standard_macros ();
|
|---|
| 3077 |
|
|---|
| 3078 | symbol = Symbol::find (target);
|
|---|
| 3079 |
|
|---|
| 3080 | if (symbol == 0)
|
|---|
| 3081 | {
|
|---|
| 3082 | cmt_string t = " ";
|
|---|
| 3083 | t += target;
|
|---|
| 3084 | t += " is not defined ";
|
|---|
| 3085 |
|
|---|
| 3086 | CmtError::set (CmtError::symbol_not_found, t);
|
|---|
| 3087 |
|
|---|
| 3088 | return;
|
|---|
| 3089 | }
|
|---|
| 3090 | else
|
|---|
| 3091 | {
|
|---|
| 3092 | cmt_string t = target;
|
|---|
| 3093 | t += " is a ";
|
|---|
| 3094 |
|
|---|
| 3095 | if ((m_action == action_show_action) ||
|
|---|
| 3096 | (m_action == action_show_action_value))
|
|---|
| 3097 | {
|
|---|
| 3098 | if (symbol->type != Symbol::SymbolAction)
|
|---|
| 3099 | {
|
|---|
| 3100 | if (symbol->type == Symbol::SymbolMacro)
|
|---|
| 3101 | {
|
|---|
| 3102 | t += "macro";
|
|---|
| 3103 | }
|
|---|
| 3104 | else if (symbol->type == Symbol::SymbolSet)
|
|---|
| 3105 | {
|
|---|
| 3106 | t += "set";
|
|---|
| 3107 | }
|
|---|
| 3108 | else if (symbol->type == Symbol::SymbolPath)
|
|---|
| 3109 | {
|
|---|
| 3110 | t += "path";
|
|---|
| 3111 | }
|
|---|
| 3112 | else if (symbol->type == Symbol::SymbolAlias)
|
|---|
| 3113 | {
|
|---|
| 3114 | t += "alias";
|
|---|
| 3115 | }
|
|---|
| 3116 |
|
|---|
| 3117 | CmtError::set (CmtError::warning, t);
|
|---|
| 3118 | }
|
|---|
| 3119 | }
|
|---|
| 3120 | }
|
|---|
| 3121 |
|
|---|
| 3122 | if (symbol->value_lists.size () < 1) return;
|
|---|
| 3123 |
|
|---|
| 3124 | symbol->show_macro (mode);
|
|---|
| 3125 | }
|
|---|
| 3126 |
|
|---|
| 3127 | //----------------------------------------------------------
|
|---|
| 3128 | void Cmt::do_show_action_names (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3129 | PrintMode& mode)
|
|---|
| 3130 | {
|
|---|
| 3131 | if (arguments.size () > 0)
|
|---|
| 3132 | {
|
|---|
| 3133 | const cmt_string& pattern = arguments[0];
|
|---|
| 3134 | print_symbol_names (mode, pattern);
|
|---|
| 3135 | }
|
|---|
| 3136 | else
|
|---|
| 3137 | {
|
|---|
| 3138 | print_symbol_names (mode);
|
|---|
| 3139 | }
|
|---|
| 3140 | }
|
|---|
| 3141 |
|
|---|
| 3142 | //----------------------------------------------------------
|
|---|
| 3143 | void Cmt::do_show_action_value (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3144 | PrintMode& mode)
|
|---|
| 3145 | {
|
|---|
| 3146 | do_show_macro (arguments, mode);
|
|---|
| 3147 | }
|
|---|
| 3148 |
|
|---|
| 3149 | //----------------------------------------------------------
|
|---|
| 3150 | void Cmt::do_show_actions (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3151 | PrintMode& mode)
|
|---|
| 3152 | {
|
|---|
| 3153 | if (arguments.size () > 0)
|
|---|
| 3154 | {
|
|---|
| 3155 | const cmt_string& pattern = arguments[0];
|
|---|
| 3156 | print_macros (mode, pattern);
|
|---|
| 3157 | }
|
|---|
| 3158 | else
|
|---|
| 3159 | {
|
|---|
| 3160 | print_macros (mode);
|
|---|
| 3161 | }
|
|---|
| 3162 | }
|
|---|
| 3163 |
|
|---|
| 3164 | //----------------------------------------------------------
|
|---|
| 3165 | void Cmt::do_show_all_tags ()
|
|---|
| 3166 | {
|
|---|
| 3167 | Tag::TagPtrVector tags = Tag::tags ();
|
|---|
| 3168 | int index;
|
|---|
| 3169 |
|
|---|
| 3170 | set_standard_macros ();
|
|---|
| 3171 |
|
|---|
| 3172 | for (index = 0; index < tags.size (); index++)
|
|---|
| 3173 | {
|
|---|
| 3174 | const Tag* tag = tags[index];
|
|---|
| 3175 | if (tag != 0)
|
|---|
| 3176 | {
|
|---|
| 3177 | tag->show_definition (true);
|
|---|
| 3178 | }
|
|---|
| 3179 | }
|
|---|
| 3180 | }
|
|---|
| 3181 |
|
|---|
| 3182 | //----------------------------------------------------------
|
|---|
| 3183 | void Cmt::do_show_applied_patterns ()
|
|---|
| 3184 | {
|
|---|
| 3185 | Pattern::show_all_applied_patterns ();
|
|---|
| 3186 | }
|
|---|
| 3187 |
|
|---|
| 3188 | //----------------------------------------------------------
|
|---|
| 3189 | void Cmt::do_show_author ()
|
|---|
| 3190 | {
|
|---|
| 3191 | Use& use = Use::current();
|
|---|
| 3192 |
|
|---|
| 3193 | cout << use.author << endl;
|
|---|
| 3194 | }
|
|---|
| 3195 |
|
|---|
| 3196 | //----------------------------------------------------------
|
|---|
| 3197 | void Cmt::do_show_branches (PrintMode& mode)
|
|---|
| 3198 | {
|
|---|
| 3199 | Branch::print_all (mode);
|
|---|
| 3200 | }
|
|---|
| 3201 |
|
|---|
| 3202 | //----------------------------------------------------------
|
|---|
| 3203 | void Cmt::do_show_clients (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3204 | {
|
|---|
| 3205 | cmt_string package;
|
|---|
| 3206 | cmt_string version;
|
|---|
| 3207 | cmt_string path_name;
|
|---|
| 3208 |
|
|---|
| 3209 | if (arguments.size () >= 1) package = arguments[0];
|
|---|
| 3210 | if (arguments.size () >= 2) version = arguments[1];
|
|---|
| 3211 | if (arguments.size () >= 3) path_name = arguments[2];
|
|---|
| 3212 |
|
|---|
| 3213 | PathScanner scanner;
|
|---|
| 3214 | ClientCollector collector (package, version);
|
|---|
| 3215 |
|
|---|
| 3216 | clear ();
|
|---|
| 3217 | configure ();
|
|---|
| 3218 |
|
|---|
| 3219 | cout << "# ----------- Clients of " << package <<
|
|---|
| 3220 | " " << version <<
|
|---|
| 3221 | " " << path_name <<
|
|---|
| 3222 | endl;
|
|---|
| 3223 |
|
|---|
| 3224 | if (path_name == "")
|
|---|
| 3225 | {
|
|---|
| 3226 | Project::scan_paths (scanner, collector);
|
|---|
| 3227 | }
|
|---|
| 3228 | else
|
|---|
| 3229 | {
|
|---|
| 3230 | scanner.scan_path (path_name, collector);
|
|---|
| 3231 | }
|
|---|
| 3232 | cout << "# ----------- " << collector.count () << " clients found." << endl;
|
|---|
| 3233 | }
|
|---|
| 3234 |
|
|---|
| 3235 | //----------------------------------------------------------
|
|---|
| 3236 | void Cmt::do_show_cmtpath_patterns ()
|
|---|
| 3237 | {
|
|---|
| 3238 | set_standard_macros ();
|
|---|
| 3239 | CmtPathPattern::show_all ();
|
|---|
| 3240 | }
|
|---|
| 3241 |
|
|---|
| 3242 | //----------------------------------------------------------
|
|---|
| 3243 | void Cmt::do_show_constituent (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3244 | {
|
|---|
| 3245 | if (arguments.size () > 0)
|
|---|
| 3246 | {
|
|---|
| 3247 | set_standard_macros ();
|
|---|
| 3248 |
|
|---|
| 3249 | Constituent* c = Constituent::find (arguments[0]);
|
|---|
| 3250 | if (c != 0)
|
|---|
| 3251 | {
|
|---|
| 3252 | c->show ();
|
|---|
| 3253 | }
|
|---|
| 3254 | }
|
|---|
| 3255 | }
|
|---|
| 3256 |
|
|---|
| 3257 | //----------------------------------------------------------
|
|---|
| 3258 | void Cmt::do_show_constituent_names ()
|
|---|
| 3259 | {
|
|---|
| 3260 | set_standard_macros ();
|
|---|
| 3261 | Constituent::show_names ();
|
|---|
| 3262 | }
|
|---|
| 3263 |
|
|---|
| 3264 | //----------------------------------------------------------
|
|---|
| 3265 | void Cmt::do_show_constituents ()
|
|---|
| 3266 | {
|
|---|
| 3267 | set_standard_macros ();
|
|---|
| 3268 | Constituent::show_all ();
|
|---|
| 3269 | }
|
|---|
| 3270 |
|
|---|
| 3271 | //----------------------------------------------------------
|
|---|
| 3272 | void Cmt::do_show_cycles ()
|
|---|
| 3273 | {
|
|---|
| 3274 | set_standard_macros ();
|
|---|
| 3275 | Use& use = Use::current();
|
|---|
| 3276 |
|
|---|
| 3277 | use.show_cycles ();
|
|---|
| 3278 | }
|
|---|
| 3279 |
|
|---|
| 3280 | //----------------------------------------------------------
|
|---|
| 3281 | void Cmt::do_show_fragment (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3282 | {
|
|---|
| 3283 | if (arguments.size () > 0) Fragment::show (arguments[0]);
|
|---|
| 3284 | }
|
|---|
| 3285 |
|
|---|
| 3286 | //----------------------------------------------------------
|
|---|
| 3287 | void Cmt::do_show_fragments ()
|
|---|
| 3288 | {
|
|---|
| 3289 | Fragment::show_all ();
|
|---|
| 3290 | }
|
|---|
| 3291 |
|
|---|
| 3292 | //----------------------------------------------------------
|
|---|
| 3293 | void Cmt::do_show_groups ()
|
|---|
| 3294 | {
|
|---|
| 3295 | Group::show_all ();
|
|---|
| 3296 | }
|
|---|
| 3297 |
|
|---|
| 3298 | //----------------------------------------------------------
|
|---|
| 3299 | void Cmt::do_show_include_dirs ()
|
|---|
| 3300 | {
|
|---|
| 3301 | cmt_string temp;
|
|---|
| 3302 |
|
|---|
| 3303 | Use& use = Use::current();
|
|---|
| 3304 |
|
|---|
| 3305 | set_standard_macros ();
|
|---|
| 3306 |
|
|---|
| 3307 | if (use.include_path == "")
|
|---|
| 3308 | {
|
|---|
| 3309 | temp += "$(src) ";
|
|---|
| 3310 | }
|
|---|
| 3311 | else if (use.include_path != "none")
|
|---|
| 3312 | {
|
|---|
| 3313 | temp += use.include_path;
|
|---|
| 3314 | temp += " ";
|
|---|
| 3315 | }
|
|---|
| 3316 |
|
|---|
| 3317 | for (int include_number = 0;
|
|---|
| 3318 | include_number < use.includes.size ();
|
|---|
| 3319 | include_number++)
|
|---|
| 3320 | {
|
|---|
| 3321 | Include& incl = use.includes[include_number];
|
|---|
| 3322 |
|
|---|
| 3323 | temp += incl.name;
|
|---|
| 3324 | temp += " ";
|
|---|
| 3325 | }
|
|---|
| 3326 |
|
|---|
| 3327 | cout << temp << endl;
|
|---|
| 3328 | }
|
|---|
| 3329 |
|
|---|
| 3330 | //----------------------------------------------------------
|
|---|
| 3331 | void Cmt::do_show_language (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3332 | {
|
|---|
| 3333 | if (arguments.size () > 0)
|
|---|
| 3334 | {
|
|---|
| 3335 | set_standard_macros ();
|
|---|
| 3336 | Language::show (arguments[0]);
|
|---|
| 3337 | }
|
|---|
| 3338 | }
|
|---|
| 3339 |
|
|---|
| 3340 | //----------------------------------------------------------
|
|---|
| 3341 | void Cmt::do_show_languages ()
|
|---|
| 3342 | {
|
|---|
| 3343 | set_standard_macros ();
|
|---|
| 3344 | Language::show_all ();
|
|---|
| 3345 | }
|
|---|
| 3346 |
|
|---|
| 3347 | //----------------------------------------------------------
|
|---|
| 3348 | void Cmt::do_show_macro (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3349 | PrintMode& mode)
|
|---|
| 3350 | {
|
|---|
| 3351 | cmt_string target;
|
|---|
| 3352 |
|
|---|
| 3353 | if (arguments.size () > 0) target = arguments[0];
|
|---|
| 3354 |
|
|---|
| 3355 | Symbol* symbol;
|
|---|
| 3356 |
|
|---|
| 3357 | set_standard_macros ();
|
|---|
| 3358 |
|
|---|
| 3359 | symbol = Symbol::find (target);
|
|---|
| 3360 |
|
|---|
| 3361 | if (symbol == 0)
|
|---|
| 3362 | {
|
|---|
| 3363 | cmt_string t = " ";
|
|---|
| 3364 | t += target;
|
|---|
| 3365 | t += " is not defined ";
|
|---|
| 3366 |
|
|---|
| 3367 | CmtError::set (CmtError::symbol_not_found, t);
|
|---|
| 3368 |
|
|---|
| 3369 | return;
|
|---|
| 3370 | }
|
|---|
| 3371 | else
|
|---|
| 3372 | {
|
|---|
| 3373 | cmt_string t = target;
|
|---|
| 3374 | t += " is a ";
|
|---|
| 3375 |
|
|---|
| 3376 | if ((m_action == action_show_macro) ||
|
|---|
| 3377 | (m_action == action_show_macro_value))
|
|---|
| 3378 | {
|
|---|
| 3379 | if (symbol->type != Symbol::SymbolMacro)
|
|---|
| 3380 | {
|
|---|
| 3381 | if (symbol->type == Symbol::SymbolAction)
|
|---|
| 3382 | {
|
|---|
| 3383 | t += "action";
|
|---|
| 3384 | }
|
|---|
| 3385 | else if (symbol->type == Symbol::SymbolSet)
|
|---|
| 3386 | {
|
|---|
| 3387 | t += "set";
|
|---|
| 3388 | }
|
|---|
| 3389 | else if (symbol->type == Symbol::SymbolPath)
|
|---|
| 3390 | {
|
|---|
| 3391 | t += "path";
|
|---|
| 3392 | }
|
|---|
| 3393 | else if (symbol->type == Symbol::SymbolAlias)
|
|---|
| 3394 | {
|
|---|
| 3395 | t += "alias";
|
|---|
| 3396 | }
|
|---|
| 3397 |
|
|---|
| 3398 | CmtError::set (CmtError::warning, t);
|
|---|
| 3399 | }
|
|---|
| 3400 | }
|
|---|
| 3401 | else if ((m_action == action_show_set) ||
|
|---|
| 3402 | (m_action == action_show_set_value))
|
|---|
| 3403 | {
|
|---|
| 3404 | if ((symbol->type != Symbol::SymbolSet) &&
|
|---|
| 3405 | (symbol->type != Symbol::SymbolPath) &&
|
|---|
| 3406 | (symbol->type != Symbol::SymbolAction) &&
|
|---|
| 3407 | (symbol->type != Symbol::SymbolAlias))
|
|---|
| 3408 | {
|
|---|
| 3409 | t += "macro";
|
|---|
| 3410 |
|
|---|
| 3411 | CmtError::set (CmtError::warning, t);
|
|---|
| 3412 | }
|
|---|
| 3413 | }
|
|---|
| 3414 | }
|
|---|
| 3415 |
|
|---|
| 3416 | if (symbol->value_lists.size () < 1) return;
|
|---|
| 3417 |
|
|---|
| 3418 | symbol->show_macro (mode);
|
|---|
| 3419 | }
|
|---|
| 3420 |
|
|---|
| 3421 | //----------------------------------------------------------
|
|---|
| 3422 | void Cmt::do_show_macro_names (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3423 | PrintMode& mode)
|
|---|
| 3424 | {
|
|---|
| 3425 | if (arguments.size () > 0)
|
|---|
| 3426 | {
|
|---|
| 3427 | const cmt_string& pattern = arguments[0];
|
|---|
| 3428 | print_symbol_names (mode, pattern);
|
|---|
| 3429 | }
|
|---|
| 3430 | else
|
|---|
| 3431 | {
|
|---|
| 3432 | print_symbol_names (mode);
|
|---|
| 3433 | }
|
|---|
| 3434 | }
|
|---|
| 3435 |
|
|---|
| 3436 | //----------------------------------------------------------
|
|---|
| 3437 | void Cmt::do_show_macro_value (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3438 | PrintMode& mode)
|
|---|
| 3439 | {
|
|---|
| 3440 | do_show_macro (arguments, mode);
|
|---|
| 3441 | }
|
|---|
| 3442 |
|
|---|
| 3443 | //----------------------------------------------------------
|
|---|
| 3444 | void Cmt::do_show_macros (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3445 | PrintMode& mode)
|
|---|
| 3446 | {
|
|---|
| 3447 | if (arguments.size () > 0)
|
|---|
| 3448 | {
|
|---|
| 3449 | const cmt_string& pattern = arguments[0];
|
|---|
| 3450 | print_macros (mode, pattern);
|
|---|
| 3451 | }
|
|---|
| 3452 | else
|
|---|
| 3453 | {
|
|---|
| 3454 | print_macros (mode);
|
|---|
| 3455 | }
|
|---|
| 3456 | }
|
|---|
| 3457 |
|
|---|
| 3458 | //----------------------------------------------------------
|
|---|
| 3459 | void Cmt::do_show_manager ()
|
|---|
| 3460 | {
|
|---|
| 3461 | Use& use = Use::current();
|
|---|
| 3462 |
|
|---|
| 3463 | cout << use.manager << endl;
|
|---|
| 3464 | }
|
|---|
| 3465 |
|
|---|
| 3466 | //----------------------------------------------------------
|
|---|
| 3467 | void Cmt::do_show_packages (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3468 | {
|
|---|
| 3469 | cmt_string path_name;
|
|---|
| 3470 |
|
|---|
| 3471 | if (arguments.size () > 0) path_name = arguments[0];
|
|---|
| 3472 |
|
|---|
| 3473 | PathScanner scanner;
|
|---|
| 3474 | PackageViewer viewer;
|
|---|
| 3475 |
|
|---|
| 3476 | if (path_name == "")
|
|---|
| 3477 | {
|
|---|
| 3478 | Project::scan_paths (scanner, viewer);
|
|---|
| 3479 | }
|
|---|
| 3480 | else
|
|---|
| 3481 | {
|
|---|
| 3482 | scanner.scan_path (path_name, viewer);
|
|---|
| 3483 | }
|
|---|
| 3484 | }
|
|---|
| 3485 |
|
|---|
| 3486 | //----------------------------------------------------------
|
|---|
| 3487 | void Cmt::do_show_path ()
|
|---|
| 3488 | {
|
|---|
| 3489 | Project::show_paths ();
|
|---|
| 3490 | }
|
|---|
| 3491 |
|
|---|
| 3492 | //----------------------------------------------------------
|
|---|
| 3493 | void Cmt::do_show_pattern (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3494 | {
|
|---|
| 3495 | cmt_string name;
|
|---|
| 3496 | if (arguments.size () > 0) name = arguments[0];
|
|---|
| 3497 | Pattern::show (name);
|
|---|
| 3498 | }
|
|---|
| 3499 |
|
|---|
| 3500 | //----------------------------------------------------------
|
|---|
| 3501 | void Cmt::do_show_pattern_names ()
|
|---|
| 3502 | {
|
|---|
| 3503 | Pattern::show_all_names ();
|
|---|
| 3504 | }
|
|---|
| 3505 |
|
|---|
| 3506 | //----------------------------------------------------------
|
|---|
| 3507 | void Cmt::do_show_patterns ()
|
|---|
| 3508 | {
|
|---|
| 3509 | Pattern::show_all ();
|
|---|
| 3510 | }
|
|---|
| 3511 |
|
|---|
| 3512 | //----------------------------------------------------------
|
|---|
| 3513 | void Cmt::do_show_projects ()
|
|---|
| 3514 | {
|
|---|
| 3515 | Project::show_all ();
|
|---|
| 3516 | }
|
|---|
| 3517 |
|
|---|
| 3518 | //----------------------------------------------------------
|
|---|
| 3519 | void Cmt::do_show_pwd ()
|
|---|
| 3520 | {
|
|---|
| 3521 | cout << m_current_dir << endl;
|
|---|
| 3522 | }
|
|---|
| 3523 |
|
|---|
| 3524 | //----------------------------------------------------------
|
|---|
| 3525 | void Cmt::do_show_setup ()
|
|---|
| 3526 | {
|
|---|
| 3527 | cout << "----------> uses" << endl;
|
|---|
| 3528 | do_show_uses ();
|
|---|
| 3529 |
|
|---|
| 3530 | cout << "----------> tags" << endl;
|
|---|
| 3531 | do_show_tags ();
|
|---|
| 3532 |
|
|---|
| 3533 | cout << "----------> CMTPATH" << endl;
|
|---|
| 3534 | do_show_path ();
|
|---|
| 3535 | }
|
|---|
| 3536 |
|
|---|
| 3537 | //----------------------------------------------------------
|
|---|
| 3538 | void Cmt::do_show_set (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3539 | PrintMode& mode)
|
|---|
| 3540 | {
|
|---|
| 3541 | do_show_macro (arguments, mode);
|
|---|
| 3542 | }
|
|---|
| 3543 |
|
|---|
| 3544 | //----------------------------------------------------------
|
|---|
| 3545 | void Cmt::do_show_set_names (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3546 | PrintMode& mode)
|
|---|
| 3547 | {
|
|---|
| 3548 | if (arguments.size () > 0)
|
|---|
| 3549 | {
|
|---|
| 3550 | const cmt_string& pattern = arguments[0];
|
|---|
| 3551 | print_symbol_names (mode, pattern);
|
|---|
| 3552 | }
|
|---|
| 3553 | else
|
|---|
| 3554 | {
|
|---|
| 3555 | print_symbol_names (mode);
|
|---|
| 3556 | }
|
|---|
| 3557 | }
|
|---|
| 3558 |
|
|---|
| 3559 | //----------------------------------------------------------
|
|---|
| 3560 | void Cmt::do_show_set_value (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3561 | PrintMode& mode)
|
|---|
| 3562 | {
|
|---|
| 3563 | do_show_macro (arguments, mode);
|
|---|
| 3564 | }
|
|---|
| 3565 |
|
|---|
| 3566 | //----------------------------------------------------------
|
|---|
| 3567 | void Cmt::do_show_sets (const CmtSystem::cmt_string_vector& arguments,
|
|---|
| 3568 | PrintMode& mode)
|
|---|
| 3569 | {
|
|---|
| 3570 | if (arguments.size () > 0)
|
|---|
| 3571 | {
|
|---|
| 3572 | const cmt_string& pattern = arguments[0];
|
|---|
| 3573 | print_macros (mode, pattern);
|
|---|
| 3574 | }
|
|---|
| 3575 | else
|
|---|
| 3576 | {
|
|---|
| 3577 | print_macros (mode);
|
|---|
| 3578 | }
|
|---|
| 3579 | }
|
|---|
| 3580 |
|
|---|
| 3581 | //----------------------------------------------------------
|
|---|
| 3582 | void Cmt::do_show_strategies ()
|
|---|
| 3583 | {
|
|---|
| 3584 | Project* p = Project::get_current ();
|
|---|
| 3585 |
|
|---|
| 3586 | if (p != 0) p->show ();
|
|---|
| 3587 | else cout << "No current project" << endl;
|
|---|
| 3588 |
|
|---|
| 3589 | cout << "Structuring style : ";
|
|---|
| 3590 |
|
|---|
| 3591 | int strategy = 0;
|
|---|
| 3592 |
|
|---|
| 3593 | switch (m_current_structuring_style)
|
|---|
| 3594 | {
|
|---|
| 3595 | case without_version_directory:
|
|---|
| 3596 | cout << "without_version_directory";
|
|---|
| 3597 | break;
|
|---|
| 3598 | case with_version_directory:
|
|---|
| 3599 | cout << "with_version_directory";
|
|---|
| 3600 | break;
|
|---|
| 3601 | }
|
|---|
| 3602 |
|
|---|
| 3603 | cout << endl;
|
|---|
| 3604 |
|
|---|
| 3605 | cout << "Build strategy : ";
|
|---|
| 3606 |
|
|---|
| 3607 | if (p == 0) strategy = m_current_build_strategy;
|
|---|
| 3608 | else strategy = p->get_build_strategy ();
|
|---|
| 3609 |
|
|---|
| 3610 | if ((strategy & PrototypesMask) == Prototypes)
|
|---|
| 3611 | {
|
|---|
| 3612 | cout << "prototypes";
|
|---|
| 3613 | }
|
|---|
| 3614 | else
|
|---|
| 3615 | {
|
|---|
| 3616 | cout << "no_prototypes";
|
|---|
| 3617 | }
|
|---|
| 3618 |
|
|---|
| 3619 | if ((strategy & KeepMakefilesMask) == KeepMakefiles)
|
|---|
| 3620 | {
|
|---|
| 3621 | cout << " keep_makefiles";
|
|---|
| 3622 | }
|
|---|
| 3623 | else
|
|---|
| 3624 | {
|
|---|
| 3625 | cout << " rebuild_makefiles";
|
|---|
| 3626 | }
|
|---|
| 3627 |
|
|---|
| 3628 | if ((strategy & InstallAreaMask) == WithInstallArea)
|
|---|
| 3629 | {
|
|---|
| 3630 | cout << " with_installarea";
|
|---|
| 3631 | }
|
|---|
| 3632 | else
|
|---|
| 3633 | {
|
|---|
| 3634 | cout << " without_installarea";
|
|---|
| 3635 | }
|
|---|
| 3636 |
|
|---|
| 3637 | cout << endl;
|
|---|
| 3638 |
|
|---|
| 3639 | cout << "Setup strategy : ";
|
|---|
| 3640 |
|
|---|
| 3641 | strategy = get_setup_strategy ();
|
|---|
| 3642 |
|
|---|
| 3643 | if ((strategy & SetupConfigMask) == SetupConfig)
|
|---|
| 3644 | {
|
|---|
| 3645 | cout << "config";
|
|---|
| 3646 | }
|
|---|
| 3647 | else
|
|---|
| 3648 | {
|
|---|
| 3649 | cout << "no_config";
|
|---|
| 3650 | }
|
|---|
| 3651 |
|
|---|
| 3652 | if ((strategy & SetupRootMask) == SetupRoot)
|
|---|
| 3653 | {
|
|---|
| 3654 | cout << " root";
|
|---|
| 3655 | }
|
|---|
| 3656 | else
|
|---|
| 3657 | {
|
|---|
| 3658 | cout << " no_root";
|
|---|
| 3659 | }
|
|---|
| 3660 |
|
|---|
| 3661 | if ((strategy & SetupCleanupMask) == SetupCleanup)
|
|---|
| 3662 | {
|
|---|
| 3663 | cout << " cleanup";
|
|---|
| 3664 | }
|
|---|
| 3665 | else
|
|---|
| 3666 | {
|
|---|
| 3667 | cout << " no_cleanup";
|
|---|
| 3668 | }
|
|---|
| 3669 |
|
|---|
| 3670 | cout << endl;
|
|---|
| 3671 | }
|
|---|
| 3672 |
|
|---|
| 3673 | //----------------------------------------------------------
|
|---|
| 3674 | void Cmt::do_show_tags ()
|
|---|
| 3675 | {
|
|---|
| 3676 | Tag::TagPtrVector tags = Tag::tags ();
|
|---|
| 3677 | int index;
|
|---|
| 3678 |
|
|---|
| 3679 | set_standard_macros ();
|
|---|
| 3680 |
|
|---|
| 3681 | for (index = 0; index < tags.size (); index++)
|
|---|
| 3682 | {
|
|---|
| 3683 | const Tag* tag = tags[index];
|
|---|
| 3684 | if (tag != 0)
|
|---|
| 3685 | {
|
|---|
| 3686 | tag->show (m_quiet);
|
|---|
| 3687 | }
|
|---|
| 3688 | }
|
|---|
| 3689 | }
|
|---|
| 3690 |
|
|---|
| 3691 | //----------------------------------------------------------
|
|---|
| 3692 | void Cmt::do_show_use_paths (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3693 | {
|
|---|
| 3694 | const cmt_string& to_name = arguments[0];
|
|---|
| 3695 |
|
|---|
| 3696 | Use* current = &(Use::current());
|
|---|
| 3697 |
|
|---|
| 3698 | current->get_all_clients (to_name);
|
|---|
| 3699 | }
|
|---|
| 3700 |
|
|---|
| 3701 | //----------------------------------------------------------
|
|---|
| 3702 | void Cmt::do_show_uses ()
|
|---|
| 3703 | {
|
|---|
| 3704 | Use::show_all ();
|
|---|
| 3705 | }
|
|---|
| 3706 |
|
|---|
| 3707 | //----------------------------------------------------------
|
|---|
| 3708 | void Cmt::do_show_version ()
|
|---|
| 3709 | {
|
|---|
| 3710 | cout << m_current_version << endl;
|
|---|
| 3711 | }
|
|---|
| 3712 |
|
|---|
| 3713 | //----------------------------------------------------------
|
|---|
| 3714 | void Cmt::do_show_versions (const CmtSystem::cmt_string_vector& arguments)
|
|---|
| 3715 | {
|
|---|
| 3716 | cmt_string package_name;
|
|---|
| 3717 |
|
|---|
| 3718 | if (arguments.size () > 0) package_name = arguments[0];
|
|---|
| 3719 |
|
|---|
| 3720 | PathScanner scanner;
|
|---|
| 3721 |
|
|---|
| 3722 | Project::scan_paths_for_package (scanner, package_name);
|
|---|
| 3723 | }
|
|---|
| 3724 |
|
|---|
| 3725 | //----------------------------------------------------------
|
|---|
| 3726 | void Cmt::do_show_system ()
|
|---|
| 3727 | {
|
|---|
| 3728 | cout << CmtSystem::get_cmt_config () << endl;
|
|---|
| 3729 | }
|
|---|
| 3730 |
|
|---|
| 3731 | //----------------------------------------------------------
|
|---|
| 3732 | void Cmt::do_unlock (const cmt_string& package,
|
|---|
| 3733 | const cmt_string& version,
|
|---|
| 3734 | const cmt_string& path)
|
|---|
| 3735 | {
|
|---|
| 3736 | // (unused??) Use& use = Use::current();
|
|---|
| 3737 |
|
|---|
| 3738 | cout << "try to unlock package " << package << " in " << CmtSystem::pwd () << endl;
|
|---|
| 3739 |
|
|---|
| 3740 | set_standard_macros ();
|
|---|
| 3741 |
|
|---|
| 3742 | CmtLock::status status = CmtLock::unlock ();
|
|---|
| 3743 | }
|
|---|
| 3744 |
|
|---|
| 3745 | //----------------------------------------------------------
|
|---|
| 3746 | void Cmt::do_version ()
|
|---|
| 3747 | {
|
|---|
| 3748 | cout << CMTVERSION << endl;
|
|---|
| 3749 | }
|
|---|
| 3750 |
|
|---|
| 3751 |
|
|---|
| 3752 |
|
|---|
| 3753 | //----------------------------------------------------------
|
|---|
| 3754 | ActionType Cmt::get_action ()
|
|---|
| 3755 | {
|
|---|
| 3756 | return (m_action);
|
|---|
| 3757 | }
|
|---|
| 3758 |
|
|---|
| 3759 | /*
|
|---|
| 3760 | const CmtSystem::cmt_string_vector& Cmt::get_cmt_path ()
|
|---|
| 3761 | {
|
|---|
| 3762 | return (m_cmt_path);
|
|---|
| 3763 | }
|
|---|
| 3764 |
|
|---|
| 3765 | const CmtSystem::cmt_string_vector& Cmt::get_cmt_path_pwds ()
|
|---|
| 3766 | {
|
|---|
| 3767 | return (m_cmt_path_pwds);
|
|---|
| 3768 | }
|
|---|
| 3769 |
|
|---|
| 3770 | const CmtSystem::cmt_string_vector& Cmt::get_cmt_path_sources ()
|
|---|
| 3771 | {
|
|---|
| 3772 | return (m_cmt_path_sources);
|
|---|
| 3773 | }
|
|---|
| 3774 | */
|
|---|
| 3775 |
|
|---|
| 3776 | const cmt_string& Cmt::get_cmt_home ()
|
|---|
| 3777 | {
|
|---|
| 3778 | return (m_cmt_home);
|
|---|
| 3779 | }
|
|---|
| 3780 |
|
|---|
| 3781 | const cmt_string& Cmt::get_cmt_user_context ()
|
|---|
| 3782 | {
|
|---|
| 3783 | return (m_cmt_user_context);
|
|---|
| 3784 | }
|
|---|
| 3785 |
|
|---|
| 3786 | const cmt_string& Cmt::get_cmt_version ()
|
|---|
| 3787 | {
|
|---|
| 3788 | return (m_cmt_version);
|
|---|
| 3789 | }
|
|---|
| 3790 |
|
|---|
| 3791 | const cmt_string& Cmt::get_current_dir ()
|
|---|
| 3792 | {
|
|---|
| 3793 | return (m_current_dir);
|
|---|
| 3794 | }
|
|---|
| 3795 |
|
|---|
| 3796 | const cmt_string& Cmt::get_current_package ()
|
|---|
| 3797 | {
|
|---|
| 3798 | return (m_current_package);
|
|---|
| 3799 | }
|
|---|
| 3800 |
|
|---|
| 3801 | const cmt_string& Cmt::get_current_cmtpath ()
|
|---|
| 3802 | {
|
|---|
| 3803 | return (m_current_cmtpath);
|
|---|
| 3804 | }
|
|---|
| 3805 |
|
|---|
| 3806 | const cmt_string& Cmt::get_current_offset ()
|
|---|
| 3807 | {
|
|---|
| 3808 | return (m_current_offset);
|
|---|
| 3809 | }
|
|---|
| 3810 |
|
|---|
| 3811 | AccessMode Cmt::get_current_access ()
|
|---|
| 3812 | {
|
|---|
| 3813 | return (m_current_access);
|
|---|
| 3814 | }
|
|---|
| 3815 |
|
|---|
| 3816 | int Cmt::get_current_build_strategy ()
|
|---|
| 3817 | {
|
|---|
| 3818 | return (m_current_build_strategy);
|
|---|
| 3819 | }
|
|---|
| 3820 |
|
|---|
| 3821 | int Cmt::get_current_setup_strategy ()
|
|---|
| 3822 | {
|
|---|
| 3823 | return (m_current_setup_strategy);
|
|---|
| 3824 | }
|
|---|
| 3825 |
|
|---|
| 3826 | CmtStructuringStyle Cmt::get_current_structuring_style ()
|
|---|
| 3827 | {
|
|---|
| 3828 | return (m_current_structuring_style);
|
|---|
| 3829 | }
|
|---|
| 3830 |
|
|---|
| 3831 | CmtDirStyle Cmt::get_current_style ()
|
|---|
| 3832 | {
|
|---|
| 3833 | return (m_current_style);
|
|---|
| 3834 | }
|
|---|
| 3835 |
|
|---|
| 3836 | const cmt_string& Cmt::get_current_version ()
|
|---|
| 3837 | {
|
|---|
| 3838 | return (m_current_version);
|
|---|
| 3839 | }
|
|---|
| 3840 |
|
|---|
| 3841 | const cmt_string& Cmt::get_current_target ()
|
|---|
| 3842 | {
|
|---|
| 3843 | return (m_current_target);
|
|---|
| 3844 | }
|
|---|
| 3845 |
|
|---|
| 3846 | bool Cmt::get_debug ()
|
|---|
| 3847 | {
|
|---|
| 3848 | return (m_debug);
|
|---|
| 3849 | }
|
|---|
| 3850 |
|
|---|
| 3851 | bool Cmt::get_quiet ()
|
|---|
| 3852 | {
|
|---|
| 3853 | return (m_quiet);
|
|---|
| 3854 | }
|
|---|
| 3855 |
|
|---|
| 3856 | bool Cmt::get_recursive ()
|
|---|
| 3857 | {
|
|---|
| 3858 | return (m_recursive);
|
|---|
| 3859 | }
|
|---|
| 3860 |
|
|---|
| 3861 | CmtScopeFilteringMode Cmt::get_scope_filtering_mode ()
|
|---|
| 3862 | {
|
|---|
| 3863 | if (m_scope_filtering_mode == default_filtering_mode)
|
|---|
| 3864 | {
|
|---|
| 3865 | return (block_private_uses);
|
|---|
| 3866 | }
|
|---|
| 3867 | else
|
|---|
| 3868 | {
|
|---|
| 3869 | return (m_scope_filtering_mode);
|
|---|
| 3870 | }
|
|---|
| 3871 | }
|
|---|
| 3872 |
|
|---|
| 3873 | //----------------------------------------------------------
|
|---|
| 3874 | const cmt_string& Cmt::filter_dir (const cmt_string& dir)
|
|---|
| 3875 | {
|
|---|
| 3876 | static cmt_string newdir;
|
|---|
| 3877 |
|
|---|
| 3878 | CmtSystem::compress_path (dir, newdir);
|
|---|
| 3879 |
|
|---|
| 3880 | return (newdir);
|
|---|
| 3881 | }
|
|---|
| 3882 |
|
|---|
| 3883 | //----------------------------------------------------------
|
|---|
| 3884 | static void dos_script_prefix (FILE* f,
|
|---|
| 3885 | const cmt_string& cmt_root,
|
|---|
| 3886 | const cmt_string& package,
|
|---|
| 3887 | const cmt_string& version,
|
|---|
| 3888 | const cmt_string& path,
|
|---|
| 3889 | const cmt_string& action,
|
|---|
| 3890 | const cmt_string& option = "")
|
|---|
| 3891 | {
|
|---|
| 3892 | cmt_string no_device = path;
|
|---|
| 3893 |
|
|---|
| 3894 | if (CmtSystem::absolute_path (path))
|
|---|
| 3895 | {
|
|---|
| 3896 | if (path[1] == ':')
|
|---|
| 3897 | {
|
|---|
| 3898 | no_device = path.substr (2);
|
|---|
| 3899 | }
|
|---|
| 3900 | }
|
|---|
| 3901 |
|
|---|
| 3902 | if (package == "cmt_standalone")
|
|---|
| 3903 | {
|
|---|
| 3904 | no_device = "";
|
|---|
| 3905 | }
|
|---|
| 3906 | else
|
|---|
| 3907 | {
|
|---|
| 3908 | no_device = "..\\..\\..";
|
|---|
| 3909 | if (Cmt::get_current_style () == no_version_style)
|
|---|
| 3910 | {
|
|---|
| 3911 | no_device = "..\\..";
|
|---|
| 3912 | }
|
|---|
| 3913 | }
|
|---|
| 3914 |
|
|---|
| 3915 |
|
|---|
| 3916 | fprintf (f, "@echo off\n");
|
|---|
| 3917 | fprintf (f, "if NOT DEFINED CMTROOT set CMTROOT=%s& set PATH=%%CMTROOT%%\\%%CMTBIN%%;%%PATH%%& set CMTBIN=VisualC& if not defined CMTCONFIG set CMTCONFIG=%%CMTBIN%%\n", cmt_root.c_str ());
|
|---|
| 3918 | fprintf (f, "\n");
|
|---|
| 3919 | fprintf (f, "set cmttempfile=\"%%TEMP%%\\tmpsetup.bat\"\n");
|
|---|
| 3920 | fprintf (f, "%%CMTROOT%%\\%%CMTBIN%%\\cmt.exe %s -bat "
|
|---|
| 3921 | " -pack=%s -version=%s -path=%%~d0%%~p0%s "
|
|---|
| 3922 | " %s "
|
|---|
| 3923 | "%%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >%%cmttempfile%%\n",
|
|---|
| 3924 | action.c_str (),
|
|---|
| 3925 | package.c_str (),
|
|---|
| 3926 | version.c_str (),
|
|---|
| 3927 | no_device.c_str (),
|
|---|
| 3928 | option.c_str ());
|
|---|
| 3929 | fprintf (f, "if exist %%cmttempfile%% call %%cmttempfile%%\n");
|
|---|
| 3930 | fprintf (f, "if exist %%cmttempfile%% del %%cmttempfile%%\n");
|
|---|
| 3931 | fprintf (f, "set cmttempfile=\n");
|
|---|
| 3932 | }
|
|---|
| 3933 |
|
|---|
| 3934 | //----------------------------------------------------------
|
|---|
| 3935 | void Cmt::install_cleanup_scripts ()
|
|---|
| 3936 | {
|
|---|
| 3937 | #ifdef WIN32
|
|---|
| 3938 | static const int modes = 1;
|
|---|
| 3939 | static const cmt_string suffix[1] = {"bat"};
|
|---|
| 3940 | static const PrintMode mode[1] = {Bat};
|
|---|
| 3941 | #else
|
|---|
| 3942 | static const int modes = 2;
|
|---|
| 3943 | static const cmt_string suffix[2] = {"csh", "sh"};
|
|---|
| 3944 | static const PrintMode mode[2] = {Csh, Sh};
|
|---|
| 3945 | #endif
|
|---|
| 3946 |
|
|---|
| 3947 | cout << "Creating cleanup scripts." << endl;
|
|---|
| 3948 |
|
|---|
| 3949 | cmt_string temp;
|
|---|
| 3950 | int i;
|
|---|
| 3951 |
|
|---|
| 3952 | cmt_string version = m_current_version;
|
|---|
| 3953 | if (version == "v*") version = "";
|
|---|
| 3954 |
|
|---|
| 3955 | for (i = 0; i < modes; i++)
|
|---|
| 3956 | {
|
|---|
| 3957 | cmt_string file_name = "cleanup";
|
|---|
| 3958 | file_name += ".";
|
|---|
| 3959 | file_name += suffix[i];
|
|---|
| 3960 | file_name += ".";
|
|---|
| 3961 | file_name += "new";
|
|---|
| 3962 |
|
|---|
| 3963 | FILE* f = fopen (file_name.c_str (), "wb");
|
|---|
| 3964 | if (f != NULL)
|
|---|
| 3965 | {
|
|---|
| 3966 | if (mode[i] == Csh)
|
|---|
| 3967 | {
|
|---|
| 3968 | fprintf (f, "if ( $?CMTROOT == 0 ) then\n");
|
|---|
| 3969 | fprintf (f, " setenv CMTROOT %s\n", m_cmt_root.c_str ());
|
|---|
| 3970 | fprintf (f, "endif\n");
|
|---|
| 3971 | fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
|
|---|
| 3972 | fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 3973 | fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n");
|
|---|
| 3974 | fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s "
|
|---|
| 3975 | "-pack=%s -version=%s -path=%s $* >${tempfile}; "
|
|---|
| 3976 | "source ${tempfile}\n",
|
|---|
| 3977 | suffix[i].c_str (),
|
|---|
| 3978 | m_current_package.c_str (),
|
|---|
| 3979 | version.c_str (),
|
|---|
| 3980 | m_current_path.c_str ());
|
|---|
| 3981 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 3982 | }
|
|---|
| 3983 | else if (mode[i] == Sh)
|
|---|
| 3984 | {
|
|---|
| 3985 | fprintf (f, "if test \"${CMTROOT}\" = \"\"; then\n");
|
|---|
| 3986 | fprintf (f, " CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
|
|---|
| 3987 | fprintf (f, "fi\n");
|
|---|
| 3988 | fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
|
|---|
| 3989 | fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 3990 | fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
|
|---|
| 3991 | fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s "
|
|---|
| 3992 | "-pack=%s -version=%s -path=%s $* >${tempfile}; "
|
|---|
| 3993 | ". ${tempfile}\n",
|
|---|
| 3994 | suffix[i].c_str (),
|
|---|
| 3995 | m_current_package.c_str (),
|
|---|
| 3996 | version.c_str (),
|
|---|
| 3997 | m_current_path.c_str ());
|
|---|
| 3998 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 3999 | }
|
|---|
| 4000 | else if (mode[i] == Bat)
|
|---|
| 4001 | {
|
|---|
| 4002 | dos_script_prefix (f, m_cmt_root,
|
|---|
| 4003 | m_current_package, version, m_current_path,
|
|---|
| 4004 | "cleanup");
|
|---|
| 4005 | }
|
|---|
| 4006 |
|
|---|
| 4007 | fprintf (f, "\n");
|
|---|
| 4008 |
|
|---|
| 4009 | fclose (f);
|
|---|
| 4010 |
|
|---|
| 4011 | cmt_string old_file_name = "cleanup";
|
|---|
| 4012 | old_file_name += ".";
|
|---|
| 4013 | old_file_name += suffix[i];
|
|---|
| 4014 |
|
|---|
| 4015 | CmtSystem::compare_and_update_files (file_name, old_file_name);
|
|---|
| 4016 | }
|
|---|
| 4017 | }
|
|---|
| 4018 | }
|
|---|
| 4019 |
|
|---|
| 4020 | //----------------------------------------------------------
|
|---|
| 4021 | void Cmt::install_setup_scripts ()
|
|---|
| 4022 | {
|
|---|
| 4023 | #ifdef WIN32
|
|---|
| 4024 | static const int modes = 1;
|
|---|
| 4025 | static const cmt_string suffix[1] = {"bat"};
|
|---|
| 4026 | static const PrintMode mode[1] = {Bat};
|
|---|
| 4027 | #else
|
|---|
| 4028 | static const int modes = 2;
|
|---|
| 4029 | static const cmt_string suffix[2] = {"csh", "sh"};
|
|---|
| 4030 | static const PrintMode mode[2] = {Csh, Sh};
|
|---|
| 4031 | #endif
|
|---|
| 4032 |
|
|---|
| 4033 | cout << "Creating setup scripts." << endl;
|
|---|
| 4034 |
|
|---|
| 4035 |
|
|---|
| 4036 | cmt_string no_cleanup_opt;
|
|---|
| 4037 |
|
|---|
| 4038 | if ((get_setup_strategy () & SetupCleanupMask) != SetupCleanup)
|
|---|
| 4039 | {
|
|---|
| 4040 | no_cleanup_opt = " -no_cleanup";
|
|---|
| 4041 | }
|
|---|
| 4042 |
|
|---|
| 4043 | cmt_string temp;
|
|---|
| 4044 | int i;
|
|---|
| 4045 |
|
|---|
| 4046 | cmt_string version = m_current_version;
|
|---|
| 4047 | if (version == "v*") version = "";
|
|---|
| 4048 |
|
|---|
| 4049 | for (i = 0; i < modes; i++)
|
|---|
| 4050 | {
|
|---|
| 4051 | cmt_string file_name = "setup";
|
|---|
| 4052 | file_name += ".";
|
|---|
| 4053 | file_name += suffix[i];
|
|---|
| 4054 | file_name += ".";
|
|---|
| 4055 | file_name += "new";
|
|---|
| 4056 |
|
|---|
| 4057 | FILE* f = fopen (file_name.c_str (), "wb");
|
|---|
| 4058 | if (f != NULL)
|
|---|
| 4059 | {
|
|---|
| 4060 | if (mode[i] == Csh)
|
|---|
| 4061 | {
|
|---|
| 4062 | fprintf (f, "# echo \"Setting %s %s in %s\"\n",
|
|---|
| 4063 | m_current_package.c_str (),
|
|---|
| 4064 | version.c_str (),
|
|---|
| 4065 | m_current_path.c_str ());
|
|---|
| 4066 | fprintf (f, "\n");
|
|---|
| 4067 |
|
|---|
| 4068 | fprintf (f, "if ( $?CMTROOT == 0 ) then\n");
|
|---|
| 4069 | fprintf (f, " setenv CMTROOT %s\n", m_cmt_root.c_str ());
|
|---|
| 4070 | fprintf (f, "endif\n");
|
|---|
| 4071 | fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
|
|---|
| 4072 | fprintf (f, "\n");
|
|---|
| 4073 | fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 4074 | fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n");
|
|---|
| 4075 | fprintf (f, "${CMTROOT}/mgr/cmt setup -%s "
|
|---|
| 4076 | "-pack=%s -version=%s -path=%s %s $* >${tempfile}; "
|
|---|
| 4077 | "source ${tempfile}\n",
|
|---|
| 4078 | suffix[i].c_str (),
|
|---|
| 4079 | m_current_package.c_str (),
|
|---|
| 4080 | version.c_str (),
|
|---|
| 4081 | m_current_path.c_str (),
|
|---|
| 4082 | no_cleanup_opt.c_str ());
|
|---|
| 4083 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 4084 | }
|
|---|
| 4085 | else if (mode[i] == Sh)
|
|---|
| 4086 | {
|
|---|
| 4087 | fprintf (f, "# echo \"Setting %s %s in %s\"\n",
|
|---|
| 4088 | m_current_package.c_str (),
|
|---|
| 4089 | version.c_str (),
|
|---|
| 4090 | m_current_path.c_str ());
|
|---|
| 4091 | fprintf (f, "\n");
|
|---|
| 4092 |
|
|---|
| 4093 | fprintf (f, "if test \"${CMTROOT}\" = \"\"; then\n");
|
|---|
| 4094 | fprintf (f, " CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
|
|---|
| 4095 | fprintf (f, "fi\n");
|
|---|
| 4096 | fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
|
|---|
| 4097 | fprintf (f, "\n");
|
|---|
| 4098 | fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 4099 | fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
|
|---|
| 4100 | fprintf (f, "${CMTROOT}/mgr/cmt setup -%s "
|
|---|
| 4101 | "-pack=%s -version=%s -path=%s %s $* >${tempfile}; "
|
|---|
| 4102 | ". ${tempfile}\n",
|
|---|
| 4103 | suffix[i].c_str (),
|
|---|
| 4104 | m_current_package.c_str (),
|
|---|
| 4105 | version.c_str (),
|
|---|
| 4106 | m_current_path.c_str (),
|
|---|
| 4107 | no_cleanup_opt.c_str ());
|
|---|
| 4108 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 4109 | }
|
|---|
| 4110 | else if (mode[i] == Bat)
|
|---|
| 4111 | {
|
|---|
| 4112 | fprintf (f, "rem Setting %s %s in %%~d0%%~p0\n",
|
|---|
| 4113 | m_current_package.c_str (),
|
|---|
| 4114 | version.c_str ());
|
|---|
| 4115 | dos_script_prefix (f, m_cmt_root,
|
|---|
| 4116 | m_current_package, version, m_current_path,
|
|---|
| 4117 | "setup", no_cleanup_opt);
|
|---|
| 4118 | }
|
|---|
| 4119 |
|
|---|
| 4120 | fprintf (f, "\n");
|
|---|
| 4121 |
|
|---|
| 4122 | fclose (f);
|
|---|
| 4123 |
|
|---|
| 4124 | cmt_string old_file_name = "setup";
|
|---|
| 4125 | old_file_name += ".";
|
|---|
| 4126 | old_file_name += suffix[i];
|
|---|
| 4127 |
|
|---|
| 4128 | CmtSystem::compare_and_update_files (file_name, old_file_name);
|
|---|
| 4129 | }
|
|---|
| 4130 | }
|
|---|
| 4131 | }
|
|---|
| 4132 |
|
|---|
| 4133 | //----------------------------------------------------------
|
|---|
| 4134 | void Cmt::install_test_cleanup_scripts ()
|
|---|
| 4135 | {
|
|---|
| 4136 | #ifdef WIN32
|
|---|
| 4137 | static const int modes = 1;
|
|---|
| 4138 | static const cmt_string suffix[1] = {"bat"};
|
|---|
| 4139 | static const PrintMode mode[1] = {Bat};
|
|---|
| 4140 | #else
|
|---|
| 4141 | static const int modes = 2;
|
|---|
| 4142 | static const cmt_string suffix[2] = {"csh", "sh"};
|
|---|
| 4143 | static const PrintMode mode[2] = {Csh, Sh};
|
|---|
| 4144 | #endif
|
|---|
| 4145 |
|
|---|
| 4146 | cout << "Creating cleanup scripts." << endl;
|
|---|
| 4147 |
|
|---|
| 4148 | cmt_string temp;
|
|---|
| 4149 | int i;
|
|---|
| 4150 |
|
|---|
| 4151 | cmt_string version = m_current_version;
|
|---|
| 4152 | if (version == "v*") version = "";
|
|---|
| 4153 |
|
|---|
| 4154 | for (i = 0; i < modes; i++)
|
|---|
| 4155 | {
|
|---|
| 4156 | cmt_string file_name = "cleanup";
|
|---|
| 4157 | file_name += ".";
|
|---|
| 4158 | file_name += suffix[i];
|
|---|
| 4159 | file_name += ".";
|
|---|
| 4160 | file_name += "new";
|
|---|
| 4161 |
|
|---|
| 4162 | FILE* f = fopen (file_name.c_str (), "wb");
|
|---|
| 4163 | if (f != NULL)
|
|---|
| 4164 | {
|
|---|
| 4165 | if (mode[i] == Csh)
|
|---|
| 4166 | {
|
|---|
| 4167 | fprintf (f, "if ( $?CMTROOT == 0 ) then\n");
|
|---|
| 4168 | fprintf (f, " setenv CMTROOT %s\n", m_cmt_root.c_str ());
|
|---|
| 4169 | fprintf (f, "endif\n");
|
|---|
| 4170 | fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
|
|---|
| 4171 | fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 4172 | fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n");
|
|---|
| 4173 | fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}; "
|
|---|
| 4174 | "source ${tempfile}\n",
|
|---|
| 4175 | suffix[i].c_str (),
|
|---|
| 4176 | m_current_path.c_str ());
|
|---|
| 4177 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 4178 | }
|
|---|
| 4179 | else if (mode[i] == Sh)
|
|---|
| 4180 | {
|
|---|
| 4181 | fprintf (f, "if test \"${CMTROOT}\" = \"\"; then\n");
|
|---|
| 4182 | fprintf (f, " CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
|
|---|
| 4183 | fprintf (f, "fi\n");
|
|---|
| 4184 | fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
|
|---|
| 4185 | fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 4186 | fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
|
|---|
| 4187 | fprintf (f, "${CMTROOT}/mgr/cmt cleanup -%s -pack=cmt_standalone -path=%s $* >${tempfile}; "
|
|---|
| 4188 | ". ${tempfile}\n",
|
|---|
| 4189 | suffix[i].c_str (),
|
|---|
| 4190 | m_current_path.c_str ());
|
|---|
| 4191 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 4192 | }
|
|---|
| 4193 | else
|
|---|
| 4194 | {
|
|---|
| 4195 | dos_script_prefix (f, m_cmt_root,
|
|---|
| 4196 | "cmt_standalone", "", m_current_path,
|
|---|
| 4197 | "cleanup");
|
|---|
| 4198 | }
|
|---|
| 4199 |
|
|---|
| 4200 | fprintf (f, "\n");
|
|---|
| 4201 |
|
|---|
| 4202 | fclose (f);
|
|---|
| 4203 |
|
|---|
| 4204 | cmt_string old_file_name = "cleanup";
|
|---|
| 4205 | old_file_name += ".";
|
|---|
| 4206 | old_file_name += suffix[i];
|
|---|
| 4207 |
|
|---|
| 4208 | CmtSystem::compare_and_update_files (file_name, old_file_name);
|
|---|
| 4209 | }
|
|---|
| 4210 | }
|
|---|
| 4211 | }
|
|---|
| 4212 |
|
|---|
| 4213 | //----------------------------------------------------------
|
|---|
| 4214 | void Cmt::install_test_setup_scripts ()
|
|---|
| 4215 | {
|
|---|
| 4216 | #ifdef WIN32
|
|---|
| 4217 | static const int modes = 1;
|
|---|
| 4218 | static const cmt_string suffix[1] = {"bat"};
|
|---|
| 4219 | static const PrintMode mode[1] = {Bat};
|
|---|
| 4220 | #else
|
|---|
| 4221 | static const int modes = 2;
|
|---|
| 4222 | static const cmt_string suffix[2] = {"csh", "sh"};
|
|---|
| 4223 | static const PrintMode mode[2] = {Csh, Sh};
|
|---|
| 4224 | #endif
|
|---|
| 4225 |
|
|---|
| 4226 | cout << "Creating setup scripts." << endl;
|
|---|
| 4227 |
|
|---|
| 4228 | cmt_string no_cleanup_opt;
|
|---|
| 4229 |
|
|---|
| 4230 | if ((get_setup_strategy () & SetupCleanupMask) != SetupCleanup)
|
|---|
| 4231 | {
|
|---|
| 4232 | no_cleanup_opt = " -no_cleanup";
|
|---|
| 4233 | }
|
|---|
| 4234 |
|
|---|
| 4235 | cmt_string temp;
|
|---|
| 4236 | int i;
|
|---|
| 4237 |
|
|---|
| 4238 | for (i = 0; i < modes; i++)
|
|---|
| 4239 | {
|
|---|
| 4240 | cmt_string file_name = "setup";
|
|---|
| 4241 | file_name += ".";
|
|---|
| 4242 | file_name += suffix[i];
|
|---|
| 4243 | file_name += ".";
|
|---|
| 4244 | file_name += "new";
|
|---|
| 4245 |
|
|---|
| 4246 | FILE* f = fopen (file_name.c_str (), "wb");
|
|---|
| 4247 | if (f != NULL)
|
|---|
| 4248 | {
|
|---|
| 4249 | if (mode[i] == Csh)
|
|---|
| 4250 | {
|
|---|
| 4251 | fprintf (f, "# echo \"Setting standalone package\"\n");
|
|---|
| 4252 | fprintf (f, "\n");
|
|---|
| 4253 |
|
|---|
| 4254 | fprintf (f, "if ( $?CMTROOT == 0 ) then\n");
|
|---|
| 4255 | fprintf (f, " setenv CMTROOT %s\n", m_cmt_root.c_str ());
|
|---|
| 4256 | fprintf (f, "endif\n");
|
|---|
| 4257 | fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
|
|---|
| 4258 | fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 4259 | fprintf (f, "if $status != 0 then\n set tempfile=/tmp/cmt.$$\nendif\n");
|
|---|
| 4260 | fprintf (f, "${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}; "
|
|---|
| 4261 | "source ${tempfile}\n",
|
|---|
| 4262 | suffix[i].c_str (),
|
|---|
| 4263 | m_current_path.c_str (),
|
|---|
| 4264 | no_cleanup_opt.c_str ());
|
|---|
| 4265 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 4266 | }
|
|---|
| 4267 | else if (mode[i] == Sh)
|
|---|
| 4268 | {
|
|---|
| 4269 | fprintf (f, "# echo \"Setting standalone package\"\n");
|
|---|
| 4270 | fprintf (f, "\n");
|
|---|
| 4271 |
|
|---|
| 4272 | fprintf (f, "if test \"${CMTROOT}\" = \"\"; then\n");
|
|---|
| 4273 | fprintf (f, " CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
|
|---|
| 4274 | fprintf (f, "fi\n");
|
|---|
| 4275 | fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
|
|---|
| 4276 | fprintf (f, "\n");
|
|---|
| 4277 | fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n");
|
|---|
| 4278 | fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
|
|---|
| 4279 | fprintf (f, "${CMTROOT}/mgr/cmt setup -%s -pack=cmt_standalone -path=%s %s $* >${tempfile}; "
|
|---|
| 4280 | ". ${tempfile}\n",
|
|---|
| 4281 | suffix[i].c_str (),
|
|---|
| 4282 | m_current_path.c_str (),
|
|---|
| 4283 | no_cleanup_opt.c_str ());
|
|---|
| 4284 | fprintf (f, "/bin/rm -f ${tempfile}\n");
|
|---|
| 4285 | }
|
|---|
| 4286 | else
|
|---|
| 4287 | {
|
|---|
| 4288 | fprintf (f, "rem Setting standalone package\n");
|
|---|
| 4289 | dos_script_prefix (f, m_cmt_root,
|
|---|
| 4290 | "cmt_standalone", "", m_current_path,
|
|---|
| 4291 | "setup", no_cleanup_opt);
|
|---|
| 4292 | }
|
|---|
| 4293 |
|
|---|
| 4294 | fprintf (f, "\n");
|
|---|
| 4295 |
|
|---|
| 4296 | fclose (f);
|
|---|
| 4297 |
|
|---|
| 4298 | cmt_string old_file_name = "setup";
|
|---|
| 4299 | old_file_name += ".";
|
|---|
| 4300 | old_file_name += suffix[i];
|
|---|
| 4301 |
|
|---|
| 4302 | CmtSystem::compare_and_update_files (file_name, old_file_name);
|
|---|
| 4303 | }
|
|---|
| 4304 | }
|
|---|
| 4305 | }
|
|---|
| 4306 |
|
|---|
| 4307 | /**
|
|---|
| 4308 | * load is only called from the Windows GUI which pretends to access directly
|
|---|
| 4309 | * the internal data model.
|
|---|
| 4310 | * This is considered to be rather unsafe, and should be replaced by query functions.
|
|---|
| 4311 | */
|
|---|
| 4312 | bool Cmt::load (const cmt_string& path,
|
|---|
| 4313 | const cmt_string& package,
|
|---|
| 4314 | const cmt_string& version,
|
|---|
| 4315 | const cmt_string& tag_name)
|
|---|
| 4316 | {
|
|---|
| 4317 | clear ();
|
|---|
| 4318 | configure ();
|
|---|
| 4319 |
|
|---|
| 4320 | m_action = action_load;
|
|---|
| 4321 | m_recursive = true;
|
|---|
| 4322 |
|
|---|
| 4323 | if (((package != "") && (version != "")) || (m_current_package == ""))
|
|---|
| 4324 | {
|
|---|
| 4325 | //
|
|---|
| 4326 | // Here we want to connect to a new package, or to the current package
|
|---|
| 4327 | // but with another tag.
|
|---|
| 4328 | //
|
|---|
| 4329 | // the 'package' argument may include a directory offset. Thus 'path'
|
|---|
| 4330 | // is only expected to hold the base directory.
|
|---|
| 4331 | //
|
|---|
| 4332 | cmt_string offset;
|
|---|
| 4333 | cmt_string package_name;
|
|---|
| 4334 |
|
|---|
| 4335 | CmtSystem::dirname (package, offset);
|
|---|
| 4336 | CmtSystem::basename (package, package_name);
|
|---|
| 4337 |
|
|---|
| 4338 | if (offset != "")
|
|---|
| 4339 | {
|
|---|
| 4340 | m_current_path = path;
|
|---|
| 4341 | m_current_path += CmtSystem::file_separator ();
|
|---|
| 4342 | m_current_path += offset;
|
|---|
| 4343 | }
|
|---|
| 4344 | else
|
|---|
| 4345 | {
|
|---|
| 4346 | m_current_path = path;
|
|---|
| 4347 | }
|
|---|
| 4348 |
|
|---|
| 4349 | m_current_package = package_name;
|
|---|
| 4350 | m_current_version = version;
|
|---|
| 4351 | }
|
|---|
| 4352 |
|
|---|
| 4353 | if (tag_name != "")
|
|---|
| 4354 | {
|
|---|
| 4355 | Tag* tag;
|
|---|
| 4356 |
|
|---|
| 4357 | Tag::unmark_all ();
|
|---|
| 4358 | configure_version_tag ();
|
|---|
| 4359 | configure_site_tag (0);
|
|---|
| 4360 | configure_uname_tag ();
|
|---|
| 4361 | configure_hosttype_tag ();
|
|---|
| 4362 |
|
|---|
| 4363 | m_current_tag = tag_name;
|
|---|
| 4364 |
|
|---|
| 4365 | //if (!m_quiet) cerr << "load1> current_tag=" << m_current_tag << endl;
|
|---|
| 4366 |
|
|---|
| 4367 | tag = Tag::add (tag_name, PriorityTag, "load", 0);
|
|---|
| 4368 | tag->mark ();
|
|---|
| 4369 | }
|
|---|
| 4370 |
|
|---|
| 4371 | /*
|
|---|
| 4372 | Set to developer mode if positioned into the package
|
|---|
| 4373 | (which is detected since we were able to retreive the
|
|---|
| 4374 | Version, Package and Path)
|
|---|
| 4375 | */
|
|---|
| 4376 |
|
|---|
| 4377 | if ((m_current_path == "") ||
|
|---|
| 4378 | (m_current_package == "") ||
|
|---|
| 4379 | (m_current_version == ""))
|
|---|
| 4380 | {
|
|---|
| 4381 | m_current_access = UserMode;
|
|---|
| 4382 | }
|
|---|
| 4383 | else
|
|---|
| 4384 | {
|
|---|
| 4385 | m_current_access = DeveloperMode;
|
|---|
| 4386 | }
|
|---|
| 4387 |
|
|---|
| 4388 | use_cmt ();
|
|---|
| 4389 |
|
|---|
| 4390 | cmt_string dir;
|
|---|
| 4391 |
|
|---|
| 4392 | /*
|
|---|
| 4393 | Try to access the package.
|
|---|
| 4394 | */
|
|---|
| 4395 |
|
|---|
| 4396 | if (m_current_path != "")
|
|---|
| 4397 | {
|
|---|
| 4398 | dir = m_current_path;
|
|---|
| 4399 | }
|
|---|
| 4400 | else
|
|---|
| 4401 | {
|
|---|
| 4402 | dir = m_default_path;
|
|---|
| 4403 | }
|
|---|
| 4404 |
|
|---|
| 4405 | if (!CmtSystem::cd (m_current_path))
|
|---|
| 4406 | {
|
|---|
| 4407 | if (!m_quiet)
|
|---|
| 4408 | {
|
|---|
| 4409 | cerr << "#CMT> Cannot reach the directory " <<
|
|---|
| 4410 | m_current_path << endl;
|
|---|
| 4411 | }
|
|---|
| 4412 | CmtError::set (CmtError::package_not_found, "Load> Cannot reach the path directory");
|
|---|
| 4413 | CmtSystem::cd (m_current_dir);
|
|---|
| 4414 |
|
|---|
| 4415 | return (false);
|
|---|
| 4416 | }
|
|---|
| 4417 |
|
|---|
| 4418 | dir += CmtSystem::file_separator ();
|
|---|
| 4419 | dir += m_current_package;
|
|---|
| 4420 |
|
|---|
| 4421 | if (!CmtSystem::cd (m_current_package))
|
|---|
| 4422 | {
|
|---|
| 4423 | if (!m_quiet)
|
|---|
| 4424 | {
|
|---|
| 4425 | cerr << "#CMT::load> Cannot reach the package " <<
|
|---|
| 4426 | m_current_package << endl;
|
|---|
| 4427 | }
|
|---|
| 4428 | CmtError::set (CmtError::package_not_found, "Load> Cannot reach the package directory");
|
|---|
| 4429 | CmtSystem::cd (m_current_dir);
|
|---|
| 4430 |
|
|---|
| 4431 | return (false);
|
|---|
| 4432 | }
|
|---|
| 4433 |
|
|---|
| 4434 | dir += CmtSystem::file_separator ();
|
|---|
| 4435 | dir += m_current_version;
|
|---|
| 4436 |
|
|---|
| 4437 | m_current_style = none_style;
|
|---|
| 4438 |
|
|---|
| 4439 | if (!CmtSystem::cd (m_current_version))
|
|---|
| 4440 | {
|
|---|
| 4441 | if (!CmtSystem::test_directory ("cmt"))
|
|---|
| 4442 | {
|
|---|
| 4443 | if (!m_quiet)
|
|---|
| 4444 | {
|
|---|
| 4445 | cerr << "#CMT> Cannot reach the version " <<
|
|---|
| 4446 | m_current_version << endl;
|
|---|
| 4447 | }
|
|---|
| 4448 | CmtError::set (CmtError::package_not_found, "Load> Cannot reach the version directory");
|
|---|
| 4449 | CmtSystem::cd (m_current_dir);
|
|---|
| 4450 |
|
|---|
| 4451 | return (false);
|
|---|
| 4452 | }
|
|---|
| 4453 | else
|
|---|
| 4454 | {
|
|---|
| 4455 | m_current_style = no_version_style;
|
|---|
| 4456 | }
|
|---|
| 4457 | }
|
|---|
| 4458 |
|
|---|
| 4459 | if (CmtSystem::cd ("cmt"))
|
|---|
| 4460 | {
|
|---|
| 4461 | dir += CmtSystem::file_separator ();
|
|---|
| 4462 | dir += "cmt";
|
|---|
| 4463 | if (m_current_style == none_style) m_current_style = cmt_style;
|
|---|
| 4464 | }
|
|---|
| 4465 | else
|
|---|
| 4466 | {
|
|---|
| 4467 | /*
|
|---|
| 4468 | if (!m_quiet)
|
|---|
| 4469 | {
|
|---|
| 4470 | cerr << "Cannot reach the cmt branch" << endl;
|
|---|
| 4471 | }
|
|---|
| 4472 | */
|
|---|
| 4473 |
|
|---|
| 4474 | if (CmtSystem::cd ("mgr"))
|
|---|
| 4475 | {
|
|---|
| 4476 | dir += CmtSystem::file_separator ();
|
|---|
| 4477 | dir += "mgr";
|
|---|
| 4478 | if (m_current_style == none_style) m_current_style = mgr_style;
|
|---|
| 4479 | }
|
|---|
| 4480 | else
|
|---|
| 4481 | {
|
|---|
| 4482 | if (!m_quiet)
|
|---|
| 4483 | {
|
|---|
| 4484 | cerr << "#CMT> Cannot reach the mgr branch" << endl;
|
|---|
| 4485 | }
|
|---|
| 4486 |
|
|---|
| 4487 | CmtError::set (CmtError::package_not_found,
|
|---|
| 4488 | "Load> Cannot reach the mgr/cmt directory");
|
|---|
| 4489 | CmtSystem::cd (m_current_dir);
|
|---|
| 4490 |
|
|---|
| 4491 | return (false);
|
|---|
| 4492 | }
|
|---|
| 4493 | }
|
|---|
| 4494 |
|
|---|
| 4495 | /*
|
|---|
| 4496 | Check Tag is always set up
|
|---|
| 4497 | */
|
|---|
| 4498 |
|
|---|
| 4499 | if (m_current_tag == "")
|
|---|
| 4500 | {
|
|---|
| 4501 | char* env;
|
|---|
| 4502 |
|
|---|
| 4503 | env = getenv (m_current_config.c_str ());
|
|---|
| 4504 | if (env != 0)
|
|---|
| 4505 | {
|
|---|
| 4506 | Tag* tag;
|
|---|
| 4507 |
|
|---|
| 4508 | tag = Tag::add (env, PriorityConfig, "load", 0);
|
|---|
| 4509 | tag->mark ();
|
|---|
| 4510 | m_current_tag = env;
|
|---|
| 4511 |
|
|---|
| 4512 | //if (!m_quiet) cerr << "load2> current_tag=" << m_current_tag << endl;
|
|---|
| 4513 |
|
|---|
| 4514 | }
|
|---|
| 4515 | else
|
|---|
| 4516 | {
|
|---|
| 4517 | m_current_tag = m_cmt_config;
|
|---|
| 4518 |
|
|---|
| 4519 | //if (!m_quiet) cerr << "load3> current_tag=" << m_current_tag << endl;
|
|---|
| 4520 |
|
|---|
| 4521 | }
|
|---|
| 4522 | }
|
|---|
| 4523 |
|
|---|
| 4524 | if (m_debug)
|
|---|
| 4525 | {
|
|---|
| 4526 | cout << "pwd = " << CmtSystem::pwd () << endl;
|
|---|
| 4527 | }
|
|---|
| 4528 |
|
|---|
| 4529 | configure_current_dir ();
|
|---|
| 4530 | build_prefix (m_current_package, m_current_prefix);
|
|---|
| 4531 | build_config (m_current_prefix, m_current_config);
|
|---|
| 4532 |
|
|---|
| 4533 | Use* use = &(Use::current());
|
|---|
| 4534 | use->path = m_current_path;
|
|---|
| 4535 | use->set_package_name (m_current_package);
|
|---|
| 4536 | use->version = m_current_version;
|
|---|
| 4537 | use->prefix = m_current_prefix;
|
|---|
| 4538 | use->done = false;
|
|---|
| 4539 | use->style = m_current_style;
|
|---|
| 4540 |
|
|---|
| 4541 | /*
|
|---|
| 4542 | Work on the requirements file.
|
|---|
| 4543 | */
|
|---|
| 4544 |
|
|---|
| 4545 | dir += CmtSystem::file_separator ();
|
|---|
| 4546 | dir += "requirements";
|
|---|
| 4547 | SyntaxParser::parse_requirements (dir, use);
|
|---|
| 4548 |
|
|---|
| 4549 | if (CmtError::has_pending_error ()) return (false);
|
|---|
| 4550 |
|
|---|
| 4551 | /**
|
|---|
| 4552 | * See reach_current_package for an explanation of this call
|
|---|
| 4553 | */
|
|---|
| 4554 | Pattern::apply_all_globals ();
|
|---|
| 4555 |
|
|---|
| 4556 | /*
|
|---|
| 4557 | Select all possible tags
|
|---|
| 4558 | */
|
|---|
| 4559 |
|
|---|
| 4560 | Tag::restore_tree ();
|
|---|
| 4561 |
|
|---|
| 4562 | return (true);
|
|---|
| 4563 | }
|
|---|
| 4564 |
|
|---|
| 4565 | //----------------------------------------------------------
|
|---|
| 4566 | bool Cmt::need_prototypes ()
|
|---|
| 4567 | {
|
|---|
| 4568 | if ((get_build_strategy () & PrototypesMask) == Prototypes) return (true);
|
|---|
| 4569 | else return (false);
|
|---|
| 4570 | }
|
|---|
| 4571 |
|
|---|
| 4572 | //----------------------------------------------------------
|
|---|
| 4573 | void Cmt::parse_arguments (int argc, char* argv[],
|
|---|
| 4574 | CmtSystem::cmt_string_vector& arguments,
|
|---|
| 4575 | cmt_string& extra_line,
|
|---|
| 4576 | cmt_string& extra_file,
|
|---|
| 4577 | PrintMode& mode)
|
|---|
| 4578 | {
|
|---|
| 4579 | /*
|
|---|
| 4580 | Decoding arguments.
|
|---|
| 4581 |
|
|---|
| 4582 | While decoding all arguments, no requirements analysis should
|
|---|
| 4583 | occur. Every new option, or parameter should be saved and
|
|---|
| 4584 | used later at actual analysis time.
|
|---|
| 4585 | */
|
|---|
| 4586 |
|
|---|
| 4587 | cmt_string arg;
|
|---|
| 4588 |
|
|---|
| 4589 | m_action = action_none;
|
|---|
| 4590 | m_help_action = action_none;
|
|---|
| 4591 |
|
|---|
| 4592 | arguments.clear ();
|
|---|
| 4593 | extra_line.erase (0);
|
|---|
| 4594 | extra_file.erase (0);
|
|---|
| 4595 | mode = Csh;
|
|---|
| 4596 |
|
|---|
| 4597 | /*
|
|---|
| 4598 | Tag management.
|
|---|
| 4599 | ---------------
|
|---|
| 4600 |
|
|---|
| 4601 | Tag settings may come from :
|
|---|
| 4602 |
|
|---|
| 4603 | - existing environment variables:
|
|---|
| 4604 |
|
|---|
| 4605 | 1) CMTCONFIG
|
|---|
| 4606 |
|
|---|
| 4607 | 2) CMTEXTRATAGS for addons
|
|---|
| 4608 |
|
|---|
| 4609 | - arguments:
|
|---|
| 4610 |
|
|---|
| 4611 | -tag=<tag-list>
|
|---|
| 4612 | -tag_add=<tag-list>
|
|---|
| 4613 | -tag_remove=<tag-list>
|
|---|
| 4614 |
|
|---|
| 4615 | o Arguments should take precedence over environment variables.
|
|---|
| 4616 | o when nothing is specified:
|
|---|
| 4617 |
|
|---|
| 4618 | - primary tag = CMTCONFIG
|
|---|
| 4619 | - tag set is empty
|
|---|
| 4620 |
|
|---|
| 4621 |
|
|---|
| 4622 | */
|
|---|
| 4623 |
|
|---|
| 4624 |
|
|---|
| 4625 | restore_all_tags (0);
|
|---|
| 4626 |
|
|---|
| 4627 | #ifdef WIN32
|
|---|
| 4628 | m_build_nmake = true;
|
|---|
| 4629 | #endif
|
|---|
| 4630 |
|
|---|
| 4631 | while (argc > 1)
|
|---|
| 4632 | {
|
|---|
| 4633 | int lf;
|
|---|
| 4634 |
|
|---|
| 4635 | arg = argv[1];
|
|---|
| 4636 | lf = arg.find ('\r');
|
|---|
| 4637 | if (lf != cmt_string::npos) arg.erase (lf);
|
|---|
| 4638 |
|
|---|
| 4639 | if ((arg[0] == '\"') && (arg[arg.size () - 1] == '\"'))
|
|---|
| 4640 | {
|
|---|
| 4641 | arg.erase (0, 1);
|
|---|
| 4642 | arg.erase (arg.size () - 1, 1);
|
|---|
| 4643 | }
|
|---|
| 4644 |
|
|---|
| 4645 | //fprintf (stderr, "arg=[%s]\n", arg.c_str ());
|
|---|
| 4646 |
|
|---|
| 4647 | switch (arg[0])
|
|---|
| 4648 | {
|
|---|
| 4649 | case 'a' :
|
|---|
| 4650 | if (arg == "awk")
|
|---|
| 4651 | {
|
|---|
| 4652 | argc--;
|
|---|
| 4653 | argv++;
|
|---|
| 4654 | while (argc > 1)
|
|---|
| 4655 | {
|
|---|
| 4656 | cmt_string& s = arguments.add ();
|
|---|
| 4657 | s = argv[1];
|
|---|
| 4658 | argc--;
|
|---|
| 4659 | argv++;
|
|---|
| 4660 | }
|
|---|
| 4661 |
|
|---|
| 4662 | m_action = action_awk;
|
|---|
| 4663 | }
|
|---|
| 4664 | break;
|
|---|
| 4665 | case 'b' :
|
|---|
| 4666 | if ((arg == "b") ||
|
|---|
| 4667 | (arg == "br") ||
|
|---|
| 4668 | (arg == "bro") ||
|
|---|
| 4669 | (arg == "broa") ||
|
|---|
| 4670 | (arg == "broad") ||
|
|---|
| 4671 | (arg == "broadc") ||
|
|---|
| 4672 | (arg == "broadca") ||
|
|---|
| 4673 | (arg == "broadcas") ||
|
|---|
| 4674 | (arg == "broadcast"))
|
|---|
| 4675 | {
|
|---|
| 4676 | argc--;
|
|---|
| 4677 | argv++;
|
|---|
| 4678 | while (argc > 1)
|
|---|
| 4679 | {
|
|---|
| 4680 | cmt_string& s = arguments.add ();
|
|---|
| 4681 | s = argv[1];
|
|---|
| 4682 | argc--;
|
|---|
| 4683 | argv++;
|
|---|
| 4684 | }
|
|---|
| 4685 |
|
|---|
| 4686 | m_action = action_broadcast;
|
|---|
| 4687 |
|
|---|
| 4688 | if (m_scope_filtering_mode == default_filtering_mode)
|
|---|
| 4689 | {
|
|---|
| 4690 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 4691 | }
|
|---|
| 4692 | }
|
|---|
| 4693 | else if (arg == "build")
|
|---|
| 4694 | {
|
|---|
| 4695 | argc--;
|
|---|
| 4696 | argv++;
|
|---|
| 4697 |
|
|---|
| 4698 | if (argc > 1)
|
|---|
| 4699 | {
|
|---|
| 4700 | arg = argv[1];
|
|---|
| 4701 |
|
|---|
| 4702 | if (arg == "-nmake")
|
|---|
| 4703 | {
|
|---|
| 4704 | m_build_nmake = true;
|
|---|
| 4705 | argc--;
|
|---|
| 4706 | argv++;
|
|---|
| 4707 | }
|
|---|
| 4708 | }
|
|---|
| 4709 |
|
|---|
| 4710 | if (argc > 1)
|
|---|
| 4711 | {
|
|---|
| 4712 | arg = argv[1];
|
|---|
| 4713 |
|
|---|
| 4714 | if (arg == "-nmake")
|
|---|
| 4715 | {
|
|---|
| 4716 | argc--;
|
|---|
| 4717 | argv++;
|
|---|
| 4718 | }
|
|---|
| 4719 |
|
|---|
| 4720 | if (arg == "constituent_makefile")
|
|---|
| 4721 | {
|
|---|
| 4722 | argc--;
|
|---|
| 4723 | argv++;
|
|---|
| 4724 | if (argc > 1)
|
|---|
| 4725 | {
|
|---|
| 4726 | cmt_string& s = arguments.add ();
|
|---|
| 4727 | s = argv[1];
|
|---|
| 4728 |
|
|---|
| 4729 | m_action = action_build_constituent_makefile;
|
|---|
| 4730 | }
|
|---|
| 4731 | else
|
|---|
| 4732 | {
|
|---|
| 4733 | if (!m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
|
|---|
| 4734 | m_action = action_build_constituent_makefile;
|
|---|
| 4735 | m_help_action = action_help;
|
|---|
| 4736 | }
|
|---|
| 4737 | }
|
|---|
| 4738 | else if (arg == "constituents_makefile")
|
|---|
| 4739 | {
|
|---|
| 4740 | argc--;
|
|---|
| 4741 | argv++;
|
|---|
| 4742 | while (argc > 1)
|
|---|
| 4743 | {
|
|---|
| 4744 | cmt_string& s = arguments.add ();
|
|---|
| 4745 | s = argv[1];
|
|---|
| 4746 | argc--;
|
|---|
| 4747 | argv++;
|
|---|
| 4748 | }
|
|---|
| 4749 |
|
|---|
| 4750 | m_action = action_build_constituents_makefile;
|
|---|
| 4751 | }
|
|---|
| 4752 | else if (arg == "dependencies")
|
|---|
| 4753 | {
|
|---|
| 4754 | argc--;
|
|---|
| 4755 | argv++;
|
|---|
| 4756 | if (argc > 1)
|
|---|
| 4757 | {
|
|---|
| 4758 | cmt_string& s = arguments.add ();
|
|---|
| 4759 | s = argv[1];
|
|---|
| 4760 |
|
|---|
| 4761 | m_action = action_build_dependencies;
|
|---|
| 4762 | }
|
|---|
| 4763 | else
|
|---|
| 4764 | {
|
|---|
| 4765 | if (!m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
|
|---|
| 4766 | m_help_action = action_help;
|
|---|
| 4767 | m_action = action_build_dependencies;
|
|---|
| 4768 | }
|
|---|
| 4769 |
|
|---|
| 4770 | argc = 0;
|
|---|
| 4771 | }
|
|---|
| 4772 | else if (arg == "library_links")
|
|---|
| 4773 | {
|
|---|
| 4774 | m_action = action_build_library_links;
|
|---|
| 4775 | }
|
|---|
| 4776 | else if (arg == "make_setup")
|
|---|
| 4777 | {
|
|---|
| 4778 | m_action = action_build_make_setup;
|
|---|
| 4779 | }
|
|---|
| 4780 | else if (arg == "msdev")
|
|---|
| 4781 | {
|
|---|
| 4782 | argc--;
|
|---|
| 4783 | argv++;
|
|---|
| 4784 |
|
|---|
| 4785 | if (argc > 1)
|
|---|
| 4786 | {
|
|---|
| 4787 | cmt_string& s = arguments.add ();
|
|---|
| 4788 | s = argv[1];
|
|---|
| 4789 | if (s[0] == '-')
|
|---|
| 4790 | {
|
|---|
| 4791 | s = "";
|
|---|
| 4792 | argc++;
|
|---|
| 4793 | argv--;
|
|---|
| 4794 | }
|
|---|
| 4795 | }
|
|---|
| 4796 |
|
|---|
| 4797 | m_action = action_build_msdev;
|
|---|
| 4798 | }
|
|---|
| 4799 | else if (arg == "CMT_pacman")
|
|---|
| 4800 | {
|
|---|
| 4801 | m_action = action_build_CMT_pacman;
|
|---|
| 4802 | }
|
|---|
| 4803 | else if (arg == "vsnet")
|
|---|
| 4804 | {
|
|---|
| 4805 | argc--;
|
|---|
| 4806 | argv++;
|
|---|
| 4807 |
|
|---|
| 4808 | if (argc > 1)
|
|---|
| 4809 | {
|
|---|
| 4810 | cmt_string& s = arguments.add ();
|
|---|
| 4811 | s = argv[1];
|
|---|
| 4812 | if (s[0] == '-')
|
|---|
| 4813 | {
|
|---|
| 4814 | s = "";
|
|---|
| 4815 | argc++;
|
|---|
| 4816 | argv--;
|
|---|
| 4817 | }
|
|---|
| 4818 | }
|
|---|
| 4819 |
|
|---|
| 4820 | m_action = action_build_vsnet;
|
|---|
| 4821 | }
|
|---|
| 4822 | else if (arg == "os9_makefile")
|
|---|
| 4823 | {
|
|---|
| 4824 | argc--;
|
|---|
| 4825 | argv++;
|
|---|
| 4826 | if (argc > 1)
|
|---|
| 4827 | {
|
|---|
| 4828 | cmt_string& s = arguments.add ();
|
|---|
| 4829 | s = argv[1];
|
|---|
| 4830 |
|
|---|
| 4831 | m_action = action_build_os9_makefile;
|
|---|
| 4832 | }
|
|---|
| 4833 | else
|
|---|
| 4834 | {
|
|---|
| 4835 | if (!m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
|
|---|
| 4836 | m_help_action = action_help;
|
|---|
| 4837 | m_action = action_build_os9_makefile;
|
|---|
| 4838 | }
|
|---|
| 4839 | }
|
|---|
| 4840 | else if (arg == "prototype")
|
|---|
| 4841 | {
|
|---|
| 4842 | argc--;
|
|---|
| 4843 | argv++;
|
|---|
| 4844 | if (argc > 1)
|
|---|
| 4845 | {
|
|---|
| 4846 | cmt_string& s = arguments.add ();
|
|---|
| 4847 | s = argv[1];
|
|---|
| 4848 |
|
|---|
| 4849 | m_action = action_build_prototype;
|
|---|
| 4850 | }
|
|---|
| 4851 | else
|
|---|
| 4852 | {
|
|---|
| 4853 | if (!m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
|
|---|
| 4854 | m_help_action = action_help;
|
|---|
| 4855 | m_action = action_build_prototype;
|
|---|
| 4856 | }
|
|---|
| 4857 | }
|
|---|
| 4858 | else if (arg == "readme")
|
|---|
| 4859 | {
|
|---|
| 4860 | m_action = action_build_readme;
|
|---|
| 4861 |
|
|---|
| 4862 | argc--;
|
|---|
| 4863 | argv++;
|
|---|
| 4864 | while (argc > 1)
|
|---|
| 4865 | {
|
|---|
| 4866 | cmt_string& s = arguments.add ();
|
|---|
| 4867 | s = argv[1];
|
|---|
| 4868 | argc--;
|
|---|
| 4869 | argv++;
|
|---|
| 4870 | }
|
|---|
| 4871 | }
|
|---|
| 4872 | else if (arg == "tag_makefile")
|
|---|
| 4873 | {
|
|---|
| 4874 | m_action = action_build_tag_makefile;
|
|---|
| 4875 | }
|
|---|
| 4876 | else if (arg == "temporary_name")
|
|---|
| 4877 | {
|
|---|
| 4878 | m_action = action_build_temporary_name;
|
|---|
| 4879 | }
|
|---|
| 4880 | else if (arg == "triggers")
|
|---|
| 4881 | {
|
|---|
| 4882 | argc--;
|
|---|
| 4883 | argv++;
|
|---|
| 4884 | if (argc > 1)
|
|---|
| 4885 | {
|
|---|
| 4886 | cmt_string& s = arguments.add ();
|
|---|
| 4887 | s = argv[1];
|
|---|
| 4888 |
|
|---|
| 4889 | m_action = action_build_triggers;
|
|---|
| 4890 | }
|
|---|
| 4891 | else
|
|---|
| 4892 | {
|
|---|
| 4893 | if (!m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
|
|---|
| 4894 | m_help_action = action_help;
|
|---|
| 4895 | m_action = action_build_triggers;
|
|---|
| 4896 | }
|
|---|
| 4897 | }
|
|---|
| 4898 | else if (arg == "windefs")
|
|---|
| 4899 | {
|
|---|
| 4900 | argc--;
|
|---|
| 4901 | argv++;
|
|---|
| 4902 | if (argc > 1)
|
|---|
| 4903 | {
|
|---|
| 4904 | cmt_string& s = arguments.add ();
|
|---|
| 4905 | s = argv[1];
|
|---|
| 4906 |
|
|---|
| 4907 | m_action = action_build_windefs;
|
|---|
| 4908 | }
|
|---|
| 4909 | else
|
|---|
| 4910 | {
|
|---|
| 4911 | if (!m_quiet) cerr << "#CMT> syntax error : arguments missing" << endl;
|
|---|
| 4912 | m_help_action = action_help;
|
|---|
| 4913 | m_action = action_build_windefs;
|
|---|
| 4914 | }
|
|---|
| 4915 | }
|
|---|
| 4916 | else
|
|---|
| 4917 | {
|
|---|
| 4918 | if (!m_quiet) cerr << "#CMT> syntax error : wrong argument" << endl;
|
|---|
| 4919 | m_help_action = action_help;
|
|---|
| 4920 | m_action = action_build;
|
|---|
| 4921 | }
|
|---|
| 4922 | }
|
|---|
| 4923 | else
|
|---|
| 4924 | {
|
|---|
| 4925 | if (!m_quiet) cerr << "#CMT> syntax error : don't know what to build" << endl;
|
|---|
| 4926 | m_help_action = action_help;
|
|---|
| 4927 | m_action = action_build;
|
|---|
| 4928 | }
|
|---|
| 4929 | }
|
|---|
| 4930 | else
|
|---|
| 4931 | {
|
|---|
| 4932 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 4933 | m_help_action = action_help;
|
|---|
| 4934 | }
|
|---|
| 4935 | break;
|
|---|
| 4936 | case 'c' :
|
|---|
| 4937 | if (arg == "check")
|
|---|
| 4938 | {
|
|---|
| 4939 | argc--;
|
|---|
| 4940 | argv++;
|
|---|
| 4941 |
|
|---|
| 4942 | if (argc > 1)
|
|---|
| 4943 | {
|
|---|
| 4944 | arg = argv[1];
|
|---|
| 4945 |
|
|---|
| 4946 | if (arg == "configuration")
|
|---|
| 4947 | {
|
|---|
| 4948 | m_action = action_check_configuration;
|
|---|
| 4949 | }
|
|---|
| 4950 | else if (arg == "files")
|
|---|
| 4951 | {
|
|---|
| 4952 | argc--;
|
|---|
| 4953 | argv++;
|
|---|
| 4954 | if (argc > 1)
|
|---|
| 4955 | {
|
|---|
| 4956 | cmt_string& s = arguments.add ();
|
|---|
| 4957 | s = argv[1];
|
|---|
| 4958 | argc--;
|
|---|
| 4959 | argv++;
|
|---|
| 4960 | if (argc > 1)
|
|---|
| 4961 | {
|
|---|
| 4962 | cmt_string& s = arguments.add ();
|
|---|
| 4963 | s = argv[1];
|
|---|
| 4964 |
|
|---|
| 4965 | m_action = action_check_files;
|
|---|
| 4966 | }
|
|---|
| 4967 | else
|
|---|
| 4968 | {
|
|---|
| 4969 | if (!m_quiet) cerr << "#CMT> syntax error : reference file name missing"
|
|---|
| 4970 | << endl;
|
|---|
| 4971 | m_help_action = action_help;
|
|---|
| 4972 | m_action = action_check_files;
|
|---|
| 4973 | }
|
|---|
| 4974 | }
|
|---|
| 4975 | else
|
|---|
| 4976 | {
|
|---|
| 4977 | if (!m_quiet) cerr << "#CMT> syntax error : file name missing" << endl;
|
|---|
| 4978 | m_help_action = action_help;
|
|---|
| 4979 | m_action = action_check_files;
|
|---|
| 4980 | }
|
|---|
| 4981 | }
|
|---|
| 4982 | else if (arg == "version")
|
|---|
| 4983 | {
|
|---|
| 4984 | argc--;
|
|---|
| 4985 | argv++;
|
|---|
| 4986 | if (argc > 1)
|
|---|
| 4987 | {
|
|---|
| 4988 | cmt_string& s = arguments.add ();
|
|---|
| 4989 | s = argv[1];
|
|---|
| 4990 |
|
|---|
| 4991 | m_action = action_check_version;
|
|---|
| 4992 | }
|
|---|
| 4993 | else
|
|---|
| 4994 | {
|
|---|
| 4995 | if (!m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
|
|---|
| 4996 | m_help_action = action_help;
|
|---|
| 4997 | m_action = action_check_version;
|
|---|
| 4998 | }
|
|---|
| 4999 | }
|
|---|
| 5000 | else
|
|---|
| 5001 | {
|
|---|
| 5002 | if (!m_quiet) cerr << "#CMT> syntax error : bad check option" << endl;
|
|---|
| 5003 | m_help_action = action_help;
|
|---|
| 5004 | m_action = action_check;
|
|---|
| 5005 | }
|
|---|
| 5006 | }
|
|---|
| 5007 | else
|
|---|
| 5008 | {
|
|---|
| 5009 | if (!m_quiet) cerr << "#CMT> syntax error : don't know what to check" << endl;
|
|---|
| 5010 | m_help_action = action_help;
|
|---|
| 5011 | m_action = action_check;
|
|---|
| 5012 | }
|
|---|
| 5013 | }
|
|---|
| 5014 | else if (arg == "check_files")
|
|---|
| 5015 | {
|
|---|
| 5016 | argc--;
|
|---|
| 5017 | argv++;
|
|---|
| 5018 | if (argc > 1)
|
|---|
| 5019 | {
|
|---|
| 5020 | cmt_string& s = arguments.add ();
|
|---|
| 5021 | s = argv[1];
|
|---|
| 5022 | argc--;
|
|---|
| 5023 | argv++;
|
|---|
| 5024 | if (argc > 1)
|
|---|
| 5025 | {
|
|---|
| 5026 | cmt_string& s = arguments.add ();
|
|---|
| 5027 | s = argv[1];
|
|---|
| 5028 |
|
|---|
| 5029 | m_action = action_check_files;
|
|---|
| 5030 | }
|
|---|
| 5031 | else
|
|---|
| 5032 | {
|
|---|
| 5033 | if (!m_quiet) cerr << "#CMT> syntax error : reference file missing" << endl;
|
|---|
| 5034 | m_help_action = action_help;
|
|---|
| 5035 | m_action = action_check_files;
|
|---|
| 5036 | }
|
|---|
| 5037 | }
|
|---|
| 5038 | else
|
|---|
| 5039 | {
|
|---|
| 5040 | if (!m_quiet) cerr << "#CMT> syntax error : file name missing" << endl;
|
|---|
| 5041 | m_help_action = action_help;
|
|---|
| 5042 | m_action = action_check_files;
|
|---|
| 5043 | }
|
|---|
| 5044 | }
|
|---|
| 5045 | else if ((arg == "co") ||
|
|---|
| 5046 | (arg == "checkout"))
|
|---|
| 5047 | {
|
|---|
| 5048 | // handle all of the command line arguments in a vector
|
|---|
| 5049 | argc--;
|
|---|
| 5050 | argv++;
|
|---|
| 5051 | if (argc > 1)
|
|---|
| 5052 | {
|
|---|
| 5053 | m_action = action_checkout;
|
|---|
| 5054 |
|
|---|
| 5055 | while (argc > 1)
|
|---|
| 5056 | {
|
|---|
| 5057 | cmt_string& s = arguments.add ();
|
|---|
| 5058 | s = argv[1];
|
|---|
| 5059 | argc--;
|
|---|
| 5060 | argv++;
|
|---|
| 5061 | }
|
|---|
| 5062 | }
|
|---|
| 5063 | else
|
|---|
| 5064 | {
|
|---|
| 5065 | if (!m_quiet) cerr << "#CMT> syntax error : checkout arguments missing" << endl;
|
|---|
| 5066 | m_help_action = action_help;
|
|---|
| 5067 | m_action = action_checkout;
|
|---|
| 5068 | }
|
|---|
| 5069 | }
|
|---|
| 5070 | else if (arg == "cleanup")
|
|---|
| 5071 | {
|
|---|
| 5072 | m_action = action_cleanup;
|
|---|
| 5073 | }
|
|---|
| 5074 | else if (arg == "config")
|
|---|
| 5075 | {
|
|---|
| 5076 | argc--;
|
|---|
| 5077 | argv++;
|
|---|
| 5078 | if (argc > 1)
|
|---|
| 5079 | {
|
|---|
| 5080 | cerr << "#---------------------------------------------------------" << endl;
|
|---|
| 5081 | cerr << "# Warning: using 'cmt config ...' to create a package is "
|
|---|
| 5082 | "becoming obsolete" << endl;
|
|---|
| 5083 | cerr << "# Please use 'cmt create ...' instead" << endl;
|
|---|
| 5084 | cerr << "#---------------------------------------------------------" << endl;
|
|---|
| 5085 |
|
|---|
| 5086 | m_current_package = argv[1];
|
|---|
| 5087 | m_current_version.erase (0);
|
|---|
| 5088 | m_current_path.erase (0);
|
|---|
| 5089 |
|
|---|
| 5090 | argc--;
|
|---|
| 5091 | argv++;
|
|---|
| 5092 | if (argc > 1)
|
|---|
| 5093 | {
|
|---|
| 5094 | m_current_version = argv[1];
|
|---|
| 5095 |
|
|---|
| 5096 | {
|
|---|
| 5097 | cmt_string& s = arguments.add ();
|
|---|
| 5098 | s = m_current_package;
|
|---|
| 5099 | }
|
|---|
| 5100 | {
|
|---|
| 5101 | cmt_string& s = arguments.add ();
|
|---|
| 5102 | s = m_current_version;
|
|---|
| 5103 | }
|
|---|
| 5104 |
|
|---|
| 5105 | argc--;
|
|---|
| 5106 | argv++;
|
|---|
| 5107 | if (argc > 1)
|
|---|
| 5108 | {
|
|---|
| 5109 | m_current_path = argv[1];
|
|---|
| 5110 | if (m_current_path[0] == '-')
|
|---|
| 5111 | {
|
|---|
| 5112 | m_current_path.erase (0);
|
|---|
| 5113 | }
|
|---|
| 5114 | }
|
|---|
| 5115 |
|
|---|
| 5116 | m_action = action_create;
|
|---|
| 5117 | }
|
|---|
| 5118 | else
|
|---|
| 5119 | {
|
|---|
| 5120 | if (!m_quiet) cerr << "#CMT> syntax error : create arguments missing" << endl;
|
|---|
| 5121 | m_help_action = action_help;
|
|---|
| 5122 | m_action = action_create;
|
|---|
| 5123 | }
|
|---|
| 5124 | }
|
|---|
| 5125 | else
|
|---|
| 5126 | {
|
|---|
| 5127 | m_action = action_config;
|
|---|
| 5128 | }
|
|---|
| 5129 | }
|
|---|
| 5130 | else if (arg == "create")
|
|---|
| 5131 | {
|
|---|
| 5132 | argc--;
|
|---|
| 5133 | argv++;
|
|---|
| 5134 |
|
|---|
| 5135 | if (argc > 1)
|
|---|
| 5136 | {
|
|---|
| 5137 | while (argc > 1)
|
|---|
| 5138 | {
|
|---|
| 5139 | cmt_string& s = arguments.add ();
|
|---|
| 5140 | s = argv[1];
|
|---|
| 5141 | argc--;
|
|---|
| 5142 | argv++;
|
|---|
| 5143 | }
|
|---|
| 5144 |
|
|---|
| 5145 | m_action = action_create;
|
|---|
| 5146 | }
|
|---|
| 5147 | else
|
|---|
| 5148 | {
|
|---|
| 5149 | if (!m_quiet) cerr << "#CMT> syntax error : create arguments missing" << endl;
|
|---|
| 5150 | m_help_action = action_help;
|
|---|
| 5151 | m_action = action_create;
|
|---|
| 5152 | }
|
|---|
| 5153 | }
|
|---|
| 5154 | else if (arg == "create_project")
|
|---|
| 5155 | {
|
|---|
| 5156 | argc--;
|
|---|
| 5157 | argv++;
|
|---|
| 5158 |
|
|---|
| 5159 | if (argc > 1)
|
|---|
| 5160 | {
|
|---|
| 5161 | while (argc > 1)
|
|---|
| 5162 | {
|
|---|
| 5163 | cmt_string& s = arguments.add ();
|
|---|
| 5164 | s = argv[1];
|
|---|
| 5165 | argc--;
|
|---|
| 5166 | argv++;
|
|---|
| 5167 | }
|
|---|
| 5168 |
|
|---|
| 5169 | m_action = action_create_project;
|
|---|
| 5170 | }
|
|---|
| 5171 | else
|
|---|
| 5172 | {
|
|---|
| 5173 | if (!m_quiet) cerr << "#CMT> syntax error : create_project arguments missing" << endl;
|
|---|
| 5174 | m_help_action = action_help;
|
|---|
| 5175 | m_action = action_create_project;
|
|---|
| 5176 | }
|
|---|
| 5177 | }
|
|---|
| 5178 | else if (arg == "cvsbranches")
|
|---|
| 5179 | {
|
|---|
| 5180 | argc--;
|
|---|
| 5181 | argv++;
|
|---|
| 5182 | if (argc > 1)
|
|---|
| 5183 | {
|
|---|
| 5184 | cmt_string& s = arguments.add ();
|
|---|
| 5185 | s = argv[1];
|
|---|
| 5186 | argc--;
|
|---|
| 5187 | argv++;
|
|---|
| 5188 |
|
|---|
| 5189 | m_action = action_cvsbranches;
|
|---|
| 5190 | }
|
|---|
| 5191 | else
|
|---|
| 5192 | {
|
|---|
| 5193 | if (!m_quiet) cerr << "#CMT> syntax error : cvsbranches arguments missing" << endl;
|
|---|
| 5194 | m_help_action = action_help;
|
|---|
| 5195 | m_action = action_cvsbranches;
|
|---|
| 5196 | }
|
|---|
| 5197 | }
|
|---|
| 5198 | else if (arg == "cvssubpackages")
|
|---|
| 5199 | {
|
|---|
| 5200 | argc--;
|
|---|
| 5201 | argv++;
|
|---|
| 5202 | if (argc > 1)
|
|---|
| 5203 | {
|
|---|
| 5204 | cmt_string& s = arguments.add ();
|
|---|
| 5205 | s = argv[1];
|
|---|
| 5206 | argc--;
|
|---|
| 5207 | argv++;
|
|---|
| 5208 |
|
|---|
| 5209 | m_action = action_cvssubpackages;
|
|---|
| 5210 | }
|
|---|
| 5211 | else
|
|---|
| 5212 | {
|
|---|
| 5213 | if (!m_quiet) cerr << "#CMT> syntax error : cvssubpackages arguments missing" << endl;
|
|---|
| 5214 | m_help_action = action_help;
|
|---|
| 5215 | m_action = action_cvssubpackages;
|
|---|
| 5216 | }
|
|---|
| 5217 | }
|
|---|
| 5218 | else if (arg == "cvstags")
|
|---|
| 5219 | {
|
|---|
| 5220 | argc--;
|
|---|
| 5221 | argv++;
|
|---|
| 5222 | if (argc > 1)
|
|---|
| 5223 | {
|
|---|
| 5224 | while (argc > 1)
|
|---|
| 5225 | {
|
|---|
| 5226 | cmt_string& s = arguments.add ();
|
|---|
| 5227 | s = argv[1];
|
|---|
| 5228 | argc--;
|
|---|
| 5229 | argv++;
|
|---|
| 5230 | }
|
|---|
| 5231 |
|
|---|
| 5232 | m_action = action_cvstags;
|
|---|
| 5233 | }
|
|---|
| 5234 | else
|
|---|
| 5235 | {
|
|---|
| 5236 | if (!m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
|
|---|
| 5237 | m_help_action = action_help;
|
|---|
| 5238 | m_action = action_cvstags;
|
|---|
| 5239 | }
|
|---|
| 5240 | }
|
|---|
| 5241 | else
|
|---|
| 5242 | {
|
|---|
| 5243 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5244 | m_help_action = action_help;
|
|---|
| 5245 | }
|
|---|
| 5246 | break;
|
|---|
| 5247 | case 'd' :
|
|---|
| 5248 | if (arg == "do")
|
|---|
| 5249 | {
|
|---|
| 5250 | argc--;
|
|---|
| 5251 | argv++;
|
|---|
| 5252 |
|
|---|
| 5253 | if (argc > 1)
|
|---|
| 5254 | {
|
|---|
| 5255 | while (argc > 1)
|
|---|
| 5256 | {
|
|---|
| 5257 | cmt_string& s = arguments.add ();
|
|---|
| 5258 | s = argv[1];
|
|---|
| 5259 | argc--;
|
|---|
| 5260 | argv++;
|
|---|
| 5261 | }
|
|---|
| 5262 |
|
|---|
| 5263 | {
|
|---|
| 5264 | cmt_string tag_name = "target_";
|
|---|
| 5265 | tag_name += arguments[0];
|
|---|
| 5266 |
|
|---|
| 5267 | Tag* tag;
|
|---|
| 5268 | tag = Tag::add (tag_name, PriorityUserTag, "action", 0);
|
|---|
| 5269 | tag->mark ();
|
|---|
| 5270 | }
|
|---|
| 5271 |
|
|---|
| 5272 | m_action = action_do;
|
|---|
| 5273 | }
|
|---|
| 5274 | else
|
|---|
| 5275 | {
|
|---|
| 5276 | if (!m_quiet) cerr << "#CMT> syntax error : action not specified" << endl;
|
|---|
| 5277 | m_help_action = action_help;
|
|---|
| 5278 | m_action = action_do;
|
|---|
| 5279 | }
|
|---|
| 5280 | }
|
|---|
| 5281 | else
|
|---|
| 5282 | {
|
|---|
| 5283 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5284 | m_help_action = action_help;
|
|---|
| 5285 | }
|
|---|
| 5286 | break;
|
|---|
| 5287 | case 'e' :
|
|---|
| 5288 | if (arg == "expand")
|
|---|
| 5289 | {
|
|---|
| 5290 | argc--;
|
|---|
| 5291 | argv++;
|
|---|
| 5292 |
|
|---|
| 5293 | if (argc > 1)
|
|---|
| 5294 | {
|
|---|
| 5295 | arg = argv[1];
|
|---|
| 5296 |
|
|---|
| 5297 | if (arg == "model")
|
|---|
| 5298 | {
|
|---|
| 5299 | argc--;
|
|---|
| 5300 | argv++;
|
|---|
| 5301 |
|
|---|
| 5302 | if (argc > 1)
|
|---|
| 5303 | {
|
|---|
| 5304 | while (argc > 1)
|
|---|
| 5305 | {
|
|---|
| 5306 | cmt_string& s = arguments.add ();
|
|---|
| 5307 | s = argv[1];
|
|---|
| 5308 | argc--;
|
|---|
| 5309 | argv++;
|
|---|
| 5310 | }
|
|---|
| 5311 |
|
|---|
| 5312 | m_action = action_expand_model;
|
|---|
| 5313 | }
|
|---|
| 5314 | else
|
|---|
| 5315 | {
|
|---|
| 5316 | if (!m_quiet) cerr << "#CMT> syntax error : model not specified" << endl;
|
|---|
| 5317 | m_help_action = action_help;
|
|---|
| 5318 | m_action = action_expand_model;
|
|---|
| 5319 | }
|
|---|
| 5320 | }
|
|---|
| 5321 | else
|
|---|
| 5322 | {
|
|---|
| 5323 | if (!m_quiet) cerr << "#CMT> syntax error : bad expand option" << endl;
|
|---|
| 5324 | m_help_action = action_help;
|
|---|
| 5325 | m_action = action_expand_model;
|
|---|
| 5326 | }
|
|---|
| 5327 | }
|
|---|
| 5328 | else
|
|---|
| 5329 | {
|
|---|
| 5330 | if (!m_quiet) cerr << "#CMT> syntax error : don't know what to expand" << endl;
|
|---|
| 5331 | m_help_action = action_help;
|
|---|
| 5332 | m_action = action_expand_model;
|
|---|
| 5333 | }
|
|---|
| 5334 | }
|
|---|
| 5335 | else
|
|---|
| 5336 | {
|
|---|
| 5337 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5338 | m_help_action = action_help;
|
|---|
| 5339 | }
|
|---|
| 5340 | break;
|
|---|
| 5341 | case 'f' :
|
|---|
| 5342 | if ((arg == "f") ||
|
|---|
| 5343 | (arg == "fi") ||
|
|---|
| 5344 | (arg == "fil") ||
|
|---|
| 5345 | (arg == "filt") ||
|
|---|
| 5346 | (arg == "filte") ||
|
|---|
| 5347 | (arg == "filter"))
|
|---|
| 5348 | {
|
|---|
| 5349 | // handle all of the command line arguments in a vector
|
|---|
| 5350 | argc--;
|
|---|
| 5351 | argv++;
|
|---|
| 5352 | while (argc > 1)
|
|---|
| 5353 | {
|
|---|
| 5354 | cmt_string& s = arguments.add ();
|
|---|
| 5355 | s = argv[1];
|
|---|
| 5356 | argc--;
|
|---|
| 5357 | argv++;
|
|---|
| 5358 | }
|
|---|
| 5359 |
|
|---|
| 5360 | m_action = action_filter;
|
|---|
| 5361 | }
|
|---|
| 5362 | else
|
|---|
| 5363 | {
|
|---|
| 5364 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5365 | m_help_action = action_help;
|
|---|
| 5366 | }
|
|---|
| 5367 | break;
|
|---|
| 5368 | case 'h' :
|
|---|
| 5369 | if ((arg == "h") ||
|
|---|
| 5370 | (arg == "he") ||
|
|---|
| 5371 | (arg == "hel") ||
|
|---|
| 5372 | (arg == "help"))
|
|---|
| 5373 | {
|
|---|
| 5374 | m_help_action = action_help;
|
|---|
| 5375 | }
|
|---|
| 5376 | else
|
|---|
| 5377 | {
|
|---|
| 5378 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5379 | m_help_action = action_help;
|
|---|
| 5380 | }
|
|---|
| 5381 | break;
|
|---|
| 5382 | case 'l' :
|
|---|
| 5383 | if (arg == "lock")
|
|---|
| 5384 | {
|
|---|
| 5385 | argc--;
|
|---|
| 5386 | argv++;
|
|---|
| 5387 | if (argc > 1)
|
|---|
| 5388 | {
|
|---|
| 5389 | m_current_package = argv[1];
|
|---|
| 5390 | {
|
|---|
| 5391 | cmt_string& s = arguments.add ();
|
|---|
| 5392 | s = m_current_package;
|
|---|
| 5393 | }
|
|---|
| 5394 |
|
|---|
| 5395 | m_current_version.erase (0);
|
|---|
| 5396 | m_current_path.erase (0);
|
|---|
| 5397 |
|
|---|
| 5398 | argc--;
|
|---|
| 5399 | argv++;
|
|---|
| 5400 | if (argc > 1)
|
|---|
| 5401 | {
|
|---|
| 5402 | m_current_version = argv[1];
|
|---|
| 5403 |
|
|---|
| 5404 | {
|
|---|
| 5405 | cmt_string& s = arguments.add ();
|
|---|
| 5406 | s = m_current_version;
|
|---|
| 5407 | }
|
|---|
| 5408 |
|
|---|
| 5409 | m_action = action_lock;
|
|---|
| 5410 |
|
|---|
| 5411 | argc--;
|
|---|
| 5412 | argv++;
|
|---|
| 5413 | if (argc > 1)
|
|---|
| 5414 | {
|
|---|
| 5415 | m_current_path = argv[1];
|
|---|
| 5416 | if (m_current_path[0] == '-')
|
|---|
| 5417 | {
|
|---|
| 5418 | m_current_path.erase (0);
|
|---|
| 5419 | }
|
|---|
| 5420 | }
|
|---|
| 5421 |
|
|---|
| 5422 | m_current_access = UserMode;
|
|---|
| 5423 | (Use::current()).set (m_current_package,
|
|---|
| 5424 | m_current_version,
|
|---|
| 5425 | m_current_path);
|
|---|
| 5426 |
|
|---|
| 5427 | }
|
|---|
| 5428 | else
|
|---|
| 5429 | {
|
|---|
| 5430 | if (!m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
|
|---|
| 5431 | m_help_action = action_help;
|
|---|
| 5432 | m_action = action_lock;
|
|---|
| 5433 | }
|
|---|
| 5434 | }
|
|---|
| 5435 | else
|
|---|
| 5436 | {
|
|---|
| 5437 | m_action = action_lock;
|
|---|
| 5438 | }
|
|---|
| 5439 | }
|
|---|
| 5440 | else
|
|---|
| 5441 | {
|
|---|
| 5442 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5443 | m_help_action = action_help;
|
|---|
| 5444 | }
|
|---|
| 5445 | break;
|
|---|
| 5446 | case 'r' :
|
|---|
| 5447 | if (arg == "remove")
|
|---|
| 5448 | {
|
|---|
| 5449 | argc--;
|
|---|
| 5450 | argv++;
|
|---|
| 5451 |
|
|---|
| 5452 | if (argc > 1)
|
|---|
| 5453 | {
|
|---|
| 5454 | arg = argv[1];
|
|---|
| 5455 |
|
|---|
| 5456 | if (arg == "library_links")
|
|---|
| 5457 | {
|
|---|
| 5458 | m_action = action_remove_library_links;
|
|---|
| 5459 | }
|
|---|
| 5460 | else
|
|---|
| 5461 | {
|
|---|
| 5462 | m_current_package = argv[1];
|
|---|
| 5463 | {
|
|---|
| 5464 | cmt_string& s = arguments.add ();
|
|---|
| 5465 | s = m_current_package;
|
|---|
| 5466 | }
|
|---|
| 5467 |
|
|---|
| 5468 | m_current_version.erase (0);
|
|---|
| 5469 | m_current_path.erase (0);
|
|---|
| 5470 |
|
|---|
| 5471 | argc--;
|
|---|
| 5472 | argv++;
|
|---|
| 5473 | if (argc > 1)
|
|---|
| 5474 | {
|
|---|
| 5475 | m_current_version = argv[1];
|
|---|
| 5476 |
|
|---|
| 5477 | {
|
|---|
| 5478 | cmt_string& s = arguments.add ();
|
|---|
| 5479 | s = m_current_version;
|
|---|
| 5480 | }
|
|---|
| 5481 |
|
|---|
| 5482 | argc--;
|
|---|
| 5483 | argv++;
|
|---|
| 5484 | if (argc > 1)
|
|---|
| 5485 | {
|
|---|
| 5486 | m_current_path = argv[1];
|
|---|
| 5487 | if (m_current_path[0] == '-')
|
|---|
| 5488 | {
|
|---|
| 5489 | m_current_path.erase (0);
|
|---|
| 5490 | }
|
|---|
| 5491 | }
|
|---|
| 5492 |
|
|---|
| 5493 | m_action = action_remove;
|
|---|
| 5494 | }
|
|---|
| 5495 | else
|
|---|
| 5496 | {
|
|---|
| 5497 | if (!m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
|
|---|
| 5498 | m_help_action = action_help;
|
|---|
| 5499 | m_action = action_remove;
|
|---|
| 5500 | }
|
|---|
| 5501 | }
|
|---|
| 5502 | }
|
|---|
| 5503 | else
|
|---|
| 5504 | {
|
|---|
| 5505 | if (!m_quiet) cerr << "#CMT> syntax error : don't know what to remove" << endl;
|
|---|
| 5506 | m_help_action = action_help;
|
|---|
| 5507 | m_action = action_remove;
|
|---|
| 5508 | }
|
|---|
| 5509 | }
|
|---|
| 5510 | else if (arg == "run")
|
|---|
| 5511 | {
|
|---|
| 5512 | argc--;
|
|---|
| 5513 | argv++;
|
|---|
| 5514 | if (argc > 1)
|
|---|
| 5515 | {
|
|---|
| 5516 | cmt_string& s = arguments.add ();
|
|---|
| 5517 | s = argv[1];
|
|---|
| 5518 |
|
|---|
| 5519 | m_action = action_run;
|
|---|
| 5520 | }
|
|---|
| 5521 | else
|
|---|
| 5522 | {
|
|---|
| 5523 | if (!m_quiet) cerr << "#CMT> syntax error : run arguments missing" << endl;
|
|---|
| 5524 | m_help_action = action_help;
|
|---|
| 5525 | m_action = action_run;
|
|---|
| 5526 | }
|
|---|
| 5527 | }
|
|---|
| 5528 | else if (arg == "run_sequence")
|
|---|
| 5529 | {
|
|---|
| 5530 | argc--;
|
|---|
| 5531 | argv++;
|
|---|
| 5532 | if (argc > 1)
|
|---|
| 5533 | {
|
|---|
| 5534 | cmt_string& s = arguments.add ();
|
|---|
| 5535 | s = argv[1];
|
|---|
| 5536 |
|
|---|
| 5537 | m_action = action_run_sequence;
|
|---|
| 5538 | }
|
|---|
| 5539 | else
|
|---|
| 5540 | {
|
|---|
| 5541 | if (!m_quiet) cerr << "#CMT> syntax error : run_sequence arguments missing" << endl;
|
|---|
| 5542 | m_help_action = action_help;
|
|---|
| 5543 | m_action = action_run_sequence;
|
|---|
| 5544 | }
|
|---|
| 5545 | }
|
|---|
| 5546 | else
|
|---|
| 5547 | {
|
|---|
| 5548 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 5549 | m_help_action = action_help;
|
|---|
| 5550 | }
|
|---|
| 5551 | break;
|
|---|
| 5552 | case 's' :
|
|---|
| 5553 | if (arg == "set")
|
|---|
| 5554 | {
|
|---|
| 5555 | argc--;
|
|---|
| 5556 | argv++;
|
|---|
| 5557 | if (argc > 1)
|
|---|
| 5558 | {
|
|---|
| 5559 | arg = argv[1];
|
|---|
| 5560 |
|
|---|
| 5561 | if (arg == "version")
|
|---|
| 5562 | {
|
|---|
| 5563 | argc--;
|
|---|
| 5564 | argv++;
|
|---|
| 5565 |
|
|---|
| 5566 | while (argc > 1)
|
|---|
| 5567 | {
|
|---|
| 5568 | cmt_string& s = arguments.add ();
|
|---|
| 5569 | s = argv[1];
|
|---|
| 5570 | argc--;
|
|---|
| 5571 | argv++;
|
|---|
| 5572 | }
|
|---|
| 5573 |
|
|---|
| 5574 | m_action = action_set_version;
|
|---|
| 5575 | }
|
|---|
| 5576 | else if (arg == "versions")
|
|---|
| 5577 | {
|
|---|
| 5578 | argc--;
|
|---|
| 5579 | argv++;
|
|---|
| 5580 |
|
|---|
| 5581 | while (argc > 1)
|
|---|
| 5582 | {
|
|---|
| 5583 | cmt_string& s = arguments.add ();
|
|---|
| 5584 | s = argv[1];
|
|---|
| 5585 | argc--;
|
|---|
| 5586 | argv++;
|
|---|
| 5587 | }
|
|---|
| 5588 |
|
|---|
| 5589 | m_action = action_set_versions;
|
|---|
| 5590 |
|
|---|
| 5591 | if (m_scope_filtering_mode == default_filtering_mode)
|
|---|
| 5592 | {
|
|---|
| 5593 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 5594 | }
|
|---|
| 5595 | }
|
|---|
| 5596 | else
|
|---|
| 5597 | {
|
|---|
| 5598 | if (!m_quiet) cerr << "#CMT> syntax error : bad set argument" << endl;
|
|---|
| 5599 | m_help_action = action_help;
|
|---|
| 5600 | //m_action = action_set;
|
|---|
| 5601 | }
|
|---|
| 5602 | }
|
|---|
| 5603 | else
|
|---|
| 5604 | {
|
|---|
| 5605 | if (!m_quiet) cerr << "#CMT> syntax error : don't know what to set" << endl;
|
|---|
| 5606 | m_help_action = action_help;
|
|---|
| 5607 | //m_action = action_set;
|
|---|
| 5608 | }
|
|---|
| 5609 | }
|
|---|
| 5610 | else if (arg == "setup")
|
|---|
| 5611 | {
|
|---|
| 5612 | m_action = action_setup;
|
|---|
| 5613 | }
|
|---|
| 5614 | else if ((arg == "s") ||
|
|---|
| 5615 | (arg == "sh") ||
|
|---|
| 5616 | (arg == "sho") ||
|
|---|
| 5617 | (arg == "show"))
|
|---|
| 5618 | {
|
|---|
| 5619 | argc--;
|
|---|
| 5620 | argv++;
|
|---|
| 5621 | if (argc > 1)
|
|---|
| 5622 | {
|
|---|
| 5623 | arg = argv[1];
|
|---|
| 5624 |
|
|---|
| 5625 | if (arg == "action")
|
|---|
| 5626 | {
|
|---|
| 5627 | argc--;
|
|---|
| 5628 | argv++;
|
|---|
| 5629 | if (argc > 1)
|
|---|
| 5630 | {
|
|---|
| 5631 | cmt_string& s = arguments.add ();
|
|---|
| 5632 | s = argv[1];
|
|---|
| 5633 | m_current_target = argv[1];
|
|---|
| 5634 |
|
|---|
| 5635 | m_action = action_show_action;
|
|---|
| 5636 | }
|
|---|
| 5637 | else
|
|---|
| 5638 | {
|
|---|
| 5639 | if (!m_quiet) cerr << "#CMT> syntax error : action name missing" << endl;
|
|---|
| 5640 | m_help_action = action_help;
|
|---|
| 5641 | m_action = action_show_action;
|
|---|
| 5642 | }
|
|---|
| 5643 | }
|
|---|
| 5644 | else if (arg == "action_names")
|
|---|
| 5645 | {
|
|---|
| 5646 | argc--;
|
|---|
| 5647 | argv++;
|
|---|
| 5648 | if (argc > 1)
|
|---|
| 5649 | {
|
|---|
| 5650 | cmt_string& s = arguments.add ();
|
|---|
| 5651 | s = argv[1];
|
|---|
| 5652 | }
|
|---|
| 5653 |
|
|---|
| 5654 | m_action = action_show_action_names;
|
|---|
| 5655 | }
|
|---|
| 5656 | else if (arg == "action_value")
|
|---|
| 5657 | {
|
|---|
| 5658 | m_quiet = true;
|
|---|
| 5659 | argc--;
|
|---|
| 5660 | argv++;
|
|---|
| 5661 | if (argc > 1)
|
|---|
| 5662 | {
|
|---|
| 5663 | cmt_string& s = arguments.add ();
|
|---|
| 5664 | s = argv[1];
|
|---|
| 5665 | m_current_target = argv[1];
|
|---|
| 5666 |
|
|---|
| 5667 | m_action = action_show_action_value;
|
|---|
| 5668 | }
|
|---|
| 5669 | else
|
|---|
| 5670 | {
|
|---|
| 5671 | if (!m_quiet) cerr << "#CMT> syntax error : action name missing" << endl;
|
|---|
| 5672 | m_help_action = action_help;
|
|---|
| 5673 | m_action = action_show_action_value;
|
|---|
| 5674 | }
|
|---|
| 5675 | }
|
|---|
| 5676 | else if (arg == "actions")
|
|---|
| 5677 | {
|
|---|
| 5678 | argc--;
|
|---|
| 5679 | argv++;
|
|---|
| 5680 | if (argc > 1)
|
|---|
| 5681 | {
|
|---|
| 5682 | cmt_string& s = arguments.add ();
|
|---|
| 5683 | s = argv[1];
|
|---|
| 5684 | }
|
|---|
| 5685 |
|
|---|
| 5686 | m_action = action_show_actions;
|
|---|
| 5687 | }
|
|---|
| 5688 | else if (arg == "all_tags")
|
|---|
| 5689 | {
|
|---|
| 5690 | m_action = action_show_all_tags;
|
|---|
| 5691 | }
|
|---|
| 5692 | else if (arg == "applied_patterns")
|
|---|
| 5693 | {
|
|---|
| 5694 | m_action = action_show_applied_patterns;
|
|---|
| 5695 | }
|
|---|
| 5696 | else if (arg == "author")
|
|---|
| 5697 | {
|
|---|
| 5698 | m_action = action_show_author;
|
|---|
| 5699 | }
|
|---|
| 5700 | else if (arg == "branches")
|
|---|
| 5701 | {
|
|---|
| 5702 | m_action = action_show_branches;
|
|---|
| 5703 | }
|
|---|
| 5704 | else if (arg == "clients")
|
|---|
| 5705 | {
|
|---|
| 5706 | argc--;
|
|---|
| 5707 | argv++;
|
|---|
| 5708 | if (argc > 1)
|
|---|
| 5709 | {
|
|---|
| 5710 | cmt_string& s = arguments.add ();
|
|---|
| 5711 | s = argv[1];
|
|---|
| 5712 | m_current_target = argv[1];
|
|---|
| 5713 |
|
|---|
| 5714 | m_action = action_show_clients;
|
|---|
| 5715 |
|
|---|
| 5716 | argc--;
|
|---|
| 5717 | argv++;
|
|---|
| 5718 | if (argc > 1)
|
|---|
| 5719 | {
|
|---|
| 5720 | cmt_string& s = arguments.add ();
|
|---|
| 5721 | s = argv[1];
|
|---|
| 5722 |
|
|---|
| 5723 | argc--;
|
|---|
| 5724 | argv++;
|
|---|
| 5725 | if (argc > 1)
|
|---|
| 5726 | {
|
|---|
| 5727 | cmt_string& s = arguments.add ();
|
|---|
| 5728 | s = argv[1];
|
|---|
| 5729 | }
|
|---|
| 5730 | }
|
|---|
| 5731 | }
|
|---|
| 5732 | else
|
|---|
| 5733 | {
|
|---|
| 5734 | if (!m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
|
|---|
| 5735 | m_help_action = action_help;
|
|---|
| 5736 | m_action = action_show_clients;
|
|---|
| 5737 | }
|
|---|
| 5738 | }
|
|---|
| 5739 | else if (arg == "cmtpath_patterns")
|
|---|
| 5740 | {
|
|---|
| 5741 | m_action = action_show_cmtpath_patterns;
|
|---|
| 5742 | }
|
|---|
| 5743 | else if (arg == "constituent")
|
|---|
| 5744 | {
|
|---|
| 5745 | argc--;
|
|---|
| 5746 | argv++;
|
|---|
| 5747 | if (argc > 1)
|
|---|
| 5748 | {
|
|---|
| 5749 | cmt_string& s = arguments.add ();
|
|---|
| 5750 | s = argv[1];
|
|---|
| 5751 | m_current_target = argv[1];
|
|---|
| 5752 |
|
|---|
| 5753 | m_action = action_show_constituent;
|
|---|
| 5754 | }
|
|---|
| 5755 | else
|
|---|
| 5756 | {
|
|---|
| 5757 | if (!m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
|
|---|
| 5758 | m_help_action = action_help;
|
|---|
| 5759 | m_action = action_show_constituent;
|
|---|
| 5760 | }
|
|---|
| 5761 | }
|
|---|
| 5762 | else if (arg == "constituent_names")
|
|---|
| 5763 | {
|
|---|
| 5764 | m_action = action_show_constituent_names;
|
|---|
| 5765 | }
|
|---|
| 5766 | else if (arg == "constituents")
|
|---|
| 5767 | {
|
|---|
| 5768 | m_action = action_show_constituents;
|
|---|
| 5769 | }
|
|---|
| 5770 | else if (arg == "cycles")
|
|---|
| 5771 | {
|
|---|
| 5772 | m_action = action_show_cycles;
|
|---|
| 5773 | }
|
|---|
| 5774 | else if (arg == "fragment")
|
|---|
| 5775 | {
|
|---|
| 5776 | argc--;
|
|---|
| 5777 | argv++;
|
|---|
| 5778 | if (argc > 1)
|
|---|
| 5779 | {
|
|---|
| 5780 | cmt_string& s = arguments.add ();
|
|---|
| 5781 | s = argv[1];
|
|---|
| 5782 | m_current_target = argv[1];
|
|---|
| 5783 |
|
|---|
| 5784 | m_action = action_show_fragment;
|
|---|
| 5785 | }
|
|---|
| 5786 | else
|
|---|
| 5787 | {
|
|---|
| 5788 | if (!m_quiet) cerr << "#CMT> syntax error : fragment name missing" << endl;
|
|---|
| 5789 | m_help_action = action_help;
|
|---|
| 5790 | m_action = action_show_fragment;
|
|---|
| 5791 | }
|
|---|
| 5792 | }
|
|---|
| 5793 | else if (arg == "fragments")
|
|---|
| 5794 | {
|
|---|
| 5795 | m_action = action_show_fragments;
|
|---|
| 5796 | }
|
|---|
| 5797 | else if (arg == "groups")
|
|---|
| 5798 | {
|
|---|
| 5799 | m_action = action_show_groups;
|
|---|
| 5800 | }
|
|---|
| 5801 | else if (arg == "include_dirs")
|
|---|
| 5802 | {
|
|---|
| 5803 | m_action = action_show_include_dirs;
|
|---|
| 5804 | }
|
|---|
| 5805 | else if (arg == "language")
|
|---|
| 5806 | {
|
|---|
| 5807 | argc--;
|
|---|
| 5808 | argv++;
|
|---|
| 5809 | if (argc > 1)
|
|---|
| 5810 | {
|
|---|
| 5811 | cmt_string& s = arguments.add ();
|
|---|
| 5812 | s = argv[1];
|
|---|
| 5813 | m_current_target = argv[1];
|
|---|
| 5814 |
|
|---|
| 5815 | m_action = action_show_language;
|
|---|
| 5816 | }
|
|---|
| 5817 | else
|
|---|
| 5818 | {
|
|---|
| 5819 | if (!m_quiet) cerr << "#CMT> syntax error : language name missing" << endl;
|
|---|
| 5820 | m_help_action = action_help;
|
|---|
| 5821 | m_action = action_show_language;
|
|---|
| 5822 | }
|
|---|
| 5823 | }
|
|---|
| 5824 | else if (arg == "languages")
|
|---|
| 5825 | {
|
|---|
| 5826 | m_action = action_show_languages;
|
|---|
| 5827 | }
|
|---|
| 5828 | else if (arg == "macro")
|
|---|
| 5829 | {
|
|---|
| 5830 | argc--;
|
|---|
| 5831 | argv++;
|
|---|
| 5832 | if (argc > 1)
|
|---|
| 5833 | {
|
|---|
| 5834 | cmt_string& s = arguments.add ();
|
|---|
| 5835 | s = argv[1];
|
|---|
| 5836 | m_current_target = argv[1];
|
|---|
| 5837 |
|
|---|
| 5838 | m_action = action_show_macro;
|
|---|
| 5839 | }
|
|---|
| 5840 | else
|
|---|
| 5841 | {
|
|---|
| 5842 | if (!m_quiet) cerr << "#CMT> syntax error : macro name missing" << endl;
|
|---|
| 5843 | m_help_action = action_help;
|
|---|
| 5844 | m_action = action_show_macro;
|
|---|
| 5845 | }
|
|---|
| 5846 | }
|
|---|
| 5847 | else if (arg == "macro_names")
|
|---|
| 5848 | {
|
|---|
| 5849 | argc--;
|
|---|
| 5850 | argv++;
|
|---|
| 5851 | if (argc > 1)
|
|---|
| 5852 | {
|
|---|
| 5853 | cmt_string& s = arguments.add ();
|
|---|
| 5854 | s = argv[1];
|
|---|
| 5855 | }
|
|---|
| 5856 |
|
|---|
| 5857 | m_action = action_show_macro_names;
|
|---|
| 5858 | }
|
|---|
| 5859 | else if (arg == "macro_value")
|
|---|
| 5860 | {
|
|---|
| 5861 | m_quiet = true;
|
|---|
| 5862 | argc--;
|
|---|
| 5863 | argv++;
|
|---|
| 5864 | if (argc > 1)
|
|---|
| 5865 | {
|
|---|
| 5866 | cmt_string& s = arguments.add ();
|
|---|
| 5867 | s = argv[1];
|
|---|
| 5868 | m_current_target = argv[1];
|
|---|
| 5869 |
|
|---|
| 5870 | m_action = action_show_macro_value;
|
|---|
| 5871 | }
|
|---|
| 5872 | else
|
|---|
| 5873 | {
|
|---|
| 5874 | if (!m_quiet) cerr << "#CMT> syntax error : macro name missing" << endl;
|
|---|
| 5875 | m_help_action = action_help;
|
|---|
| 5876 | m_action = action_show_macro_value;
|
|---|
| 5877 | }
|
|---|
| 5878 | }
|
|---|
| 5879 | else if (arg == "macros")
|
|---|
| 5880 | {
|
|---|
| 5881 | argc--;
|
|---|
| 5882 | argv++;
|
|---|
| 5883 | if (argc > 1)
|
|---|
| 5884 | {
|
|---|
| 5885 | cmt_string& s = arguments.add ();
|
|---|
| 5886 | s = argv[1];
|
|---|
| 5887 | }
|
|---|
| 5888 |
|
|---|
| 5889 | m_action = action_show_macros;
|
|---|
| 5890 | }
|
|---|
| 5891 | else if (arg == "manager")
|
|---|
| 5892 | {
|
|---|
| 5893 | m_action = action_show_manager;
|
|---|
| 5894 | }
|
|---|
| 5895 | else if (arg == "packages")
|
|---|
| 5896 | {
|
|---|
| 5897 | argc--;
|
|---|
| 5898 | argv++;
|
|---|
| 5899 | if (argc > 1)
|
|---|
| 5900 | {
|
|---|
| 5901 | cmt_string& s = arguments.add ();
|
|---|
| 5902 | s = argv[1];
|
|---|
| 5903 | m_current_target = argv[1];
|
|---|
| 5904 | }
|
|---|
| 5905 |
|
|---|
| 5906 | m_action = action_show_packages;
|
|---|
| 5907 | }
|
|---|
| 5908 | else if (arg == "path")
|
|---|
| 5909 | {
|
|---|
| 5910 | m_action = action_show_path;
|
|---|
| 5911 | }
|
|---|
| 5912 | else if (arg == "pattern")
|
|---|
| 5913 | {
|
|---|
| 5914 | argc--;
|
|---|
| 5915 | argv++;
|
|---|
| 5916 | if (argc > 1)
|
|---|
| 5917 | {
|
|---|
| 5918 | cmt_string& s = arguments.add ();
|
|---|
| 5919 | s = argv[1];
|
|---|
| 5920 | m_current_target = argv[1];
|
|---|
| 5921 |
|
|---|
| 5922 | m_action = action_show_pattern;
|
|---|
| 5923 | }
|
|---|
| 5924 | else
|
|---|
| 5925 | {
|
|---|
| 5926 | if (!m_quiet) cerr << "#CMT> syntax error : pattern name missing" << endl;
|
|---|
| 5927 | m_help_action = action_help;
|
|---|
| 5928 | m_action = action_show_pattern;
|
|---|
| 5929 | }
|
|---|
| 5930 | }
|
|---|
| 5931 | else if (arg == "pattern_names")
|
|---|
| 5932 | {
|
|---|
| 5933 | m_action = action_show_pattern_names;
|
|---|
| 5934 | }
|
|---|
| 5935 | else if (arg == "patterns")
|
|---|
| 5936 | {
|
|---|
| 5937 | m_action = action_show_patterns;
|
|---|
| 5938 | }
|
|---|
| 5939 | else if (arg == "projects")
|
|---|
| 5940 | {
|
|---|
| 5941 | m_action = action_show_projects;
|
|---|
| 5942 | }
|
|---|
| 5943 | else if (arg == "pwd")
|
|---|
| 5944 | {
|
|---|
| 5945 | m_action = action_show_pwd;
|
|---|
| 5946 | }
|
|---|
| 5947 | else if (arg == "setup")
|
|---|
| 5948 | {
|
|---|
| 5949 | m_action = action_show_setup;
|
|---|
| 5950 |
|
|---|
| 5951 | if (m_scope_filtering_mode == default_filtering_mode)
|
|---|
| 5952 | {
|
|---|
| 5953 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 5954 | }
|
|---|
| 5955 | }
|
|---|
| 5956 | else if (arg == "set_names")
|
|---|
| 5957 | {
|
|---|
| 5958 | argc--;
|
|---|
| 5959 | argv++;
|
|---|
| 5960 | if (argc > 1)
|
|---|
| 5961 | {
|
|---|
| 5962 | cmt_string& s = arguments.add ();
|
|---|
| 5963 | s = argv[1];
|
|---|
| 5964 | }
|
|---|
| 5965 |
|
|---|
| 5966 | m_action = action_show_set_names;
|
|---|
| 5967 | }
|
|---|
| 5968 | else if (arg == "set_value")
|
|---|
| 5969 | {
|
|---|
| 5970 | m_quiet = true;
|
|---|
| 5971 | argc--;
|
|---|
| 5972 | argv++;
|
|---|
| 5973 | if (argc > 1)
|
|---|
| 5974 | {
|
|---|
| 5975 | cmt_string& s = arguments.add ();
|
|---|
| 5976 | s = argv[1];
|
|---|
| 5977 | m_current_target = argv[1];
|
|---|
| 5978 |
|
|---|
| 5979 | m_action = action_show_set_value;
|
|---|
| 5980 | }
|
|---|
| 5981 | else
|
|---|
| 5982 | {
|
|---|
| 5983 | if (!m_quiet) cerr << "#CMT> syntax error : set name missing" << endl;
|
|---|
| 5984 | m_help_action = action_help;
|
|---|
| 5985 | m_action = action_show_set_value;
|
|---|
| 5986 | }
|
|---|
| 5987 | }
|
|---|
| 5988 | else if (arg == "set")
|
|---|
| 5989 | {
|
|---|
| 5990 | argc--;
|
|---|
| 5991 | argv++;
|
|---|
| 5992 | if (argc > 1)
|
|---|
| 5993 | {
|
|---|
| 5994 | cmt_string& s = arguments.add ();
|
|---|
| 5995 | s = argv[1];
|
|---|
| 5996 | m_current_target = argv[1];
|
|---|
| 5997 |
|
|---|
| 5998 | m_action = action_show_set;
|
|---|
| 5999 | }
|
|---|
| 6000 | else
|
|---|
| 6001 | {
|
|---|
| 6002 | if (!m_quiet) cerr << "#CMT> syntax error : set name missing" << endl;
|
|---|
| 6003 | m_help_action = action_help;
|
|---|
| 6004 | m_action = action_show_set;
|
|---|
| 6005 | }
|
|---|
| 6006 | }
|
|---|
| 6007 | else if (arg == "sets")
|
|---|
| 6008 | {
|
|---|
| 6009 | argc--;
|
|---|
| 6010 | argv++;
|
|---|
| 6011 | if (argc > 1)
|
|---|
| 6012 | {
|
|---|
| 6013 | cmt_string& s = arguments.add ();
|
|---|
| 6014 | s = argv[1];
|
|---|
| 6015 | }
|
|---|
| 6016 |
|
|---|
| 6017 | m_action = action_show_sets;
|
|---|
| 6018 | }
|
|---|
| 6019 | else if (arg == "strategies")
|
|---|
| 6020 | {
|
|---|
| 6021 | m_action = action_show_strategies;
|
|---|
| 6022 | }
|
|---|
| 6023 | else if (arg == "tags")
|
|---|
| 6024 | {
|
|---|
| 6025 | m_action = action_show_tags;
|
|---|
| 6026 | }
|
|---|
| 6027 | else if (arg == "use_paths")
|
|---|
| 6028 | {
|
|---|
| 6029 | argc--;
|
|---|
| 6030 | argv++;
|
|---|
| 6031 | if (argc > 1)
|
|---|
| 6032 | {
|
|---|
| 6033 | while (argc > 1)
|
|---|
| 6034 | {
|
|---|
| 6035 | if (strcmp (argv[1], "-private") == 0)
|
|---|
| 6036 | {
|
|---|
| 6037 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 6038 | }
|
|---|
| 6039 | else if (strcmp (argv[1], "--private") == 0)
|
|---|
| 6040 | {
|
|---|
| 6041 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 6042 | }
|
|---|
| 6043 | else
|
|---|
| 6044 | {
|
|---|
| 6045 | cmt_string& s = arguments.add ();
|
|---|
| 6046 | s = argv[1];
|
|---|
| 6047 | }
|
|---|
| 6048 |
|
|---|
| 6049 | argc--;
|
|---|
| 6050 | argv++;
|
|---|
| 6051 | }
|
|---|
| 6052 |
|
|---|
| 6053 | m_action = action_show_use_paths;
|
|---|
| 6054 | }
|
|---|
| 6055 | else
|
|---|
| 6056 | {
|
|---|
| 6057 | if (!m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
|
|---|
| 6058 | m_help_action = action_help;
|
|---|
| 6059 | m_action = action_show_use_paths;
|
|---|
| 6060 | }
|
|---|
| 6061 | }
|
|---|
| 6062 | else if ((arg == "u") ||
|
|---|
| 6063 | (arg == "us") ||
|
|---|
| 6064 | (arg == "use") ||
|
|---|
| 6065 | (arg == "uses"))
|
|---|
| 6066 | {
|
|---|
| 6067 | m_action = action_show_uses;
|
|---|
| 6068 |
|
|---|
| 6069 | if (m_scope_filtering_mode == default_filtering_mode)
|
|---|
| 6070 | {
|
|---|
| 6071 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 6072 | }
|
|---|
| 6073 | }
|
|---|
| 6074 | else if (arg == "version")
|
|---|
| 6075 | {
|
|---|
| 6076 | m_action = action_show_version;
|
|---|
| 6077 | }
|
|---|
| 6078 | else if (arg == "versions")
|
|---|
| 6079 | {
|
|---|
| 6080 | argc--;
|
|---|
| 6081 | argv++;
|
|---|
| 6082 | if (argc > 1)
|
|---|
| 6083 | {
|
|---|
| 6084 | cmt_string& s = arguments.add ();
|
|---|
| 6085 | s = argv[1];
|
|---|
| 6086 | m_current_target = argv[1];
|
|---|
| 6087 |
|
|---|
| 6088 | m_action = action_show_versions;
|
|---|
| 6089 | }
|
|---|
| 6090 | else
|
|---|
| 6091 | {
|
|---|
| 6092 | if (!m_quiet) cerr << "#CMT> syntax error : package name missing" << endl;
|
|---|
| 6093 | m_help_action = action_help;
|
|---|
| 6094 | m_action = action_show_versions;
|
|---|
| 6095 | }
|
|---|
| 6096 | }
|
|---|
| 6097 | else
|
|---|
| 6098 | {
|
|---|
| 6099 | if (!m_quiet) cerr << "#CMT> syntax error : bad show argument" << endl;
|
|---|
| 6100 | m_help_action = action_help;
|
|---|
| 6101 | m_action = action_show;
|
|---|
| 6102 | }
|
|---|
| 6103 | }
|
|---|
| 6104 | else
|
|---|
| 6105 | {
|
|---|
| 6106 | if (!m_quiet) cerr << "#CMT> syntax error : don't know what to show" << endl;
|
|---|
| 6107 | m_help_action = action_help;
|
|---|
| 6108 | m_action = action_show;
|
|---|
| 6109 | }
|
|---|
| 6110 | }
|
|---|
| 6111 | else if (arg == "system")
|
|---|
| 6112 | {
|
|---|
| 6113 | m_action = action_system;
|
|---|
| 6114 | }
|
|---|
| 6115 | else
|
|---|
| 6116 | {
|
|---|
| 6117 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 6118 | m_help_action = action_help;
|
|---|
| 6119 | }
|
|---|
| 6120 |
|
|---|
| 6121 | break;
|
|---|
| 6122 | case 'u' :
|
|---|
| 6123 | if (arg == "unlock")
|
|---|
| 6124 | {
|
|---|
| 6125 | argc--;
|
|---|
| 6126 | argv++;
|
|---|
| 6127 | if (argc > 1)
|
|---|
| 6128 | {
|
|---|
| 6129 | m_current_package = argv[1];
|
|---|
| 6130 | {
|
|---|
| 6131 | cmt_string& s = arguments.add ();
|
|---|
| 6132 | s = m_current_package;
|
|---|
| 6133 | }
|
|---|
| 6134 |
|
|---|
| 6135 | m_current_version.erase (0);
|
|---|
| 6136 | m_current_path.erase (0);
|
|---|
| 6137 |
|
|---|
| 6138 | argc--;
|
|---|
| 6139 | argv++;
|
|---|
| 6140 | if (argc > 1)
|
|---|
| 6141 | {
|
|---|
| 6142 | m_current_version = argv[1];
|
|---|
| 6143 |
|
|---|
| 6144 | {
|
|---|
| 6145 | cmt_string& s = arguments.add ();
|
|---|
| 6146 | s = m_current_version;
|
|---|
| 6147 | }
|
|---|
| 6148 |
|
|---|
| 6149 | m_action = action_unlock;
|
|---|
| 6150 |
|
|---|
| 6151 | argc--;
|
|---|
| 6152 | argv++;
|
|---|
| 6153 | if (argc > 1)
|
|---|
| 6154 | {
|
|---|
| 6155 | m_current_path = argv[1];
|
|---|
| 6156 | if (m_current_path[0] == '-')
|
|---|
| 6157 | {
|
|---|
| 6158 | m_current_path.erase (0);
|
|---|
| 6159 | }
|
|---|
| 6160 | }
|
|---|
| 6161 |
|
|---|
| 6162 | m_current_access = UserMode;
|
|---|
| 6163 | (Use::current()).set (m_current_package,
|
|---|
| 6164 | m_current_version,
|
|---|
| 6165 | m_current_path);
|
|---|
| 6166 |
|
|---|
| 6167 | }
|
|---|
| 6168 | else
|
|---|
| 6169 | {
|
|---|
| 6170 | if (!m_quiet) cerr << "#CMT> syntax error : version missing" << endl;
|
|---|
| 6171 | m_help_action = action_help;
|
|---|
| 6172 | m_action = action_unlock;
|
|---|
| 6173 | }
|
|---|
| 6174 | }
|
|---|
| 6175 | else
|
|---|
| 6176 | {
|
|---|
| 6177 | m_action = action_unlock;
|
|---|
| 6178 | }
|
|---|
| 6179 | }
|
|---|
| 6180 | else
|
|---|
| 6181 | {
|
|---|
| 6182 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 6183 | m_help_action = action_help;
|
|---|
| 6184 | }
|
|---|
| 6185 |
|
|---|
| 6186 | break;
|
|---|
| 6187 | case 'v' :
|
|---|
| 6188 | if ((arg == "v") ||
|
|---|
| 6189 | (arg == "ve") ||
|
|---|
| 6190 | (arg == "ver") ||
|
|---|
| 6191 | (arg == "vers") ||
|
|---|
| 6192 | (arg == "versi") ||
|
|---|
| 6193 | (arg == "versio") ||
|
|---|
| 6194 | (arg == "version"))
|
|---|
| 6195 | {
|
|---|
| 6196 | m_action = action_version;
|
|---|
| 6197 | }
|
|---|
| 6198 | else
|
|---|
| 6199 | {
|
|---|
| 6200 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 6201 | m_help_action = action_help;
|
|---|
| 6202 | }
|
|---|
| 6203 | break;
|
|---|
| 6204 | case '+' :
|
|---|
| 6205 | if (arg.substr (0, 6) == "+path=")
|
|---|
| 6206 | {
|
|---|
| 6207 | arg.erase (0, 6);
|
|---|
| 6208 |
|
|---|
| 6209 | IProjectFactory& factory = ProjectFactory::instance ();
|
|---|
| 6210 |
|
|---|
| 6211 | CmtSystem::add_cmt_path (arg, "argument", factory);
|
|---|
| 6212 | }
|
|---|
| 6213 | else
|
|---|
| 6214 | {
|
|---|
| 6215 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb "
|
|---|
| 6216 | << arg << endl;
|
|---|
| 6217 | m_help_action = action_help;
|
|---|
| 6218 | }
|
|---|
| 6219 |
|
|---|
| 6220 | break;
|
|---|
| 6221 | case '-' :
|
|---|
| 6222 | if ((arg == "-help") ||
|
|---|
| 6223 | (arg == "--help"))
|
|---|
| 6224 | {
|
|---|
| 6225 | m_help_action = action_help;
|
|---|
| 6226 | }
|
|---|
| 6227 | else if (arg == "-n")
|
|---|
| 6228 | {
|
|---|
| 6229 | m_simulation = true;
|
|---|
| 6230 | }
|
|---|
| 6231 | else if ((arg == "-q") ||
|
|---|
| 6232 | (arg == "-qu") ||
|
|---|
| 6233 | (arg == "-qui") ||
|
|---|
| 6234 | (arg == "-quie") ||
|
|---|
| 6235 | (arg == "-quiet"))
|
|---|
| 6236 | {
|
|---|
| 6237 | m_quiet = true;
|
|---|
| 6238 | }
|
|---|
| 6239 | else if (arg == "-csh")
|
|---|
| 6240 | {
|
|---|
| 6241 | mode = Csh;
|
|---|
| 6242 | }
|
|---|
| 6243 | else if (arg == "-sh")
|
|---|
| 6244 | {
|
|---|
| 6245 | mode = Sh;
|
|---|
| 6246 | }
|
|---|
| 6247 | else if (arg == "-bat")
|
|---|
| 6248 | {
|
|---|
| 6249 | mode = Bat;
|
|---|
| 6250 | }
|
|---|
| 6251 | else if (arg.substr (0, 5) == "-use=")
|
|---|
| 6252 | {
|
|---|
| 6253 | arg.erase (0, 5);
|
|---|
| 6254 |
|
|---|
| 6255 | if (m_action != action_create)
|
|---|
| 6256 | {
|
|---|
| 6257 | CmtSystem::cmt_string_vector words;
|
|---|
| 6258 |
|
|---|
| 6259 | CmtSystem::split (arg, ":", words);
|
|---|
| 6260 |
|
|---|
| 6261 | m_current_access = UserMode;
|
|---|
| 6262 |
|
|---|
| 6263 | if (words.size () > 0) m_current_package = words[0];
|
|---|
| 6264 | if (words.size () > 1) m_current_version = words[1];
|
|---|
| 6265 | if (words.size () > 2) m_current_path = words[2];
|
|---|
| 6266 | (Use::current()).set (m_current_package,
|
|---|
| 6267 | m_current_version,
|
|---|
| 6268 | m_current_path);
|
|---|
| 6269 | }
|
|---|
| 6270 | }
|
|---|
| 6271 | else if (arg.substr (0, 6) == "-pack=")
|
|---|
| 6272 | {
|
|---|
| 6273 | arg.erase (0, 6);
|
|---|
| 6274 | if ((m_action != action_create) && (m_current_package != arg))
|
|---|
| 6275 | {
|
|---|
| 6276 | //CmtSystem::cd (m_default_path);
|
|---|
| 6277 |
|
|---|
| 6278 | m_current_access = UserMode;
|
|---|
| 6279 |
|
|---|
| 6280 | m_current_package = arg;
|
|---|
| 6281 | m_current_version = "";
|
|---|
| 6282 | m_current_path = m_default_path;
|
|---|
| 6283 |
|
|---|
| 6284 | (Use::current()).set (m_current_package,
|
|---|
| 6285 | m_current_version,
|
|---|
| 6286 | m_current_path);
|
|---|
| 6287 | }
|
|---|
| 6288 | }
|
|---|
| 6289 | else if (arg.substr (0, 9) == "-version=")
|
|---|
| 6290 | {
|
|---|
| 6291 | arg.erase (0, 9);
|
|---|
| 6292 | if ((m_action != action_create) && (m_current_version != arg))
|
|---|
| 6293 | {
|
|---|
| 6294 | m_current_access = UserMode;
|
|---|
| 6295 | m_current_version = arg;
|
|---|
| 6296 | (Use::current()).set (m_current_package,
|
|---|
| 6297 | m_current_version,
|
|---|
| 6298 | m_current_path);
|
|---|
| 6299 | }
|
|---|
| 6300 | }
|
|---|
| 6301 | else if (arg.substr (0, 6) == "-path=")
|
|---|
| 6302 | {
|
|---|
| 6303 | arg.erase (0, 6);
|
|---|
| 6304 |
|
|---|
| 6305 | /*
|
|---|
| 6306 | cerr << "-path=" << arg <<
|
|---|
| 6307 | " cp=" << m_current_package <<
|
|---|
| 6308 | " cv=" << m_current_version <<
|
|---|
| 6309 | " cp=" << m_current_path << endl;
|
|---|
| 6310 | */
|
|---|
| 6311 |
|
|---|
| 6312 | if ((m_action != action_create) && (m_current_path != arg))
|
|---|
| 6313 | {
|
|---|
| 6314 | m_current_access = UserMode;
|
|---|
| 6315 | m_current_path = arg;
|
|---|
| 6316 | (Use::current()).set (m_current_package,
|
|---|
| 6317 | m_current_version,
|
|---|
| 6318 | m_current_path);
|
|---|
| 6319 |
|
|---|
| 6320 | IProjectFactory& factory = ProjectFactory::instance ();
|
|---|
| 6321 |
|
|---|
| 6322 | //CmtSystem::add_cmt_path (m_current_path, "argument", factory);
|
|---|
| 6323 | }
|
|---|
| 6324 | }
|
|---|
| 6325 | else if (arg.substr (0, 3) == "-f=")
|
|---|
| 6326 | {
|
|---|
| 6327 | arg.substr (3, extra_file);
|
|---|
| 6328 | }
|
|---|
| 6329 | else if (arg.substr (0, 3) == "-e=")
|
|---|
| 6330 | {
|
|---|
| 6331 | cerr << "#CMT> Warning: extra statement = " << arg << endl;
|
|---|
| 6332 | arg.substr (3, extra_line);
|
|---|
| 6333 | }
|
|---|
| 6334 | else if (arg.substr (0, 6) == "-home=")
|
|---|
| 6335 | {
|
|---|
| 6336 | arg.erase (0, 6);
|
|---|
| 6337 | if (CmtSystem::test_directory (arg))
|
|---|
| 6338 | {
|
|---|
| 6339 | m_cmt_home = arg;
|
|---|
| 6340 | }
|
|---|
| 6341 | }
|
|---|
| 6342 | else if (arg.substr (0, 5) == "-tag=")
|
|---|
| 6343 | {
|
|---|
| 6344 | /*
|
|---|
| 6345 | Here we are going to change the complete tag set
|
|---|
| 6346 | */
|
|---|
| 6347 |
|
|---|
| 6348 | arg.erase (0, 5);
|
|---|
| 6349 |
|
|---|
| 6350 | if (arg != "")
|
|---|
| 6351 | {
|
|---|
| 6352 | Tag* tag;
|
|---|
| 6353 | CmtSystem::cmt_string_vector words;
|
|---|
| 6354 |
|
|---|
| 6355 | // First forget about all existing tags
|
|---|
| 6356 | Tag::clear_all ();
|
|---|
| 6357 | Cmt::m_extra_tags = ",";
|
|---|
| 6358 |
|
|---|
| 6359 | // Then restore CMTSITE
|
|---|
| 6360 | configure_version_tag ();
|
|---|
| 6361 | configure_site_tag (0);
|
|---|
| 6362 | configure_uname_tag ();
|
|---|
| 6363 | configure_hosttype_tag ();
|
|---|
| 6364 | configure_config_tag ();
|
|---|
| 6365 | configure_home (0);
|
|---|
| 6366 |
|
|---|
| 6367 | CmtSystem::split (arg, " \t,", words);
|
|---|
| 6368 |
|
|---|
| 6369 | for (int i = 0; i < words.size (); i++)
|
|---|
| 6370 | {
|
|---|
| 6371 | const cmt_string& a = words[i];
|
|---|
| 6372 |
|
|---|
| 6373 | cmt_string s = ",";
|
|---|
| 6374 | s += a;
|
|---|
| 6375 | s += ",";
|
|---|
| 6376 |
|
|---|
| 6377 | if (i == 0)
|
|---|
| 6378 | {
|
|---|
| 6379 | m_current_tag = a;
|
|---|
| 6380 |
|
|---|
| 6381 | if (CmtSystem::testenv ("TAGDEBUG")) cerr
|
|---|
| 6382 | << "parse_argument(tag_add)> current_tag=" << m_current_tag << endl;
|
|---|
| 6383 | }
|
|---|
| 6384 |
|
|---|
| 6385 | if (Cmt::m_extra_tags.find (s) == cmt_string::npos)
|
|---|
| 6386 | {
|
|---|
| 6387 | //if (!m_quiet) cerr << " a=[" << a << "]" << endl;
|
|---|
| 6388 |
|
|---|
| 6389 | // Then restore uname if the specified tag is CMTCONFIG
|
|---|
| 6390 | if (a == CmtSystem::get_cmt_config ())
|
|---|
| 6391 | {
|
|---|
| 6392 | configure_uname_tag ();
|
|---|
| 6393 | }
|
|---|
| 6394 |
|
|---|
| 6395 | tag = Tag::add (a, PriorityArgument, "arguments", 0);
|
|---|
| 6396 |
|
|---|
| 6397 | tag->mark ();
|
|---|
| 6398 |
|
|---|
| 6399 | Cmt::m_extra_tags += a;
|
|---|
| 6400 | Cmt::m_extra_tags += ",";
|
|---|
| 6401 | }
|
|---|
| 6402 | }
|
|---|
| 6403 | }
|
|---|
| 6404 | }
|
|---|
| 6405 | else if (arg.substr (0, 9) == "-tag_add=")
|
|---|
| 6406 | {
|
|---|
| 6407 | Tag* tag;
|
|---|
| 6408 | CmtSystem::cmt_string_vector words;
|
|---|
| 6409 |
|
|---|
| 6410 | arg.erase (0, 9);
|
|---|
| 6411 |
|
|---|
| 6412 | //if (!m_quiet) cerr << "-tag_add=" << arg << endl;
|
|---|
| 6413 |
|
|---|
| 6414 | CmtSystem::split (arg, " \t,", words);
|
|---|
| 6415 |
|
|---|
| 6416 | for (int i = 0; i < words.size (); i++)
|
|---|
| 6417 | {
|
|---|
| 6418 | const cmt_string& a = words[i];
|
|---|
| 6419 |
|
|---|
| 6420 | cmt_string s = ",";
|
|---|
| 6421 | s += a;
|
|---|
| 6422 | s += ",";
|
|---|
| 6423 |
|
|---|
| 6424 | if (Cmt::m_extra_tags.find (s) == cmt_string::npos)
|
|---|
| 6425 | {
|
|---|
| 6426 | //if (!m_quiet) cerr << " a=[" << a << "]" << endl;
|
|---|
| 6427 |
|
|---|
| 6428 | /// Then restore uname if the specified tag is CMTCONFIG
|
|---|
| 6429 | if (a == CmtSystem::get_cmt_config ())
|
|---|
| 6430 | {
|
|---|
| 6431 | configure_uname_tag ();
|
|---|
| 6432 | }
|
|---|
| 6433 |
|
|---|
| 6434 | tag = Tag::add (a, PriorityUserTag, "arguments", 0);
|
|---|
| 6435 |
|
|---|
| 6436 | tag->mark ();
|
|---|
| 6437 |
|
|---|
| 6438 | Cmt::m_extra_tags += a;
|
|---|
| 6439 | Cmt::m_extra_tags += ",";
|
|---|
| 6440 | }
|
|---|
| 6441 | }
|
|---|
| 6442 | }
|
|---|
| 6443 | else if (arg.substr (0, 12) == "-tag_remove=")
|
|---|
| 6444 | {
|
|---|
| 6445 | Tag::TagPtrVector tags = Tag::tags ();
|
|---|
| 6446 | int i;
|
|---|
| 6447 | Tag* tag;
|
|---|
| 6448 |
|
|---|
| 6449 | /*
|
|---|
| 6450 | for (i = 0; i < tags.size (); i++)
|
|---|
| 6451 | {
|
|---|
| 6452 | tag = tags[i];
|
|---|
| 6453 | if ((tag != 0) &&
|
|---|
| 6454 | (tag->selected))
|
|---|
| 6455 | {
|
|---|
| 6456 | if (!m_quiet) cerr << " original tag_list=" << tag->name << tag->priority << endl;
|
|---|
| 6457 | }
|
|---|
| 6458 | }
|
|---|
| 6459 | */
|
|---|
| 6460 |
|
|---|
| 6461 | CmtSystem::cmt_string_vector words;
|
|---|
| 6462 |
|
|---|
| 6463 | arg.erase (0, 12);
|
|---|
| 6464 |
|
|---|
| 6465 | //if (!m_quiet) cerr << "-arg_remove=" << arg << endl;
|
|---|
| 6466 |
|
|---|
| 6467 | CmtSystem::split (arg, " \t,", words);
|
|---|
| 6468 |
|
|---|
| 6469 | //
|
|---|
| 6470 | // Now erase all entries in the old list that match
|
|---|
| 6471 | // the specified tags
|
|---|
| 6472 | //
|
|---|
| 6473 |
|
|---|
| 6474 | for (i = 0; i < words.size (); i++)
|
|---|
| 6475 | {
|
|---|
| 6476 | const cmt_string& a = words[i];
|
|---|
| 6477 |
|
|---|
| 6478 | cmt_string s = ",";
|
|---|
| 6479 | s += a;
|
|---|
| 6480 | s += ",";
|
|---|
| 6481 |
|
|---|
| 6482 | int pos;
|
|---|
| 6483 |
|
|---|
| 6484 | pos = Cmt::m_extra_tags.find (s);
|
|---|
| 6485 |
|
|---|
| 6486 | if (pos != cmt_string::npos)
|
|---|
| 6487 | {
|
|---|
| 6488 | Cmt::m_extra_tags.erase (pos, s.size () - 1);
|
|---|
| 6489 | }
|
|---|
| 6490 |
|
|---|
| 6491 | //if (!m_quiet) cerr << " tag_list=[" << tag_list << "]" << endl;
|
|---|
| 6492 | }
|
|---|
| 6493 |
|
|---|
| 6494 | //
|
|---|
| 6495 | // Now reinject the purged list of tags into the database
|
|---|
| 6496 | // exactly as when using -tag=<tag-list>
|
|---|
| 6497 | //
|
|---|
| 6498 |
|
|---|
| 6499 | /// First forget about all existing tags
|
|---|
| 6500 | Tag::unmark_all ();
|
|---|
| 6501 |
|
|---|
| 6502 | /// Then restore CMTSITE
|
|---|
| 6503 | configure_version_tag ();
|
|---|
| 6504 | configure_site_tag (0);
|
|---|
| 6505 | configure_uname_tag ();
|
|---|
| 6506 | configure_hosttype_tag ();
|
|---|
| 6507 |
|
|---|
| 6508 | CmtSystem::split (Cmt::m_extra_tags, " \t,", words);
|
|---|
| 6509 |
|
|---|
| 6510 | for (i = 0; i < words.size (); i++)
|
|---|
| 6511 | {
|
|---|
| 6512 | const cmt_string& a = words[i];
|
|---|
| 6513 |
|
|---|
| 6514 | //fprintf (stderr, " a=[%s]\n", a.c_str ());
|
|---|
| 6515 |
|
|---|
| 6516 | /// Then restore uname if the specified tag is CMTCONFIG
|
|---|
| 6517 | if (a == CmtSystem::get_cmt_config ())
|
|---|
| 6518 | {
|
|---|
| 6519 | configure_uname_tag ();
|
|---|
| 6520 | }
|
|---|
| 6521 |
|
|---|
| 6522 | if (i == 0)
|
|---|
| 6523 | {
|
|---|
| 6524 | m_current_tag = a;
|
|---|
| 6525 |
|
|---|
| 6526 | //if (!m_quiet) cerr << "parse_argument(tag_remove)> current_tag="
|
|---|
| 6527 | //<< m_current_tag << endl;
|
|---|
| 6528 |
|
|---|
| 6529 | tag = Tag::add (a, PriorityTag, "restore configuration", 0);
|
|---|
| 6530 | }
|
|---|
| 6531 | else
|
|---|
| 6532 | {
|
|---|
| 6533 | tag = Tag::add (a, PriorityUserTag, "restore configuration", 0);
|
|---|
| 6534 | }
|
|---|
| 6535 |
|
|---|
| 6536 | tag->mark ();
|
|---|
| 6537 | }
|
|---|
| 6538 | }
|
|---|
| 6539 | else if (arg.substr (0, 14) == "-user_context=")
|
|---|
| 6540 | {
|
|---|
| 6541 | arg.erase (0, 14);
|
|---|
| 6542 | if (CmtSystem::test_directory (arg))
|
|---|
| 6543 | {
|
|---|
| 6544 | m_cmt_user_context = arg;
|
|---|
| 6545 | }
|
|---|
| 6546 | }
|
|---|
| 6547 | else if (arg == "--version")
|
|---|
| 6548 | {
|
|---|
| 6549 | m_action = action_version;
|
|---|
| 6550 | }
|
|---|
| 6551 | else if (arg.substr (0, 23) == "-with_version_directory")
|
|---|
| 6552 | {
|
|---|
| 6553 | m_current_structuring_style = with_version_directory;
|
|---|
| 6554 | }
|
|---|
| 6555 | else if (arg.substr (0, 26) == "-without_version_directory")
|
|---|
| 6556 | {
|
|---|
| 6557 | m_current_structuring_style = without_version_directory;
|
|---|
| 6558 | }
|
|---|
| 6559 | else if (arg.substr (0, 11) == "-no_cleanup")
|
|---|
| 6560 | {
|
|---|
| 6561 | m_current_setup_strategy |= SetupNoCleanup;
|
|---|
| 6562 | }
|
|---|
| 6563 | else if ((arg == "-private") ||
|
|---|
| 6564 | (arg == "--private"))
|
|---|
| 6565 | {
|
|---|
| 6566 | set_scope_filtering_mode (reach_private_uses);
|
|---|
| 6567 | }
|
|---|
| 6568 | else if ((arg == "-public") ||
|
|---|
| 6569 | (arg == "--public"))
|
|---|
| 6570 | {
|
|---|
| 6571 | set_scope_filtering_mode (block_private_uses);
|
|---|
| 6572 | }
|
|---|
| 6573 | else
|
|---|
| 6574 | {
|
|---|
| 6575 | if (!m_quiet) cerr << "#CMT> syntax error : bad verb " << arg << endl;
|
|---|
| 6576 | m_help_action = action_help;
|
|---|
| 6577 | }
|
|---|
| 6578 |
|
|---|
| 6579 | break;
|
|---|
| 6580 | default:
|
|---|
| 6581 | if (!m_quiet) cerr << "#CMT> syntax error : bad command parameter " << arg << endl;
|
|---|
| 6582 | m_help_action = action_help;
|
|---|
| 6583 | break;
|
|---|
| 6584 | }
|
|---|
| 6585 |
|
|---|
| 6586 | argc--;
|
|---|
| 6587 | argv++;
|
|---|
| 6588 | }
|
|---|
| 6589 | }
|
|---|
| 6590 |
|
|---|
| 6591 | //----------------------------------------------------------
|
|---|
| 6592 | int Cmt::parser (const cmt_string& command_line)
|
|---|
| 6593 | {
|
|---|
| 6594 | CmtSystem::cmt_string_vector v;
|
|---|
| 6595 |
|
|---|
| 6596 | CmtSystem::split (command_line, " \t", v);
|
|---|
| 6597 |
|
|---|
| 6598 | int argc = v.size ();
|
|---|
| 6599 |
|
|---|
| 6600 | char** argv = (char**) malloc ((argc + 1) * sizeof (char*));
|
|---|
| 6601 |
|
|---|
| 6602 | int i;
|
|---|
| 6603 | for (i = 0; i < argc; i++)
|
|---|
| 6604 | {
|
|---|
| 6605 | argv[i] = (char*) v[i].c_str ();
|
|---|
| 6606 | }
|
|---|
| 6607 | argv[argc] = 0;
|
|---|
| 6608 |
|
|---|
| 6609 | int status = parser (argc, argv);
|
|---|
| 6610 |
|
|---|
| 6611 | free (argv);
|
|---|
| 6612 |
|
|---|
| 6613 | return (status);
|
|---|
| 6614 | }
|
|---|
| 6615 |
|
|---|
| 6616 | //----------------------------------------------------------
|
|---|
| 6617 | int Cmt::parser (int argc, char* argv[])
|
|---|
| 6618 | {
|
|---|
| 6619 | PrintMode mode = Csh;
|
|---|
| 6620 | CmtSystem::cmt_string_vector arguments;
|
|---|
| 6621 | cmt_string extra_line;
|
|---|
| 6622 | cmt_string extra_file;
|
|---|
| 6623 |
|
|---|
| 6624 | if (argc <= 1)
|
|---|
| 6625 | {
|
|---|
| 6626 | do_help ();
|
|---|
| 6627 | exit (0);
|
|---|
| 6628 | }
|
|---|
| 6629 |
|
|---|
| 6630 | clear ();
|
|---|
| 6631 | configure ();
|
|---|
| 6632 |
|
|---|
| 6633 | CmtError::clear ();
|
|---|
| 6634 |
|
|---|
| 6635 | /*
|
|---|
| 6636 | Set private if positioned inside the package
|
|---|
| 6637 | (which is detected since we were able to retreive the
|
|---|
| 6638 | Version, Package and Path)
|
|---|
| 6639 | */
|
|---|
| 6640 |
|
|---|
| 6641 | if ((m_current_path.size () == 0) ||
|
|---|
| 6642 | (m_current_package.size () == 0) ||
|
|---|
| 6643 | (m_current_version.size () == 0))
|
|---|
| 6644 | {
|
|---|
| 6645 | m_current_access = UserMode;
|
|---|
| 6646 | }
|
|---|
| 6647 | else
|
|---|
| 6648 | {
|
|---|
| 6649 | m_current_access = DeveloperMode;
|
|---|
| 6650 | }
|
|---|
| 6651 |
|
|---|
| 6652 | parse_arguments (argc, argv, arguments,
|
|---|
| 6653 | extra_line, extra_file, mode);
|
|---|
| 6654 |
|
|---|
| 6655 | if (m_configure_error != "")
|
|---|
| 6656 | {
|
|---|
| 6657 | if (!m_quiet) cerr << "#CMT> Error: " << m_configure_error << endl;
|
|---|
| 6658 | return (CmtError::execution_error);
|
|---|
| 6659 | }
|
|---|
| 6660 |
|
|---|
| 6661 | if (CmtError::has_pending_error ())
|
|---|
| 6662 | {
|
|---|
| 6663 | int code = CmtError::get_last_error_code ();
|
|---|
| 6664 | if (!m_quiet) CmtError::print ();
|
|---|
| 6665 | clear ();
|
|---|
| 6666 |
|
|---|
| 6667 | return (code);
|
|---|
| 6668 | }
|
|---|
| 6669 |
|
|---|
| 6670 | if (m_debug)
|
|---|
| 6671 | {
|
|---|
| 6672 | cout << "After parse_argument> pack=" << m_current_package
|
|---|
| 6673 | << " m_current_tag=" << m_current_tag
|
|---|
| 6674 | << " cwd=" << CmtSystem::pwd ()
|
|---|
| 6675 | << endl;
|
|---|
| 6676 | }
|
|---|
| 6677 |
|
|---|
| 6678 | /*
|
|---|
| 6679 | Now actual requirements analysis can take place.
|
|---|
| 6680 |
|
|---|
| 6681 | Extra lines or files are analysed first.
|
|---|
| 6682 | */
|
|---|
| 6683 |
|
|---|
| 6684 | if (strlen (extra_file.c_str ()) > 0) SyntaxParser::parse_requirements (extra_file, (Use*) 0);
|
|---|
| 6685 | if (strlen (extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (extra_line, (Use*) 0);
|
|---|
| 6686 |
|
|---|
| 6687 | //
|
|---|
| 6688 | // For some of the actions, the CMT package must be automatically
|
|---|
| 6689 | // included
|
|---|
| 6690 | //
|
|---|
| 6691 |
|
|---|
| 6692 | if (m_debug) cout << "parser1> current_tag=" << m_current_tag << endl;
|
|---|
| 6693 |
|
|---|
| 6694 | if (m_help_action == action_help)
|
|---|
| 6695 | {
|
|---|
| 6696 | do_help (m_action);
|
|---|
| 6697 | return (0);
|
|---|
| 6698 | }
|
|---|
| 6699 |
|
|---|
| 6700 | switch (m_action)
|
|---|
| 6701 | {
|
|---|
| 6702 | // case action_none :
|
|---|
| 6703 | case action_awk :
|
|---|
| 6704 | case action_broadcast :
|
|---|
| 6705 | case action_build_constituent_makefile :
|
|---|
| 6706 | case action_build_constituents_makefile :
|
|---|
| 6707 | case action_build_dependencies :
|
|---|
| 6708 | case action_build_library_links :
|
|---|
| 6709 | case action_build_make_setup :
|
|---|
| 6710 | case action_build_msdev :
|
|---|
| 6711 | case action_build_CMT_pacman :
|
|---|
| 6712 | case action_build_vsnet :
|
|---|
| 6713 | case action_build_os9_makefile :
|
|---|
| 6714 | // case action_build_prototype :
|
|---|
| 6715 | case action_build_readme :
|
|---|
| 6716 | case action_build_tag_makefile :
|
|---|
| 6717 | // case action_build_temporary_name :
|
|---|
| 6718 | case action_build_triggers :
|
|---|
| 6719 | case action_build_windefs :
|
|---|
| 6720 | case action_check_configuration :
|
|---|
| 6721 | // case action_check_files :
|
|---|
| 6722 | // case action_check_version :
|
|---|
| 6723 | case action_checkout :
|
|---|
| 6724 | case action_cleanup :
|
|---|
| 6725 | case action_config :
|
|---|
| 6726 | case action_create :
|
|---|
| 6727 | // case action_create_project :
|
|---|
| 6728 | // case action_cvsbranches :
|
|---|
| 6729 | // case action_cvssubpackages :
|
|---|
| 6730 | // case action_cvstags :
|
|---|
| 6731 | case action_do :
|
|---|
| 6732 | case action_expand_model :
|
|---|
| 6733 | case action_filter :
|
|---|
| 6734 | // case action_help :
|
|---|
| 6735 | case action_load :
|
|---|
| 6736 | case action_lock :
|
|---|
| 6737 | case action_remove :
|
|---|
| 6738 | case action_remove_library_links :
|
|---|
| 6739 | case action_run :
|
|---|
| 6740 | case action_run_sequence :
|
|---|
| 6741 | case action_set_version :
|
|---|
| 6742 | case action_set_versions :
|
|---|
| 6743 | case action_setup :
|
|---|
| 6744 | case action_show_action :
|
|---|
| 6745 | case action_show_action_names :
|
|---|
| 6746 | case action_show_action_value :
|
|---|
| 6747 | case action_show_actions :
|
|---|
| 6748 | case action_show_all_tags :
|
|---|
| 6749 | case action_show_applied_patterns :
|
|---|
| 6750 | // case action_show_author :
|
|---|
| 6751 | // case action_show_branches :
|
|---|
| 6752 | // case action_show_clients :
|
|---|
| 6753 | case action_show_cmtpath_patterns :
|
|---|
| 6754 | // case action_show_constituent :
|
|---|
| 6755 | // case action_show_constituent_names :
|
|---|
| 6756 | // case action_show_constituents :
|
|---|
| 6757 | case action_show_cycles :
|
|---|
| 6758 | case action_show_fragment :
|
|---|
| 6759 | case action_show_fragments :
|
|---|
| 6760 | case action_show_groups :
|
|---|
| 6761 | case action_show_include_dirs :
|
|---|
| 6762 | case action_show_language :
|
|---|
| 6763 | case action_show_languages :
|
|---|
| 6764 | case action_show_macro :
|
|---|
| 6765 | case action_show_macro_names :
|
|---|
| 6766 | case action_show_macro_value :
|
|---|
| 6767 | case action_show_macros :
|
|---|
| 6768 | // case action_show_manager :
|
|---|
| 6769 | // case action_show_packages :
|
|---|
| 6770 | case action_show_path :
|
|---|
| 6771 | case action_show_pattern :
|
|---|
| 6772 | case action_show_pattern_names :
|
|---|
| 6773 | case action_show_patterns :
|
|---|
| 6774 | case action_show_projects :
|
|---|
| 6775 | // case action_show_pwd :
|
|---|
| 6776 | case action_show_setup :
|
|---|
| 6777 | case action_show_set :
|
|---|
| 6778 | case action_show_set_names :
|
|---|
| 6779 | case action_show_set_value :
|
|---|
| 6780 | case action_show_sets :
|
|---|
| 6781 | case action_show_strategies :
|
|---|
| 6782 | case action_show_tags :
|
|---|
| 6783 | case action_show_use_paths :
|
|---|
| 6784 | case action_show_uses :
|
|---|
| 6785 | case action_show_version :
|
|---|
| 6786 | // case action_show_versions :
|
|---|
| 6787 | // case action_system :
|
|---|
| 6788 | case action_unlock :
|
|---|
| 6789 | case action_version :
|
|---|
| 6790 | use_cmt ();
|
|---|
| 6791 | //
|
|---|
| 6792 | // Now parse the requirements file stored in ${CMTHOME}
|
|---|
| 6793 | //
|
|---|
| 6794 |
|
|---|
| 6795 | use_home_requirements ();
|
|---|
| 6796 |
|
|---|
| 6797 | break;
|
|---|
| 6798 | default:
|
|---|
| 6799 | break;
|
|---|
| 6800 | }
|
|---|
| 6801 |
|
|---|
| 6802 | if (m_debug) cout << "parser2> current_tag=" << m_current_tag << endl;
|
|---|
| 6803 |
|
|---|
| 6804 | //
|
|---|
| 6805 | // Setting up recursive actions
|
|---|
| 6806 | //
|
|---|
| 6807 |
|
|---|
| 6808 | switch (m_action)
|
|---|
| 6809 | {
|
|---|
| 6810 | // case action_none :
|
|---|
| 6811 | case action_awk :
|
|---|
| 6812 | case action_broadcast :
|
|---|
| 6813 | case action_build_constituent_makefile :
|
|---|
| 6814 | case action_build_constituents_makefile :
|
|---|
| 6815 | case action_build_dependencies :
|
|---|
| 6816 | case action_build_library_links :
|
|---|
| 6817 | case action_build_make_setup :
|
|---|
| 6818 | case action_build_msdev :
|
|---|
| 6819 | case action_build_CMT_pacman :
|
|---|
| 6820 | case action_build_vsnet :
|
|---|
| 6821 | case action_build_os9_makefile :
|
|---|
| 6822 | // case action_build_prototype :
|
|---|
| 6823 | case action_build_readme :
|
|---|
| 6824 | case action_build_tag_makefile :
|
|---|
| 6825 | // case action_build_temporary_name :
|
|---|
| 6826 | case action_build_triggers :
|
|---|
| 6827 | case action_build_windefs :
|
|---|
| 6828 | case action_check_configuration :
|
|---|
| 6829 | // case action_check_files :
|
|---|
| 6830 | // case action_check_version :
|
|---|
| 6831 | // case action_checkout :
|
|---|
| 6832 | case action_cleanup :
|
|---|
| 6833 | case action_config :
|
|---|
| 6834 | // case action_create :
|
|---|
| 6835 | // case action_create_project :
|
|---|
| 6836 | // case action_cvsbranches :
|
|---|
| 6837 | // case action_cvssubpackages :
|
|---|
| 6838 | // case action_cvstags :
|
|---|
| 6839 | case action_do :
|
|---|
| 6840 | case action_expand_model :
|
|---|
| 6841 | case action_filter :
|
|---|
| 6842 | // case action_help :
|
|---|
| 6843 | case action_load :
|
|---|
| 6844 | // case action_lock :
|
|---|
| 6845 | // case action_remove :
|
|---|
| 6846 | case action_remove_library_links :
|
|---|
| 6847 | case action_run :
|
|---|
| 6848 | case action_run_sequence :
|
|---|
| 6849 | // case action_set_version :
|
|---|
| 6850 | case action_set_versions :
|
|---|
| 6851 | case action_setup :
|
|---|
| 6852 | case action_show_action :
|
|---|
| 6853 | case action_show_action_names :
|
|---|
| 6854 | case action_show_action_value :
|
|---|
| 6855 | case action_show_actions :
|
|---|
| 6856 | case action_show_all_tags :
|
|---|
| 6857 | case action_show_applied_patterns :
|
|---|
| 6858 | // case action_show_author :
|
|---|
| 6859 | // case action_show_branches :
|
|---|
| 6860 | // case action_show_clients :
|
|---|
| 6861 | case action_show_cmtpath_patterns :
|
|---|
| 6862 | case action_show_constituent :
|
|---|
| 6863 | case action_show_constituent_names :
|
|---|
| 6864 | case action_show_constituents :
|
|---|
| 6865 | case action_show_cycles :
|
|---|
| 6866 | case action_show_fragment :
|
|---|
| 6867 | case action_show_fragments :
|
|---|
| 6868 | case action_show_groups :
|
|---|
| 6869 | case action_show_include_dirs :
|
|---|
| 6870 | case action_show_language :
|
|---|
| 6871 | case action_show_languages :
|
|---|
| 6872 | case action_show_macro :
|
|---|
| 6873 | case action_show_macro_names :
|
|---|
| 6874 | case action_show_macro_value :
|
|---|
| 6875 | case action_show_macros :
|
|---|
| 6876 | // case action_show_manager :
|
|---|
| 6877 | // case action_show_packages :
|
|---|
| 6878 | case action_show_path :
|
|---|
| 6879 | case action_show_pattern :
|
|---|
| 6880 | case action_show_pattern_names :
|
|---|
| 6881 | case action_show_patterns :
|
|---|
| 6882 | case action_show_projects :
|
|---|
| 6883 | // case action_show_pwd :
|
|---|
| 6884 | case action_show_setup :
|
|---|
| 6885 | case action_show_set :
|
|---|
| 6886 | case action_show_set_names :
|
|---|
| 6887 | case action_show_set_value :
|
|---|
| 6888 | case action_show_sets :
|
|---|
| 6889 | case action_show_strategies :
|
|---|
| 6890 | case action_show_tags :
|
|---|
| 6891 | case action_show_use_paths :
|
|---|
| 6892 | case action_show_uses :
|
|---|
| 6893 | // case action_show_version :
|
|---|
| 6894 | // case action_show_versions :
|
|---|
| 6895 | // case action_system :
|
|---|
| 6896 | // case action_unlock :
|
|---|
| 6897 | // case action_version :
|
|---|
| 6898 | m_recursive = true;
|
|---|
| 6899 | break;
|
|---|
| 6900 | default:
|
|---|
| 6901 | m_recursive = false;
|
|---|
| 6902 | break;
|
|---|
| 6903 | }
|
|---|
| 6904 |
|
|---|
| 6905 | //
|
|---|
| 6906 | // Actions for which the context of the package is checked,
|
|---|
| 6907 | // and the requirements file is analysed.
|
|---|
| 6908 | //
|
|---|
| 6909 |
|
|---|
| 6910 | switch (m_action)
|
|---|
| 6911 | {
|
|---|
| 6912 | case action_none :
|
|---|
| 6913 | case action_awk :
|
|---|
| 6914 | case action_broadcast :
|
|---|
| 6915 | case action_build_constituent_makefile :
|
|---|
| 6916 | case action_build_constituents_makefile :
|
|---|
| 6917 | case action_build_dependencies :
|
|---|
| 6918 | case action_build_library_links :
|
|---|
| 6919 | case action_build_make_setup :
|
|---|
| 6920 | case action_build_msdev :
|
|---|
| 6921 | case action_build_CMT_pacman :
|
|---|
| 6922 | case action_build_vsnet :
|
|---|
| 6923 | case action_build_os9_makefile :
|
|---|
| 6924 | // case action_build_prototype :
|
|---|
| 6925 | case action_build_readme :
|
|---|
| 6926 | case action_build_tag_makefile :
|
|---|
| 6927 | // case action_build_temporary_name :
|
|---|
| 6928 | case action_build_triggers :
|
|---|
| 6929 | case action_build_windefs :
|
|---|
| 6930 | case action_check_configuration :
|
|---|
| 6931 | // case action_check_files :
|
|---|
| 6932 | // case action_check_version :
|
|---|
| 6933 | // case action_checkout :
|
|---|
| 6934 | case action_cleanup :
|
|---|
| 6935 | case action_config :
|
|---|
| 6936 | // case action_create :
|
|---|
| 6937 | // case action_create_project :
|
|---|
| 6938 | // case action_cvsbranches :
|
|---|
| 6939 | // case action_cvssubpackages :
|
|---|
| 6940 | // case action_cvstags :
|
|---|
| 6941 | case action_do :
|
|---|
| 6942 | case action_expand_model :
|
|---|
| 6943 | case action_filter :
|
|---|
| 6944 | // case action_help :
|
|---|
| 6945 | case action_load :
|
|---|
| 6946 | case action_lock :
|
|---|
| 6947 | // case action_remove :
|
|---|
| 6948 | case action_remove_library_links :
|
|---|
| 6949 | case action_run :
|
|---|
| 6950 | // case action_run_sequence :
|
|---|
| 6951 | // case action_set_version :
|
|---|
| 6952 | case action_set_versions :
|
|---|
| 6953 | case action_setup :
|
|---|
| 6954 | case action_show_action :
|
|---|
| 6955 | case action_show_action_names :
|
|---|
| 6956 | case action_show_action_value :
|
|---|
| 6957 | case action_show_actions :
|
|---|
| 6958 | case action_show_all_tags :
|
|---|
| 6959 | case action_show_applied_patterns :
|
|---|
| 6960 | case action_show_author :
|
|---|
| 6961 | case action_show_branches :
|
|---|
| 6962 | // case action_show_clients :
|
|---|
| 6963 | case action_show_cmtpath_patterns :
|
|---|
| 6964 | case action_show_constituent :
|
|---|
| 6965 | case action_show_constituent_names :
|
|---|
| 6966 | case action_show_constituents :
|
|---|
| 6967 | case action_show_cycles :
|
|---|
| 6968 | case action_show_fragment :
|
|---|
| 6969 | case action_show_fragments :
|
|---|
| 6970 | case action_show_groups :
|
|---|
| 6971 | case action_show_include_dirs :
|
|---|
| 6972 | case action_show_language :
|
|---|
| 6973 | case action_show_languages :
|
|---|
| 6974 | case action_show_macro :
|
|---|
| 6975 | case action_show_macro_names :
|
|---|
| 6976 | case action_show_macro_value :
|
|---|
| 6977 | case action_show_macros :
|
|---|
| 6978 | case action_show_manager :
|
|---|
| 6979 | // case action_show_packages :
|
|---|
| 6980 | case action_show_path :
|
|---|
| 6981 | case action_show_pattern :
|
|---|
| 6982 | case action_show_pattern_names :
|
|---|
| 6983 | case action_show_patterns :
|
|---|
| 6984 | case action_show_projects :
|
|---|
| 6985 | case action_show_pwd :
|
|---|
| 6986 | case action_show_setup :
|
|---|
| 6987 | case action_show_set :
|
|---|
| 6988 | case action_show_set_names :
|
|---|
| 6989 | case action_show_set_value :
|
|---|
| 6990 | case action_show_sets :
|
|---|
| 6991 | case action_show_strategies :
|
|---|
| 6992 | case action_show_tags :
|
|---|
| 6993 | case action_show_use_paths :
|
|---|
| 6994 | case action_show_uses :
|
|---|
| 6995 | case action_show_version :
|
|---|
| 6996 | // case action_show_versions :
|
|---|
| 6997 | // case action_system :
|
|---|
| 6998 | case action_unlock :
|
|---|
| 6999 | // case action_version :
|
|---|
| 7000 | reach_current_package ();
|
|---|
| 7001 | use_user_context_requirements ();
|
|---|
| 7002 | break;
|
|---|
| 7003 | default:
|
|---|
| 7004 | break;
|
|---|
| 7005 | }
|
|---|
| 7006 |
|
|---|
| 7007 | if (m_debug) cout << "parser3> current_tag=" << m_current_tag << endl;
|
|---|
| 7008 |
|
|---|
| 7009 | //
|
|---|
| 7010 | // Perform some actions even if there is an error
|
|---|
| 7011 | //
|
|---|
| 7012 |
|
|---|
| 7013 | if (CmtError::has_pending_error ())
|
|---|
| 7014 | {
|
|---|
| 7015 | int code = CmtError::get_last_error_code ();
|
|---|
| 7016 | if (!m_quiet) CmtError::print ();
|
|---|
| 7017 |
|
|---|
| 7018 | switch (m_action)
|
|---|
| 7019 | {
|
|---|
| 7020 | // case action_none :
|
|---|
| 7021 | // case action_awk :
|
|---|
| 7022 | // case action_broadcast :
|
|---|
| 7023 | case action_build_constituent_makefile :
|
|---|
| 7024 | case action_build_constituents_makefile :
|
|---|
| 7025 | case action_build_dependencies :
|
|---|
| 7026 | case action_build_library_links :
|
|---|
| 7027 | case action_build_make_setup :
|
|---|
| 7028 | case action_build_msdev :
|
|---|
| 7029 | case action_build_CMT_pacman :
|
|---|
| 7030 | case action_build_vsnet :
|
|---|
| 7031 | case action_build_os9_makefile :
|
|---|
| 7032 | case action_build_prototype :
|
|---|
| 7033 | case action_build_readme :
|
|---|
| 7034 | case action_build_tag_makefile :
|
|---|
| 7035 | // case action_build_temporary_name :
|
|---|
| 7036 | case action_build_triggers :
|
|---|
| 7037 | case action_build_windefs :
|
|---|
| 7038 | case action_check_configuration :
|
|---|
| 7039 | // case action_check_files :
|
|---|
| 7040 | // case action_check_version :
|
|---|
| 7041 | // case action_checkout :
|
|---|
| 7042 | case action_cleanup :
|
|---|
| 7043 | // case action_config :
|
|---|
| 7044 | // case action_create :
|
|---|
| 7045 | // case action_create_project :
|
|---|
| 7046 | // case action_cvsbranches :
|
|---|
| 7047 | // case action_cvssubpackages :
|
|---|
| 7048 | // case action_cvstags :
|
|---|
| 7049 | // case action_do :
|
|---|
| 7050 | // case action_expand_model :
|
|---|
| 7051 | // case action_filter :
|
|---|
| 7052 | // case action_help :
|
|---|
| 7053 | case action_load :
|
|---|
| 7054 | case action_lock :
|
|---|
| 7055 | case action_remove :
|
|---|
| 7056 | case action_remove_library_links :
|
|---|
| 7057 | // case action_run :
|
|---|
| 7058 | case action_run_sequence :
|
|---|
| 7059 | // case action_set_version :
|
|---|
| 7060 | // case action_set_versions :
|
|---|
| 7061 | case action_setup :
|
|---|
| 7062 | // case action_show_action :
|
|---|
| 7063 | // case action_show_action_names :
|
|---|
| 7064 | // case action_show_action_value :
|
|---|
| 7065 | // case action_show_actions :
|
|---|
| 7066 | // case action_show_all_tags :
|
|---|
| 7067 | // case action_show_applied_patterns :
|
|---|
| 7068 | // case action_show_author :
|
|---|
| 7069 | // case action_show_branches :
|
|---|
| 7070 | // case action_show_clients :
|
|---|
| 7071 | // case action_show_cmtpath_patterns :
|
|---|
| 7072 | // case action_show_constituent :
|
|---|
| 7073 | // case action_show_constituent_names :
|
|---|
| 7074 | // case action_show_constituents :
|
|---|
| 7075 | // case action_show_cycles :
|
|---|
| 7076 | // case action_show_fragment :
|
|---|
| 7077 | // case action_show_fragments :
|
|---|
| 7078 | // case action_show_groups :
|
|---|
| 7079 | // case action_show_include_dirs :
|
|---|
| 7080 | // case action_show_language :
|
|---|
| 7081 | // case action_show_languages :
|
|---|
| 7082 | // case action_show_macro :
|
|---|
| 7083 | // case action_show_macro_names :
|
|---|
| 7084 | // case action_show_macro_value :
|
|---|
| 7085 | // case action_show_macros :
|
|---|
| 7086 | // case action_show_manager :
|
|---|
| 7087 | // case action_show_packages :
|
|---|
| 7088 | // case action_show_path :
|
|---|
| 7089 | // case action_show_pattern :
|
|---|
| 7090 | // case action_show_pattern_names :
|
|---|
| 7091 | // case action_show_patterns :
|
|---|
| 7092 | // case action_show_projects :
|
|---|
| 7093 | // case action_show_pwd :
|
|---|
| 7094 | // case action_show_setup :
|
|---|
| 7095 | // case action_show_set :
|
|---|
| 7096 | // case action_show_set_names :
|
|---|
| 7097 | // case action_show_set_value :
|
|---|
| 7098 | // case action_show_sets :
|
|---|
| 7099 | // case action_show_strategies :
|
|---|
| 7100 | // case action_show_tags :
|
|---|
| 7101 | // case action_show_use_paths :
|
|---|
| 7102 | // case action_show_uses :
|
|---|
| 7103 | // case action_show_version :
|
|---|
| 7104 | // case action_show_versions :
|
|---|
| 7105 | // case action_system :
|
|---|
| 7106 | case action_unlock :
|
|---|
| 7107 | // case action_version :
|
|---|
| 7108 | clear ();
|
|---|
| 7109 | return (code);
|
|---|
| 7110 | default:
|
|---|
| 7111 | CmtError::clear ();
|
|---|
| 7112 | break;
|
|---|
| 7113 | }
|
|---|
| 7114 | }
|
|---|
| 7115 |
|
|---|
| 7116 | //
|
|---|
| 7117 | // Perform actions
|
|---|
| 7118 | //
|
|---|
| 7119 |
|
|---|
| 7120 | switch (m_action)
|
|---|
| 7121 | {
|
|---|
| 7122 | case action_none :
|
|---|
| 7123 | //CmtError::set (CmtError::syntax_error, "ParseArguments> ");
|
|---|
| 7124 | break;
|
|---|
| 7125 | case action_awk :
|
|---|
| 7126 | do_awk (arguments);
|
|---|
| 7127 | break;
|
|---|
| 7128 | case action_broadcast :
|
|---|
| 7129 | do_broadcast (arguments, argc, argv);
|
|---|
| 7130 | break;
|
|---|
| 7131 | case action_build_constituent_makefile :
|
|---|
| 7132 | do_build_constituent_makefile (arguments, argc, argv);
|
|---|
| 7133 | break;
|
|---|
| 7134 | case action_build_constituents_makefile :
|
|---|
| 7135 | do_build_constituents_makefile (arguments, argc, argv);
|
|---|
| 7136 | break;
|
|---|
| 7137 | case action_build_dependencies :
|
|---|
| 7138 | do_build_dependencies (arguments, argc, argv);
|
|---|
| 7139 | break;
|
|---|
| 7140 | case action_build_library_links :
|
|---|
| 7141 | do_build_library_links ();
|
|---|
| 7142 | break;
|
|---|
| 7143 | case action_build_make_setup :
|
|---|
| 7144 | do_build_make_setup ();
|
|---|
| 7145 | break;
|
|---|
| 7146 | case action_build_msdev :
|
|---|
| 7147 | do_build_msdev (arguments);
|
|---|
| 7148 | break;
|
|---|
| 7149 | case action_build_CMT_pacman :
|
|---|
| 7150 | do_build_CMT_pacman ();
|
|---|
| 7151 | break;
|
|---|
| 7152 | case action_build_vsnet :
|
|---|
| 7153 | do_build_vsnet (arguments);
|
|---|
| 7154 | break;
|
|---|
| 7155 | case action_build_os9_makefile :
|
|---|
| 7156 | do_build_os9_makefile (arguments);
|
|---|
| 7157 | break;
|
|---|
| 7158 | case action_build_prototype :
|
|---|
| 7159 | do_build_prototype (arguments);
|
|---|
| 7160 | break;
|
|---|
| 7161 | case action_build_readme :
|
|---|
| 7162 | do_build_readme (arguments);
|
|---|
| 7163 | break;
|
|---|
| 7164 | case action_build_tag_makefile :
|
|---|
| 7165 | do_build_tag_makefile ();
|
|---|
| 7166 | break;
|
|---|
| 7167 | case action_build_temporary_name :
|
|---|
| 7168 | do_build_temporary_name ();
|
|---|
| 7169 | break;
|
|---|
| 7170 | case action_build_triggers :
|
|---|
| 7171 | do_build_triggers (arguments);
|
|---|
| 7172 | break;
|
|---|
| 7173 | case action_build_windefs :
|
|---|
| 7174 | do_build_windefs (arguments);
|
|---|
| 7175 | break;
|
|---|
| 7176 | case action_check_configuration :
|
|---|
| 7177 | do_check_configuration ();
|
|---|
| 7178 | break;
|
|---|
| 7179 | case action_check_files :
|
|---|
| 7180 | do_check_files (arguments);
|
|---|
| 7181 | break;
|
|---|
| 7182 | case action_check_version :
|
|---|
| 7183 | do_check_version (arguments);
|
|---|
| 7184 | break;
|
|---|
| 7185 | case action_checkout :
|
|---|
| 7186 | do_checkout (arguments);
|
|---|
| 7187 | break;
|
|---|
| 7188 | case action_cleanup :
|
|---|
| 7189 | do_cleanup (mode);
|
|---|
| 7190 | break;
|
|---|
| 7191 | case action_config :
|
|---|
| 7192 | do_config ();
|
|---|
| 7193 | break;
|
|---|
| 7194 | case action_create :
|
|---|
| 7195 | do_create (arguments);
|
|---|
| 7196 | break;
|
|---|
| 7197 | case action_create_project :
|
|---|
| 7198 | do_create_project (arguments);
|
|---|
| 7199 | break;
|
|---|
| 7200 | case action_cvsbranches :
|
|---|
| 7201 | do_cvsbranches (arguments);
|
|---|
| 7202 | break;
|
|---|
| 7203 | case action_cvssubpackages :
|
|---|
| 7204 | do_cvssubpackages (arguments);
|
|---|
| 7205 | break;
|
|---|
| 7206 | case action_cvstags :
|
|---|
| 7207 | do_cvstags (arguments);
|
|---|
| 7208 | break;
|
|---|
| 7209 | case action_do :
|
|---|
| 7210 | do_do (arguments);
|
|---|
| 7211 | break;
|
|---|
| 7212 | case action_expand_model :
|
|---|
| 7213 | do_expand_model (arguments);
|
|---|
| 7214 | break;
|
|---|
| 7215 | case action_filter :
|
|---|
| 7216 | do_filter (arguments);
|
|---|
| 7217 | break;
|
|---|
| 7218 | case action_help :
|
|---|
| 7219 | do_help (m_help_action);
|
|---|
| 7220 | break;
|
|---|
| 7221 | case action_load :
|
|---|
| 7222 | cerr << "#CMT> action not implemented" << endl;
|
|---|
| 7223 | break;
|
|---|
| 7224 | case action_lock :
|
|---|
| 7225 | do_lock (m_current_package, m_current_version, m_current_path);
|
|---|
| 7226 | break;
|
|---|
| 7227 | case action_remove :
|
|---|
| 7228 | do_remove (m_current_package, m_current_version, m_current_path);
|
|---|
| 7229 | break;
|
|---|
| 7230 | case action_remove_library_links :
|
|---|
| 7231 | do_remove_library_links ();
|
|---|
| 7232 | break;
|
|---|
| 7233 | case action_run :
|
|---|
| 7234 | do_run (arguments);
|
|---|
| 7235 | break;
|
|---|
| 7236 | case action_run_sequence :
|
|---|
| 7237 | do_run_sequence (arguments);
|
|---|
| 7238 | break;
|
|---|
| 7239 | case action_set_version :
|
|---|
| 7240 | do_set_version (arguments);
|
|---|
| 7241 | break;
|
|---|
| 7242 | case action_set_versions :
|
|---|
| 7243 | do_set_versions (arguments);
|
|---|
| 7244 | break;
|
|---|
| 7245 | case action_setup :
|
|---|
| 7246 | do_setup (mode);
|
|---|
| 7247 | break;
|
|---|
| 7248 | case action_show_action :
|
|---|
| 7249 | do_show_action (arguments, mode);
|
|---|
| 7250 | break;
|
|---|
| 7251 | case action_show_action_names :
|
|---|
| 7252 | do_show_action_names (arguments, mode);
|
|---|
| 7253 | break;
|
|---|
| 7254 | case action_show_action_value :
|
|---|
| 7255 | do_show_action_value (arguments, mode);
|
|---|
| 7256 | break;
|
|---|
| 7257 | case action_show_actions :
|
|---|
| 7258 | do_show_actions (arguments, mode);
|
|---|
| 7259 | break;
|
|---|
| 7260 | case action_show_all_tags :
|
|---|
| 7261 | do_show_all_tags ();
|
|---|
| 7262 | break;
|
|---|
| 7263 | case action_show_applied_patterns :
|
|---|
| 7264 | do_show_applied_patterns ();
|
|---|
| 7265 | break;
|
|---|
| 7266 | case action_show_author :
|
|---|
| 7267 | do_show_author ();
|
|---|
| 7268 | break;
|
|---|
| 7269 | case action_show_branches :
|
|---|
| 7270 | do_show_branches (mode);
|
|---|
| 7271 | break;
|
|---|
| 7272 | case action_show_clients :
|
|---|
| 7273 | do_show_clients (arguments);
|
|---|
| 7274 | break;
|
|---|
| 7275 | case action_show_cmtpath_patterns :
|
|---|
| 7276 | do_show_cmtpath_patterns ();
|
|---|
| 7277 | break;
|
|---|
| 7278 | case action_show_constituent :
|
|---|
| 7279 | do_show_constituent (arguments);
|
|---|
| 7280 | break;
|
|---|
| 7281 | case action_show_constituent_names :
|
|---|
| 7282 | do_show_constituent_names ();
|
|---|
| 7283 | break;
|
|---|
| 7284 | case action_show_constituents :
|
|---|
| 7285 | do_show_constituents ();
|
|---|
| 7286 | break;
|
|---|
| 7287 | case action_show_cycles :
|
|---|
| 7288 | do_show_cycles ();
|
|---|
| 7289 | break;
|
|---|
| 7290 | case action_show_fragment :
|
|---|
| 7291 | do_show_fragment (arguments);
|
|---|
| 7292 | break;
|
|---|
| 7293 | case action_show_fragments :
|
|---|
| 7294 | do_show_fragments ();
|
|---|
| 7295 | break;
|
|---|
| 7296 | case action_show_groups :
|
|---|
| 7297 | do_show_groups ();
|
|---|
| 7298 | break;
|
|---|
| 7299 | case action_show_include_dirs :
|
|---|
| 7300 | do_show_include_dirs ();
|
|---|
| 7301 | break;
|
|---|
| 7302 | case action_show_language :
|
|---|
| 7303 | do_show_language (arguments);
|
|---|
| 7304 | break;
|
|---|
| 7305 | case action_show_languages :
|
|---|
| 7306 | do_show_languages ();
|
|---|
| 7307 | break;
|
|---|
| 7308 | case action_show_macro :
|
|---|
| 7309 | do_show_macro (arguments, mode);
|
|---|
| 7310 | break;
|
|---|
| 7311 | case action_show_macro_names :
|
|---|
| 7312 | do_show_macro_names (arguments, mode);
|
|---|
| 7313 | break;
|
|---|
| 7314 | case action_show_macro_value :
|
|---|
| 7315 | do_show_macro_value (arguments, mode);
|
|---|
| 7316 | break;
|
|---|
| 7317 | case action_show_macros :
|
|---|
| 7318 | do_show_macros (arguments, mode);
|
|---|
| 7319 | break;
|
|---|
| 7320 | case action_show_manager :
|
|---|
| 7321 | do_show_manager ();
|
|---|
| 7322 | break;
|
|---|
| 7323 | case action_show_packages :
|
|---|
| 7324 | do_show_packages (arguments);
|
|---|
| 7325 | break;
|
|---|
| 7326 | case action_show_path :
|
|---|
| 7327 | do_show_path ();
|
|---|
| 7328 | break;
|
|---|
| 7329 | case action_show_pattern :
|
|---|
| 7330 | do_show_pattern (arguments);
|
|---|
| 7331 | break;
|
|---|
| 7332 | case action_show_pattern_names :
|
|---|
| 7333 | do_show_pattern_names ();
|
|---|
| 7334 | break;
|
|---|
| 7335 | case action_show_patterns :
|
|---|
| 7336 | do_show_patterns ();
|
|---|
| 7337 | break;
|
|---|
| 7338 | case action_show_projects :
|
|---|
| 7339 | do_show_projects ();
|
|---|
| 7340 | break;
|
|---|
| 7341 | case action_show_pwd :
|
|---|
| 7342 | do_show_pwd ();
|
|---|
| 7343 | break;
|
|---|
| 7344 | case action_show_setup :
|
|---|
| 7345 | do_show_setup ();
|
|---|
| 7346 | break;
|
|---|
| 7347 | case action_show_set :
|
|---|
| 7348 | do_show_set (arguments, mode);
|
|---|
| 7349 | break;
|
|---|
| 7350 | case action_show_set_names :
|
|---|
| 7351 | do_show_set_names (arguments, mode);
|
|---|
| 7352 | break;
|
|---|
| 7353 | case action_show_set_value :
|
|---|
| 7354 | do_show_set_value (arguments, mode);
|
|---|
| 7355 | break;
|
|---|
| 7356 | case action_show_sets :
|
|---|
| 7357 | do_show_sets (arguments, mode);
|
|---|
| 7358 | break;
|
|---|
| 7359 | case action_show_strategies :
|
|---|
| 7360 | do_show_strategies ();
|
|---|
| 7361 | break;
|
|---|
| 7362 | case action_show_tags :
|
|---|
| 7363 | do_show_tags ();
|
|---|
| 7364 | break;
|
|---|
| 7365 | case action_show_use_paths :
|
|---|
| 7366 | do_show_use_paths (arguments);
|
|---|
| 7367 | break;
|
|---|
| 7368 | case action_show_uses :
|
|---|
| 7369 | do_show_uses ();
|
|---|
| 7370 | break;
|
|---|
| 7371 | case action_show_version :
|
|---|
| 7372 | do_show_version ();
|
|---|
| 7373 | break;
|
|---|
| 7374 | case action_show_versions :
|
|---|
| 7375 | do_show_versions (arguments);
|
|---|
| 7376 | break;
|
|---|
| 7377 | case action_system :
|
|---|
| 7378 | do_show_system ();
|
|---|
| 7379 | break;
|
|---|
| 7380 | case action_unlock :
|
|---|
| 7381 | do_unlock (m_current_package, m_current_version, m_current_path);
|
|---|
| 7382 | break;
|
|---|
| 7383 | case action_version :
|
|---|
| 7384 | do_version ();
|
|---|
| 7385 | break;
|
|---|
| 7386 | default:
|
|---|
| 7387 | CmtError::set (CmtError::syntax_error, "ParseArguments>");
|
|---|
| 7388 | break;
|
|---|
| 7389 | }
|
|---|
| 7390 |
|
|---|
| 7391 | if (CmtError::has_pending_error ())
|
|---|
| 7392 | {
|
|---|
| 7393 | int code = CmtError::get_last_error_code ();
|
|---|
| 7394 | if (!m_quiet) CmtError::print ();
|
|---|
| 7395 | clear ();
|
|---|
| 7396 | return (code);
|
|---|
| 7397 | }
|
|---|
| 7398 | else
|
|---|
| 7399 | {
|
|---|
| 7400 | clear ();
|
|---|
| 7401 | return (0);
|
|---|
| 7402 | }
|
|---|
| 7403 | }
|
|---|
| 7404 |
|
|---|
| 7405 |
|
|---|
| 7406 | /**
|
|---|
| 7407 | * Format as one single line a set of 'setenv' statements
|
|---|
| 7408 | * joined with semi-colons to form one shell command.
|
|---|
| 7409 | */
|
|---|
| 7410 | void Cmt::print (PrintMode mode)
|
|---|
| 7411 | {
|
|---|
| 7412 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 7413 | Use& current_use = Use::current ();
|
|---|
| 7414 |
|
|---|
| 7415 | cmt_string tag;
|
|---|
| 7416 |
|
|---|
| 7417 | set_standard_macros ();
|
|---|
| 7418 |
|
|---|
| 7419 | //cerr << "# current_tag=" << m_current_tag << endl;
|
|---|
| 7420 | //cerr << "# current_config=" << m_current_config << endl;
|
|---|
| 7421 |
|
|---|
| 7422 | if (m_current_tag == "")
|
|---|
| 7423 | {
|
|---|
| 7424 | if (mode == Bat) tag = "%CMTCONFIG%";
|
|---|
| 7425 | else tag = "${CMTCONFIG}";
|
|---|
| 7426 | }
|
|---|
| 7427 | else
|
|---|
| 7428 | {
|
|---|
| 7429 | tag = m_current_tag;
|
|---|
| 7430 | }
|
|---|
| 7431 |
|
|---|
| 7432 | //
|
|---|
| 7433 | // Now check if all extra tags are still valid. Some of them
|
|---|
| 7434 | // may be discarded du to some conflict with highest priority
|
|---|
| 7435 | // tags, or with exclude statements
|
|---|
| 7436 | //
|
|---|
| 7437 |
|
|---|
| 7438 | {
|
|---|
| 7439 | CmtSystem::cmt_string_vector words;
|
|---|
| 7440 |
|
|---|
| 7441 | cmt_string tags;
|
|---|
| 7442 |
|
|---|
| 7443 | tags = Cmt::m_extra_tags;
|
|---|
| 7444 |
|
|---|
| 7445 | CmtSystem::split (tags, " \t,", words);
|
|---|
| 7446 |
|
|---|
| 7447 | Cmt::m_extra_tags = ",";
|
|---|
| 7448 |
|
|---|
| 7449 | for (int i = 0; i < words.size (); i++)
|
|---|
| 7450 | {
|
|---|
| 7451 | Tag* tag;
|
|---|
| 7452 | const cmt_string& a = words[i];
|
|---|
| 7453 |
|
|---|
| 7454 | tag = Tag::find (a);
|
|---|
| 7455 |
|
|---|
| 7456 | if ((tag != 0) && (tag->is_selected ()))
|
|---|
| 7457 | {
|
|---|
| 7458 | Cmt::m_extra_tags += a;
|
|---|
| 7459 | Cmt::m_extra_tags += ",";
|
|---|
| 7460 | }
|
|---|
| 7461 | }
|
|---|
| 7462 | }
|
|---|
| 7463 |
|
|---|
| 7464 | if (m_debug)
|
|---|
| 7465 | {
|
|---|
| 7466 | cout << "Before all print contexts" << endl;
|
|---|
| 7467 | }
|
|---|
| 7468 |
|
|---|
| 7469 | if (Uses.size () > 0)
|
|---|
| 7470 | {
|
|---|
| 7471 | int number;
|
|---|
| 7472 |
|
|---|
| 7473 | for (number = 0; number < Uses.size (); number++)
|
|---|
| 7474 | {
|
|---|
| 7475 | Use& use = *(Uses[number]);
|
|---|
| 7476 |
|
|---|
| 7477 | if (use.discarded) continue;
|
|---|
| 7478 |
|
|---|
| 7479 | print_context (use, mode, tag);
|
|---|
| 7480 | }
|
|---|
| 7481 | }
|
|---|
| 7482 |
|
|---|
| 7483 | print_context (Use::current (), mode, tag);
|
|---|
| 7484 |
|
|---|
| 7485 | if (m_debug)
|
|---|
| 7486 | {
|
|---|
| 7487 | cout << "After all print contexts" << endl;
|
|---|
| 7488 | }
|
|---|
| 7489 |
|
|---|
| 7490 | Symbol::all_print (mode);
|
|---|
| 7491 | // Script::all_print (mode);
|
|---|
| 7492 |
|
|---|
| 7493 | if (m_debug)
|
|---|
| 7494 | {
|
|---|
| 7495 | cout << "After all print" << endl;
|
|---|
| 7496 | }
|
|---|
| 7497 |
|
|---|
| 7498 | cout << endl;
|
|---|
| 7499 | }
|
|---|
| 7500 |
|
|---|
| 7501 |
|
|---|
| 7502 | /**
|
|---|
| 7503 | * Format as one single line a set of 'unsetenv' statements
|
|---|
| 7504 | * joined with semi-colons to form one shell command.
|
|---|
| 7505 | */
|
|---|
| 7506 | void Cmt::print_clean (PrintMode mode)
|
|---|
| 7507 | {
|
|---|
| 7508 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 7509 |
|
|---|
| 7510 | set_standard_macros ();
|
|---|
| 7511 |
|
|---|
| 7512 | Script::all_print_clean (mode);
|
|---|
| 7513 | Symbol::all_print_clean (mode);
|
|---|
| 7514 |
|
|---|
| 7515 | switch (mode)
|
|---|
| 7516 | {
|
|---|
| 7517 | case Csh :
|
|---|
| 7518 | if (m_current_package != "CMT")
|
|---|
| 7519 | {
|
|---|
| 7520 | cout << "unsetenv " << m_current_prefix << "ROOT" << endl;
|
|---|
| 7521 | cout << "unsetenv " << m_current_prefix << "CONFIG" << endl;
|
|---|
| 7522 | }
|
|---|
| 7523 | break;
|
|---|
| 7524 | case Sh :
|
|---|
| 7525 | if (m_current_package != "CMT")
|
|---|
| 7526 | {
|
|---|
| 7527 | cout << "unset " << m_current_prefix << "ROOT" << endl;
|
|---|
| 7528 | cout << "unset " << m_current_prefix << "CONFIG" << endl;
|
|---|
| 7529 | }
|
|---|
| 7530 | break;
|
|---|
| 7531 | case Bat :
|
|---|
| 7532 | if (m_current_package != "CMT")
|
|---|
| 7533 | {
|
|---|
| 7534 | cout << "set " << m_current_prefix << "ROOT=" << endl;
|
|---|
| 7535 | cout << "set " << m_current_prefix << "CONFIG=" << endl;
|
|---|
| 7536 | }
|
|---|
| 7537 | break;
|
|---|
| 7538 | }
|
|---|
| 7539 |
|
|---|
| 7540 | if (Uses.size () > 0)
|
|---|
| 7541 | {
|
|---|
| 7542 | int number;
|
|---|
| 7543 |
|
|---|
| 7544 | for (number = 0; number < Uses.size (); number++)
|
|---|
| 7545 | {
|
|---|
| 7546 | Use* use = Uses[number];
|
|---|
| 7547 |
|
|---|
| 7548 | if (use->discarded) continue;
|
|---|
| 7549 |
|
|---|
| 7550 | Package* p = use->get_package ();
|
|---|
| 7551 | if (p->is_cmt ()) continue;
|
|---|
| 7552 |
|
|---|
| 7553 | switch (mode)
|
|---|
| 7554 | {
|
|---|
| 7555 | case Csh :
|
|---|
| 7556 | cout << "unsetenv " << use->prefix << "ROOT" << endl;
|
|---|
| 7557 | cout << "unsetenv " << use->prefix << "CONFIG" << endl;
|
|---|
| 7558 | break;
|
|---|
| 7559 | case Sh :
|
|---|
| 7560 | cout << "unset " << use->prefix << "ROOT" << endl;
|
|---|
| 7561 | cout << "unset " << use->prefix << "CONFIG" << endl;
|
|---|
| 7562 | break;
|
|---|
| 7563 | case Bat :
|
|---|
| 7564 | cout << "set " << use->prefix << "ROOT=" << endl;
|
|---|
| 7565 | cout << "set " << use->prefix << "CONFIG" << endl;
|
|---|
| 7566 | break;
|
|---|
| 7567 | }
|
|---|
| 7568 | }
|
|---|
| 7569 | }
|
|---|
| 7570 |
|
|---|
| 7571 | switch (mode)
|
|---|
| 7572 | {
|
|---|
| 7573 | case Csh :
|
|---|
| 7574 | cout << "unsetenv CMTEXTRATAGS" << endl;
|
|---|
| 7575 | break;
|
|---|
| 7576 | case Sh :
|
|---|
| 7577 | cout << "unset CMTEXTRATAGS" << endl;
|
|---|
| 7578 | break;
|
|---|
| 7579 | case Bat :
|
|---|
| 7580 | cout << "set CMTEXTRATAGS=" << endl;
|
|---|
| 7581 | break;
|
|---|
| 7582 | }
|
|---|
| 7583 |
|
|---|
| 7584 | cout << endl;
|
|---|
| 7585 | }
|
|---|
| 7586 |
|
|---|
| 7587 | //----------------------------------------------------------
|
|---|
| 7588 | void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag)
|
|---|
| 7589 | {
|
|---|
| 7590 | if (use.get_package_name () == "cmt_standalone") return;
|
|---|
| 7591 |
|
|---|
| 7592 | cmt_string fs = CmtSystem::file_separator ();
|
|---|
| 7593 |
|
|---|
| 7594 | use.real_path.replace_all (CmtSystem::file_separator (), fs);
|
|---|
| 7595 |
|
|---|
| 7596 | cmt_string system = CmtSystem::get_cmt_config ();
|
|---|
| 7597 |
|
|---|
| 7598 | Project* p = Project::get_current ();
|
|---|
| 7599 | int strategy = 0;
|
|---|
| 7600 |
|
|---|
| 7601 | strategy = get_setup_strategy ();
|
|---|
| 7602 |
|
|---|
| 7603 | bool do_config = ((strategy & SetupConfigMask) == SetupConfig);
|
|---|
| 7604 | bool do_root = ((strategy & SetupRootMask) == SetupRoot);
|
|---|
| 7605 |
|
|---|
| 7606 | switch (mode)
|
|---|
| 7607 | {
|
|---|
| 7608 | case Csh :
|
|---|
| 7609 | if (do_root)
|
|---|
| 7610 | {
|
|---|
| 7611 | cout << "setenv " << use.prefix << "ROOT \"" <<
|
|---|
| 7612 | use.get_full_path () << "\"" << endl;
|
|---|
| 7613 | }
|
|---|
| 7614 |
|
|---|
| 7615 | if (use.get_package_name () == "CMT")
|
|---|
| 7616 | {
|
|---|
| 7617 | cout << "setenv CMTCONFIG " << system << endl;
|
|---|
| 7618 | }
|
|---|
| 7619 | else
|
|---|
| 7620 | {
|
|---|
| 7621 | if (do_config)
|
|---|
| 7622 | {
|
|---|
| 7623 | cout << "setenv " << use.prefix << "CONFIG \"" << tag << "\"" << endl;
|
|---|
| 7624 | }
|
|---|
| 7625 | }
|
|---|
| 7626 |
|
|---|
| 7627 | break;
|
|---|
| 7628 | case Sh :
|
|---|
| 7629 | if (do_root)
|
|---|
| 7630 | {
|
|---|
| 7631 | cout << use.prefix << "ROOT=\"" <<
|
|---|
| 7632 | use.get_full_path () << "\"; export " <<
|
|---|
| 7633 | use.prefix << "ROOT" << endl;
|
|---|
| 7634 | }
|
|---|
| 7635 |
|
|---|
| 7636 | if (use.get_package_name () == "CMT")
|
|---|
| 7637 | {
|
|---|
| 7638 | cout << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;
|
|---|
| 7639 | }
|
|---|
| 7640 | else
|
|---|
| 7641 | {
|
|---|
| 7642 | if (do_config)
|
|---|
| 7643 | {
|
|---|
| 7644 | cout << use.prefix << "CONFIG=\"" <<
|
|---|
| 7645 | tag << "\"; export " <<
|
|---|
| 7646 | use.prefix << "CONFIG" << endl;
|
|---|
| 7647 | }
|
|---|
| 7648 | }
|
|---|
| 7649 |
|
|---|
| 7650 | break;
|
|---|
| 7651 | case Bat :
|
|---|
| 7652 | if (do_root)
|
|---|
| 7653 | {
|
|---|
| 7654 | cout << "set " << use.prefix << "ROOT=" <<
|
|---|
| 7655 | use.get_full_path () << endl;
|
|---|
| 7656 | }
|
|---|
| 7657 |
|
|---|
| 7658 | if (use.get_package_name () == "CMT")
|
|---|
| 7659 | {
|
|---|
| 7660 | cout << "set CMTCONFIG=" << system << endl;
|
|---|
| 7661 | }
|
|---|
| 7662 | else
|
|---|
| 7663 | {
|
|---|
| 7664 | if (do_config)
|
|---|
| 7665 | {
|
|---|
| 7666 | cout << "set " << use.prefix << "CONFIG=" << tag << endl;
|
|---|
| 7667 | }
|
|---|
| 7668 | }
|
|---|
| 7669 |
|
|---|
| 7670 | break;
|
|---|
| 7671 | }
|
|---|
| 7672 | }
|
|---|
| 7673 |
|
|---|
| 7674 | /**
|
|---|
| 7675 | * Format a set of make macro definitions (one per line)
|
|---|
| 7676 | * Each macro value is provided enclosed in single quotes
|
|---|
| 7677 | *
|
|---|
| 7678 | * Take the macro values from the macro statements found
|
|---|
| 7679 | * in recursively read requirements files.
|
|---|
| 7680 | */
|
|---|
| 7681 | void Cmt::print_symbol_names (PrintMode mode, const cmt_string& pattern)
|
|---|
| 7682 | {
|
|---|
| 7683 | int number;
|
|---|
| 7684 |
|
|---|
| 7685 | set_standard_macros ();
|
|---|
| 7686 |
|
|---|
| 7687 | cmt_regexp expression (pattern);
|
|---|
| 7688 |
|
|---|
| 7689 | bool has_pattern = (pattern != "");
|
|---|
| 7690 |
|
|---|
| 7691 | for (number = 0; number < Symbol::symbol_number (); number++)
|
|---|
| 7692 | {
|
|---|
| 7693 | Symbol& symbol = Symbol::symbol (number);
|
|---|
| 7694 |
|
|---|
| 7695 | if (has_pattern)
|
|---|
| 7696 | {
|
|---|
| 7697 | if (!expression.match (symbol.name)) continue;
|
|---|
| 7698 | }
|
|---|
| 7699 |
|
|---|
| 7700 | if (m_action == action_show_macro_names)
|
|---|
| 7701 | {
|
|---|
| 7702 | // Only keep macros.
|
|---|
| 7703 | if ((symbol.type == Symbol::SymbolSet) ||
|
|---|
| 7704 | (symbol.type == Symbol::SymbolAlias) ||
|
|---|
| 7705 | (symbol.type == Symbol::SymbolPath) ||
|
|---|
| 7706 | (symbol.type == Symbol::SymbolAction)) continue;
|
|---|
| 7707 | }
|
|---|
| 7708 | else if (m_action == action_show_set_names)
|
|---|
| 7709 | {
|
|---|
| 7710 | // Exclude macros.
|
|---|
| 7711 | if ((symbol.type == Symbol::SymbolMacro) ||
|
|---|
| 7712 | (symbol.type == Symbol::SymbolAction)) continue;
|
|---|
| 7713 | }
|
|---|
| 7714 | else if (m_action == action_show_action_names)
|
|---|
| 7715 | {
|
|---|
| 7716 | // Exclude macros.
|
|---|
| 7717 | if (symbol.type != Symbol::SymbolAction) continue;
|
|---|
| 7718 | }
|
|---|
| 7719 |
|
|---|
| 7720 | cout << symbol.name << endl;
|
|---|
| 7721 | }
|
|---|
| 7722 | }
|
|---|
| 7723 |
|
|---|
| 7724 | /**
|
|---|
| 7725 | * Format a set of make macro definitions (one per line)
|
|---|
| 7726 | * Each macro value is provided enclosed in single quotes
|
|---|
| 7727 | *
|
|---|
| 7728 | * Take the macro values from the macro statements found
|
|---|
| 7729 | * in recursively read requirements files.
|
|---|
| 7730 | */
|
|---|
| 7731 | void Cmt::print_macros (PrintMode mode, const cmt_string& pattern)
|
|---|
| 7732 | {
|
|---|
| 7733 | int number;
|
|---|
| 7734 |
|
|---|
| 7735 | set_standard_macros ();
|
|---|
| 7736 |
|
|---|
| 7737 | cmt_regexp expression (pattern);
|
|---|
| 7738 |
|
|---|
| 7739 | bool has_pattern = (pattern != "");
|
|---|
| 7740 |
|
|---|
| 7741 | for (number = 0; number < Symbol::symbol_number (); number++)
|
|---|
| 7742 | {
|
|---|
| 7743 | Symbol& symbol = Symbol::symbol (number);
|
|---|
| 7744 |
|
|---|
| 7745 | if (has_pattern)
|
|---|
| 7746 | {
|
|---|
| 7747 | if (!expression.match (symbol.name)) continue;
|
|---|
| 7748 | }
|
|---|
| 7749 |
|
|---|
| 7750 | if (m_action == action_show_macros)
|
|---|
| 7751 | {
|
|---|
| 7752 | // Only keep macros.
|
|---|
| 7753 | if ((symbol.type == Symbol::SymbolSet) ||
|
|---|
| 7754 | (symbol.type == Symbol::SymbolAlias) ||
|
|---|
| 7755 | (symbol.type == Symbol::SymbolPath) ||
|
|---|
| 7756 | (symbol.type == Symbol::SymbolAction)) continue;
|
|---|
| 7757 | }
|
|---|
| 7758 | else if (m_action == action_show_sets)
|
|---|
| 7759 | {
|
|---|
| 7760 | // Exclude macros.
|
|---|
| 7761 | if ((symbol.type == Symbol::SymbolMacro) ||
|
|---|
| 7762 | (symbol.type == Symbol::SymbolAction)) continue;
|
|---|
| 7763 | }
|
|---|
| 7764 | else if (m_action == action_build_tag_makefile)
|
|---|
| 7765 | {
|
|---|
| 7766 | // Exclude scripts and actions
|
|---|
| 7767 | if ((symbol.type == Symbol::SymbolSetupScript) ||
|
|---|
| 7768 | (symbol.type == Symbol::SymbolCleanupScript) ||
|
|---|
| 7769 | (symbol.type == Symbol::SymbolAction)) continue;
|
|---|
| 7770 | }
|
|---|
| 7771 | else if (m_action == action_show_actions)
|
|---|
| 7772 | {
|
|---|
| 7773 | if (symbol.type != Symbol::SymbolAction) continue;
|
|---|
| 7774 | }
|
|---|
| 7775 |
|
|---|
| 7776 | if (symbol.value_lists.size () < 1) continue;
|
|---|
| 7777 |
|
|---|
| 7778 | symbol.show_macro (mode);
|
|---|
| 7779 | }
|
|---|
| 7780 | }
|
|---|
| 7781 |
|
|---|
| 7782 | //----------------------------------------------------------
|
|---|
| 7783 | void Cmt::print_tabs (int tabs)
|
|---|
| 7784 | {
|
|---|
| 7785 | while (tabs > 0)
|
|---|
| 7786 | {
|
|---|
| 7787 | cout << " ";
|
|---|
| 7788 | tabs--;
|
|---|
| 7789 | }
|
|---|
| 7790 | }
|
|---|
| 7791 |
|
|---|
| 7792 | //----------------------------------------------------------
|
|---|
| 7793 | int Cmt::reach_current_package ()
|
|---|
| 7794 | {
|
|---|
| 7795 | Use& use = Use::current ();
|
|---|
| 7796 | cmt_string dir;
|
|---|
| 7797 |
|
|---|
| 7798 | if (m_debug)
|
|---|
| 7799 | {
|
|---|
| 7800 | cout << "Cmt::reach_current_package> pwd = "
|
|---|
| 7801 | << CmtSystem::pwd ()
|
|---|
| 7802 | << " path=" << m_current_path
|
|---|
| 7803 | << " package=" << m_current_package
|
|---|
| 7804 | << endl;
|
|---|
| 7805 | }
|
|---|
| 7806 |
|
|---|
| 7807 | /*
|
|---|
| 7808 | Try to access the package.
|
|---|
| 7809 | */
|
|---|
| 7810 |
|
|---|
| 7811 | if (m_current_package == "cmt_standalone")
|
|---|
| 7812 | {
|
|---|
| 7813 | if ((m_current_path != "") && (m_current_path != CmtSystem::pwd ()))
|
|---|
| 7814 | {
|
|---|
| 7815 | if (!CmtSystem::cd (m_current_path))
|
|---|
| 7816 | {
|
|---|
| 7817 | CmtError::set (CmtError::package_not_found,
|
|---|
| 7818 | "ReachCurrentPackage> Cannot reach the path directory");
|
|---|
| 7819 | return (0);
|
|---|
| 7820 | }
|
|---|
| 7821 | }
|
|---|
| 7822 |
|
|---|
| 7823 | if (!CmtSystem::test_file ("requirements"))
|
|---|
| 7824 | {
|
|---|
| 7825 | /*
|
|---|
| 7826 | if (!m_quiet)
|
|---|
| 7827 | {
|
|---|
| 7828 | cout << "#CMT> Cannot reach the requirements file" << endl;
|
|---|
| 7829 | }
|
|---|
| 7830 |
|
|---|
| 7831 | CmtError::set (CmtError::package_not_found,
|
|---|
| 7832 | "ReachCurrentPackage> Cannot reach the requirements file");
|
|---|
| 7833 | */
|
|---|
| 7834 | return (0);
|
|---|
| 7835 | }
|
|---|
| 7836 | }
|
|---|
| 7837 | else if (m_current_package != "")
|
|---|
| 7838 | {
|
|---|
| 7839 | if (!use.move_to ())
|
|---|
| 7840 | {
|
|---|
| 7841 | CmtError::set (CmtError::package_not_found,
|
|---|
| 7842 | "ReachCurrentPackage> Cannot reach the path directory");
|
|---|
| 7843 | return (0);
|
|---|
| 7844 | }
|
|---|
| 7845 |
|
|---|
| 7846 | m_current_path = use.real_path;
|
|---|
| 7847 | }
|
|---|
| 7848 | else
|
|---|
| 7849 | {
|
|---|
| 7850 | //
|
|---|
| 7851 | // The cmt command has been given without explicit search for
|
|---|
| 7852 | // a package. Thus it is expected that we are in the context of a
|
|---|
| 7853 | // true package.
|
|---|
| 7854 | //
|
|---|
| 7855 | // This means that there should be a requirements file visible.
|
|---|
| 7856 | //
|
|---|
| 7857 | // If this is not true, we'll make a try into ../cmt and then
|
|---|
| 7858 | // a last try into ../mgr
|
|---|
| 7859 | //
|
|---|
| 7860 |
|
|---|
| 7861 | if (!CmtSystem::test_file ("requirements"))
|
|---|
| 7862 | {
|
|---|
| 7863 | if (CmtSystem::cd ("../cmt") &&
|
|---|
| 7864 | CmtSystem::test_file ("requirements"))
|
|---|
| 7865 | {
|
|---|
| 7866 | m_current_style = cmt_style;
|
|---|
| 7867 | }
|
|---|
| 7868 | else if (CmtSystem::cd ("../mgr") &&
|
|---|
| 7869 | CmtSystem::test_file ("requirements"))
|
|---|
| 7870 | {
|
|---|
| 7871 | m_current_style = mgr_style;
|
|---|
| 7872 | }
|
|---|
| 7873 | else
|
|---|
| 7874 | {
|
|---|
| 7875 | if (!m_quiet)
|
|---|
| 7876 | {
|
|---|
| 7877 | cerr << "#CMT> Cannot reach the mgr branch" << endl;
|
|---|
| 7878 | }
|
|---|
| 7879 |
|
|---|
| 7880 | CmtError::set (CmtError::package_not_found,
|
|---|
| 7881 | "ReachCurrentPackage> Cannot reach the mgr/cmt directory");
|
|---|
| 7882 | return (0);
|
|---|
| 7883 | }
|
|---|
| 7884 | }
|
|---|
| 7885 |
|
|---|
| 7886 | dir = CmtSystem::pwd ();
|
|---|
| 7887 |
|
|---|
| 7888 | CmtSystem::dirname (dir, m_current_path);
|
|---|
| 7889 | CmtSystem::basename (m_current_path, m_current_version);
|
|---|
| 7890 |
|
|---|
| 7891 | if (CmtSystem::is_version_directory (m_current_version))
|
|---|
| 7892 | {
|
|---|
| 7893 | CmtSystem::dirname (m_current_path, m_current_path);
|
|---|
| 7894 | CmtSystem::basename (m_current_path, m_current_package);
|
|---|
| 7895 | CmtSystem::dirname (m_current_path, m_current_path);
|
|---|
| 7896 | }
|
|---|
| 7897 | else
|
|---|
| 7898 | {
|
|---|
| 7899 | m_current_package = m_current_version;
|
|---|
| 7900 | m_current_version = "";
|
|---|
| 7901 | CmtSystem::dirname (m_current_path, m_current_path);
|
|---|
| 7902 |
|
|---|
| 7903 | m_current_style = no_version_style;
|
|---|
| 7904 | }
|
|---|
| 7905 |
|
|---|
| 7906 | use.set_package_name (m_current_package);
|
|---|
| 7907 | use.version = m_current_version;
|
|---|
| 7908 | use.path = m_current_path;
|
|---|
| 7909 | use.style = m_current_style;
|
|---|
| 7910 | }
|
|---|
| 7911 |
|
|---|
| 7912 | configure_current_dir ();
|
|---|
| 7913 | build_prefix (m_current_package, m_current_prefix);
|
|---|
| 7914 | build_config (m_current_prefix, m_current_config);
|
|---|
| 7915 |
|
|---|
| 7916 | /*
|
|---|
| 7917 | Check Tag is always set up
|
|---|
| 7918 | */
|
|---|
| 7919 |
|
|---|
| 7920 | if (m_debug) cout << "reach_current_package0> current_tag=" << m_current_tag << endl;
|
|---|
| 7921 |
|
|---|
| 7922 | if (m_current_tag == "")
|
|---|
| 7923 | {
|
|---|
| 7924 | cmt_string env;
|
|---|
| 7925 |
|
|---|
| 7926 | env = CmtSystem::getenv (m_current_config);
|
|---|
| 7927 | if (env != "")
|
|---|
| 7928 | {
|
|---|
| 7929 | Tag* tag;
|
|---|
| 7930 |
|
|---|
| 7931 | tag = Tag::add (env, PriorityConfig, "reach current package", 0);
|
|---|
| 7932 | tag->mark ();
|
|---|
| 7933 | //m_current_tag = env;
|
|---|
| 7934 |
|
|---|
| 7935 | //if (!m_quiet) cerr << "reach_current_package1> current_tag=" << m_current_tag << endl;
|
|---|
| 7936 |
|
|---|
| 7937 | }
|
|---|
| 7938 | }
|
|---|
| 7939 |
|
|---|
| 7940 | if (m_debug)
|
|---|
| 7941 | {
|
|---|
| 7942 | cout << "pwd = " << CmtSystem::pwd () << endl;
|
|---|
| 7943 | }
|
|---|
| 7944 |
|
|---|
| 7945 | /*
|
|---|
| 7946 | Work on the requirements file.
|
|---|
| 7947 | */
|
|---|
| 7948 |
|
|---|
| 7949 | if (dir != "") dir += CmtSystem::file_separator ();
|
|---|
| 7950 | dir += "requirements";
|
|---|
| 7951 | SyntaxParser::parse_requirements (dir, &use);
|
|---|
| 7952 |
|
|---|
| 7953 | if (m_debug) cout << "reach_current_package2> current_tag=" << m_current_tag << endl;
|
|---|
| 7954 |
|
|---|
| 7955 | /**
|
|---|
| 7956 | * It would be useful to change this mechanism. Instead of
|
|---|
| 7957 | * applying all global patterns at once to all use contexts, it
|
|---|
| 7958 | * would be much better to apply it at the end of each
|
|---|
| 7959 | * requirements file parsing, and only in the context the
|
|---|
| 7960 | * appropriate Use.
|
|---|
| 7961 | *
|
|---|
| 7962 | * This would avoid the current flaw which is that when a global
|
|---|
| 7963 | * pattern specifies a "private" definition, it is actually
|
|---|
| 7964 | * applied in the scope context of the Current Use and not in
|
|---|
| 7965 | * each individual Use. Therefore the private is lost.
|
|---|
| 7966 | *
|
|---|
| 7967 | * However, this induces problems since some pattern definitions
|
|---|
| 7968 | * are done AFTER the use statements, which will NOT receive the
|
|---|
| 7969 | * pattern aplications.
|
|---|
| 7970 | *
|
|---|
| 7971 | * Therefore it is decided to leave this "bad" mechanism until
|
|---|
| 7972 | * everybody is aware of this constraint.
|
|---|
| 7973 | *
|
|---|
| 7974 | *
|
|---|
| 7975 | */
|
|---|
| 7976 | Pattern::apply_all_globals ();
|
|---|
| 7977 |
|
|---|
| 7978 | /*
|
|---|
| 7979 | Select all possible tags
|
|---|
| 7980 | */
|
|---|
| 7981 |
|
|---|
| 7982 | Tag::restore_tree ();
|
|---|
| 7983 |
|
|---|
| 7984 | return (1);
|
|---|
| 7985 | }
|
|---|
| 7986 |
|
|---|
| 7987 | static cmt_string get_best_form (const CmtSystem::cmt_string_vector& pwd,
|
|---|
| 7988 | const cmt_string& path)
|
|---|
| 7989 | {
|
|---|
| 7990 | static cmt_string fs = CmtSystem::file_separator ();
|
|---|
| 7991 | cmt_string result;
|
|---|
| 7992 |
|
|---|
| 7993 | /*
|
|---|
| 7994 | //if (CmtSystem::getenv ("CMTTESTPREFIX") != "")
|
|---|
| 7995 | {
|
|---|
| 7996 | */
|
|---|
| 7997 |
|
|---|
| 7998 | //
|
|---|
| 7999 | // If there is a common prefix between
|
|---|
| 8000 | // use->real_path and pwd
|
|---|
| 8001 | // we have
|
|---|
| 8002 | // use->real_path = /<prefix>/aaa
|
|---|
| 8003 | // pwd = /<prefix>/bbb
|
|---|
| 8004 | //
|
|---|
| 8005 | // Then use->real_path may be expressed as:
|
|---|
| 8006 | // ../..../../aaa
|
|---|
| 8007 | // where ../..../../ moves up to /<prefix>
|
|---|
| 8008 | //
|
|---|
| 8009 | // Then we try to find the shortest between
|
|---|
| 8010 | //
|
|---|
| 8011 | // /<prefix> and ../..../..
|
|---|
| 8012 | //
|
|---|
| 8013 | cmt_string a = path;
|
|---|
| 8014 |
|
|---|
| 8015 | CmtSystem::cmt_string_vector va;
|
|---|
| 8016 |
|
|---|
| 8017 | va.clear ();
|
|---|
| 8018 |
|
|---|
| 8019 | CmtSystem::split (a, fs, va);
|
|---|
| 8020 |
|
|---|
| 8021 | int m = va.size ();
|
|---|
| 8022 | if (pwd.size () < m) m = pwd.size ();
|
|---|
| 8023 |
|
|---|
| 8024 | int i;
|
|---|
| 8025 |
|
|---|
| 8026 | //cout << "Package " << use->get_package_name () << endl;
|
|---|
| 8027 |
|
|---|
| 8028 | for (i = 0; i < m; i++)
|
|---|
| 8029 | {
|
|---|
| 8030 | const cmt_string& fa = va[i];
|
|---|
| 8031 | const cmt_string& fb = pwd[i];
|
|---|
| 8032 |
|
|---|
| 8033 | //cout << " fa=" << fa << " fb=" << fb << endl;
|
|---|
| 8034 |
|
|---|
| 8035 | if (fa != fb) break;
|
|---|
| 8036 | }
|
|---|
| 8037 |
|
|---|
| 8038 | cmt_string ups = "";
|
|---|
| 8039 |
|
|---|
| 8040 | if (i > 0)
|
|---|
| 8041 | {
|
|---|
| 8042 | // We have the prefix.
|
|---|
| 8043 | // if we count what remains from pwd, then
|
|---|
| 8044 | // we have the number of ../ required to
|
|---|
| 8045 | // move to /<prefix>
|
|---|
| 8046 | int j;
|
|---|
| 8047 |
|
|---|
| 8048 | for (j = i; j < pwd.size (); j++)
|
|---|
| 8049 | {
|
|---|
| 8050 | if (j > i) ups += fs;
|
|---|
| 8051 | ups += "..";
|
|---|
| 8052 | }
|
|---|
| 8053 |
|
|---|
| 8054 | for (j = i; j < va.size (); j++)
|
|---|
| 8055 | {
|
|---|
| 8056 | ups += fs;
|
|---|
| 8057 | ups += va[j];
|
|---|
| 8058 | }
|
|---|
| 8059 | }
|
|---|
| 8060 |
|
|---|
| 8061 | //
|
|---|
| 8062 | // Here ups contains the ../..../../aaa form
|
|---|
| 8063 | // for the use->real_path or is empty when there
|
|---|
| 8064 | // were no common prefix.
|
|---|
| 8065 | //
|
|---|
| 8066 |
|
|---|
| 8067 | //if (ups != "")
|
|---|
| 8068 | if ((ups != "") &&
|
|---|
| 8069 | (ups.size () < path.size ()))
|
|---|
| 8070 | {
|
|---|
| 8071 | result = ups;
|
|---|
| 8072 | }
|
|---|
| 8073 | else
|
|---|
| 8074 | {
|
|---|
| 8075 | result = path;
|
|---|
| 8076 | }
|
|---|
| 8077 |
|
|---|
| 8078 | return (result);
|
|---|
| 8079 | }
|
|---|
| 8080 |
|
|---|
| 8081 | /**
|
|---|
| 8082 | * This completely local class holds primitive actions for building
|
|---|
| 8083 | * standard macros.
|
|---|
| 8084 | */
|
|---|
| 8085 | class StandardMacroBuilder
|
|---|
| 8086 | {
|
|---|
| 8087 | public:
|
|---|
| 8088 |
|
|---|
| 8089 | /**
|
|---|
| 8090 | * CMTVERSION
|
|---|
| 8091 | */
|
|---|
| 8092 | void fill_for_CMTVERSION ()
|
|---|
| 8093 | {
|
|---|
| 8094 | buffer = "macro CMTVERSION \"";
|
|---|
| 8095 | buffer += CMTVERSION;
|
|---|
| 8096 | buffer += "\"";
|
|---|
| 8097 | apply ();
|
|---|
| 8098 | }
|
|---|
| 8099 |
|
|---|
| 8100 | StandardMacroBuilder (const cmt_string& tag,
|
|---|
| 8101 | const cmt_string& package,
|
|---|
| 8102 | const cmt_string& version,
|
|---|
| 8103 | const cmt_string& prefix,
|
|---|
| 8104 | CmtDirStyle style)
|
|---|
| 8105 | {
|
|---|
| 8106 | fs = CmtSystem::file_separator ();
|
|---|
| 8107 | buffer = "";
|
|---|
| 8108 | pwd = CmtSystem::pwd ();
|
|---|
| 8109 | CmtSystem::split (pwd, fs, vb);
|
|---|
| 8110 | current_use = &(Use::current ());
|
|---|
| 8111 | current_tag = tag;
|
|---|
| 8112 | current_package = package;
|
|---|
| 8113 | current_version = version;
|
|---|
| 8114 | current_prefix = prefix;
|
|---|
| 8115 | current_style = style;
|
|---|
| 8116 | }
|
|---|
| 8117 |
|
|---|
| 8118 | void apply ()
|
|---|
| 8119 | {
|
|---|
| 8120 | SyntaxParser::parse_requirements_line (buffer, current_use);
|
|---|
| 8121 | buffer = "";
|
|---|
| 8122 | }
|
|---|
| 8123 |
|
|---|
| 8124 | /**
|
|---|
| 8125 | * tag
|
|---|
| 8126 | */
|
|---|
| 8127 | void fill_for_tag ()
|
|---|
| 8128 | {
|
|---|
| 8129 | static bool tag_debug = CmtSystem::testenv ("TAGDEBUG");
|
|---|
| 8130 |
|
|---|
| 8131 | if (!Symbol::is_selected ("tag"))
|
|---|
| 8132 | {
|
|---|
| 8133 | if (tag_debug) cerr << "set_standard_macro2.1> current_tag=" << current_tag << endl;
|
|---|
| 8134 |
|
|---|
| 8135 | if (current_tag == "")
|
|---|
| 8136 | {
|
|---|
| 8137 | buffer = "macro tag \"$(CMTCONFIG)\"";
|
|---|
| 8138 | }
|
|---|
| 8139 | else
|
|---|
| 8140 | {
|
|---|
| 8141 | buffer = "macro tag \"";
|
|---|
| 8142 | buffer += current_tag;
|
|---|
| 8143 | buffer += "\"";
|
|---|
| 8144 | }
|
|---|
| 8145 |
|
|---|
| 8146 | if (tag_debug) cerr << " define tag: " << buffer << endl;
|
|---|
| 8147 |
|
|---|
| 8148 | apply ();
|
|---|
| 8149 | }
|
|---|
| 8150 | }
|
|---|
| 8151 |
|
|---|
| 8152 | /**
|
|---|
| 8153 | * PACKAGE_ROOT
|
|---|
| 8154 | */
|
|---|
| 8155 | void fill_for_package (const cmt_string& current_dir)
|
|---|
| 8156 | {
|
|---|
| 8157 | buffer = "macro package \"";
|
|---|
| 8158 | buffer += current_package;
|
|---|
| 8159 | buffer += "\"";
|
|---|
| 8160 | apply ();
|
|---|
| 8161 |
|
|---|
| 8162 | buffer = "macro version \"";
|
|---|
| 8163 | buffer += current_version;
|
|---|
| 8164 | buffer += "\"";
|
|---|
| 8165 | apply ();
|
|---|
| 8166 |
|
|---|
| 8167 | if (!Symbol::is_selected ("PACKAGE_ROOT"))
|
|---|
| 8168 | {
|
|---|
| 8169 | buffer = "macro PACKAGE_ROOT \"$(";
|
|---|
| 8170 | buffer += current_prefix;
|
|---|
| 8171 | buffer += "ROOT";
|
|---|
| 8172 | buffer += ")\"";
|
|---|
| 8173 |
|
|---|
| 8174 | apply ();
|
|---|
| 8175 | }
|
|---|
| 8176 | }
|
|---|
| 8177 |
|
|---|
| 8178 | /**
|
|---|
| 8179 | * srcdir
|
|---|
| 8180 | * src =$(srcdir)/
|
|---|
| 8181 | * inc
|
|---|
| 8182 | * mgrdir
|
|---|
| 8183 | * mgr =../$(mgrdir)/
|
|---|
| 8184 | * bin
|
|---|
| 8185 | * javabin
|
|---|
| 8186 | * doc
|
|---|
| 8187 | * version
|
|---|
| 8188 | * package
|
|---|
| 8189 | *
|
|---|
| 8190 | * <package>_project
|
|---|
| 8191 | * <package>_cmtpath
|
|---|
| 8192 | * <package>_offset
|
|---|
| 8193 | * package_cmtpath
|
|---|
| 8194 | * package_offset
|
|---|
| 8195 | * project
|
|---|
| 8196 | *
|
|---|
| 8197 | */
|
|---|
| 8198 | void fill_for_branches ()
|
|---|
| 8199 | {
|
|---|
| 8200 | /**
|
|---|
| 8201 | * Basic macros (src, mgr, ...)
|
|---|
| 8202 | */
|
|---|
| 8203 |
|
|---|
| 8204 | if (current_style == none_style)
|
|---|
| 8205 | {
|
|---|
| 8206 | buffer = "macro srcdir \".";
|
|---|
| 8207 | buffer += "\"";
|
|---|
| 8208 | apply ();
|
|---|
| 8209 |
|
|---|
| 8210 | buffer = "macro src \".";
|
|---|
| 8211 | buffer += fs;
|
|---|
| 8212 | buffer += "\"";
|
|---|
| 8213 | apply ();
|
|---|
| 8214 |
|
|---|
| 8215 | buffer = "macro inc \".";
|
|---|
| 8216 | buffer += fs;
|
|---|
| 8217 | buffer += "\"";
|
|---|
| 8218 | apply ();
|
|---|
| 8219 |
|
|---|
| 8220 | buffer = "macro mgr \".";
|
|---|
| 8221 | buffer += fs;
|
|---|
| 8222 | buffer += "\"";
|
|---|
| 8223 | apply ();
|
|---|
| 8224 |
|
|---|
| 8225 | buffer = "macro bin \".";
|
|---|
| 8226 | buffer += fs;
|
|---|
| 8227 | buffer += "\"";
|
|---|
| 8228 | apply ();
|
|---|
| 8229 |
|
|---|
| 8230 | buffer = "macro javabin \".";
|
|---|
| 8231 | buffer += fs;
|
|---|
| 8232 | buffer += "\"";
|
|---|
| 8233 | apply ();
|
|---|
| 8234 |
|
|---|
| 8235 | buffer = "macro doc \".";
|
|---|
| 8236 | buffer += fs;
|
|---|
| 8237 | buffer += "\"";
|
|---|
| 8238 | apply ();
|
|---|
| 8239 | }
|
|---|
| 8240 | else
|
|---|
| 8241 | {
|
|---|
| 8242 | if (!Symbol::is_selected ("srcdir"))
|
|---|
| 8243 | {
|
|---|
| 8244 | buffer = "macro srcdir \"..";
|
|---|
| 8245 | buffer += fs;
|
|---|
| 8246 | buffer += "src";
|
|---|
| 8247 | buffer += "\"";
|
|---|
| 8248 | apply ();
|
|---|
| 8249 | }
|
|---|
| 8250 |
|
|---|
| 8251 | if (!Symbol::is_selected ("src"))
|
|---|
| 8252 | {
|
|---|
| 8253 | buffer = "macro src \"..";
|
|---|
| 8254 | buffer += fs;
|
|---|
| 8255 | buffer += "src";
|
|---|
| 8256 | buffer += fs;
|
|---|
| 8257 | buffer += "\"";
|
|---|
| 8258 | apply ();
|
|---|
| 8259 | }
|
|---|
| 8260 |
|
|---|
| 8261 | if (!Symbol::is_selected ("inc"))
|
|---|
| 8262 | {
|
|---|
| 8263 | buffer = "macro inc \"..";
|
|---|
| 8264 | buffer += fs;
|
|---|
| 8265 | buffer += "src";
|
|---|
| 8266 | buffer += fs;
|
|---|
| 8267 | buffer += "\"";
|
|---|
| 8268 | apply ();
|
|---|
| 8269 | }
|
|---|
| 8270 |
|
|---|
| 8271 | if (!Symbol::is_selected ("doc"))
|
|---|
| 8272 | {
|
|---|
| 8273 | buffer = "macro doc \"..";
|
|---|
| 8274 | buffer += fs;
|
|---|
| 8275 | buffer += "doc";
|
|---|
| 8276 | buffer += fs;
|
|---|
| 8277 | buffer += "\"";
|
|---|
| 8278 | apply ();
|
|---|
| 8279 | }
|
|---|
| 8280 |
|
|---|
| 8281 | if (!Symbol::is_selected ("bin"))
|
|---|
| 8282 | {
|
|---|
| 8283 | cmt_string package_tag = current_package;
|
|---|
| 8284 | package_tag += "_tag";
|
|---|
| 8285 |
|
|---|
| 8286 | buffer = "macro bin \"..";
|
|---|
| 8287 | buffer += fs;
|
|---|
| 8288 | buffer += "$(";
|
|---|
| 8289 | buffer += package_tag;
|
|---|
| 8290 | buffer += ")";
|
|---|
| 8291 | buffer += fs;
|
|---|
| 8292 | buffer += "\"";
|
|---|
| 8293 | apply ();
|
|---|
| 8294 | }
|
|---|
| 8295 |
|
|---|
| 8296 | if (!Symbol::is_selected ("javabin"))
|
|---|
| 8297 | {
|
|---|
| 8298 | buffer = "macro javabin \"..";
|
|---|
| 8299 | buffer += fs;
|
|---|
| 8300 | buffer += "classes";
|
|---|
| 8301 | buffer += fs;
|
|---|
| 8302 | buffer += "\"";
|
|---|
| 8303 | apply ();
|
|---|
| 8304 | }
|
|---|
| 8305 |
|
|---|
| 8306 | if (current_style == mgr_style)
|
|---|
| 8307 | {
|
|---|
| 8308 | buffer = "macro mgrdir \"mgr\"";
|
|---|
| 8309 | apply ();
|
|---|
| 8310 |
|
|---|
| 8311 | buffer = "macro mgr \"..";
|
|---|
| 8312 | buffer += fs;
|
|---|
| 8313 | buffer += "mgr";
|
|---|
| 8314 | buffer += fs;
|
|---|
| 8315 | buffer += "\"";
|
|---|
| 8316 | apply ();
|
|---|
| 8317 | }
|
|---|
| 8318 | else
|
|---|
| 8319 | {
|
|---|
| 8320 | buffer = "macro mgrdir \"cmt\"";
|
|---|
| 8321 | apply ();
|
|---|
| 8322 |
|
|---|
| 8323 | buffer = "macro mgr \"..";
|
|---|
| 8324 | buffer += fs;
|
|---|
| 8325 | buffer += "cmt";
|
|---|
| 8326 | buffer += fs;
|
|---|
| 8327 | buffer += "\"";
|
|---|
| 8328 | apply ();
|
|---|
| 8329 | }
|
|---|
| 8330 |
|
|---|
| 8331 | Cmt::configure_current_cmtpath ();
|
|---|
| 8332 | }
|
|---|
| 8333 | }
|
|---|
| 8334 |
|
|---|
| 8335 | /**
|
|---|
| 8336 | * project
|
|---|
| 8337 | */
|
|---|
| 8338 | void fill_for_project ()
|
|---|
| 8339 | {
|
|---|
| 8340 | if (current_style == none_style) return;
|
|---|
| 8341 |
|
|---|
| 8342 | cmt_string project_name;
|
|---|
| 8343 | Project* project = Project::get_current ();
|
|---|
| 8344 | if (project != 0)
|
|---|
| 8345 | {
|
|---|
| 8346 | project_name = project->get_name ();
|
|---|
| 8347 | }
|
|---|
| 8348 |
|
|---|
| 8349 | buffer = "macro project \"";
|
|---|
| 8350 | buffer += project_name;
|
|---|
| 8351 | buffer += "\"";
|
|---|
| 8352 | apply ();
|
|---|
| 8353 | }
|
|---|
| 8354 |
|
|---|
| 8355 | /**
|
|---|
| 8356 | * use_requirements
|
|---|
| 8357 | */
|
|---|
| 8358 | void fill_for_use_requirements ()
|
|---|
| 8359 | {
|
|---|
| 8360 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8361 |
|
|---|
| 8362 | if (Uses.size () == 0) return;
|
|---|
| 8363 |
|
|---|
| 8364 | if (!Symbol::is_selected ("use_requirements"))
|
|---|
| 8365 | {
|
|---|
| 8366 | buffer = "macro use_requirements \"";
|
|---|
| 8367 | buffer += "requirements ";
|
|---|
| 8368 |
|
|---|
| 8369 | for (int number = 0; number < Uses.size (); number++)
|
|---|
| 8370 | {
|
|---|
| 8371 | Use* use = Uses[number];
|
|---|
| 8372 |
|
|---|
| 8373 | if (use->discarded) continue;
|
|---|
| 8374 |
|
|---|
| 8375 | if (use->located ())
|
|---|
| 8376 | {
|
|---|
| 8377 | buffer += "$(";
|
|---|
| 8378 | buffer += use->prefix;
|
|---|
| 8379 | buffer += "ROOT)";
|
|---|
| 8380 | buffer += fs;
|
|---|
| 8381 |
|
|---|
| 8382 | if (use->style == mgr_style) buffer += "mgr";
|
|---|
| 8383 | else buffer += "cmt";
|
|---|
| 8384 |
|
|---|
| 8385 | buffer += fs;
|
|---|
| 8386 | buffer += "requirements ";
|
|---|
| 8387 | }
|
|---|
| 8388 | }
|
|---|
| 8389 |
|
|---|
| 8390 | buffer += "\"";
|
|---|
| 8391 |
|
|---|
| 8392 | apply ();
|
|---|
| 8393 | }
|
|---|
| 8394 | }
|
|---|
| 8395 |
|
|---|
| 8396 | /**
|
|---|
| 8397 | * use_includes
|
|---|
| 8398 | */
|
|---|
| 8399 | void fill_for_use_includes ()
|
|---|
| 8400 | {
|
|---|
| 8401 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8402 |
|
|---|
| 8403 | if (Uses.size () == 0) return;
|
|---|
| 8404 |
|
|---|
| 8405 | if (!Symbol::is_selected ("use_includes"))
|
|---|
| 8406 | {
|
|---|
| 8407 | buffer = "macro_append use_includes \' ";
|
|---|
| 8408 |
|
|---|
| 8409 | for (int number = 0; number < Uses.size (); number++)
|
|---|
| 8410 | {
|
|---|
| 8411 | Use* use = Uses[number];
|
|---|
| 8412 |
|
|---|
| 8413 | if (use->discarded) continue;
|
|---|
| 8414 |
|
|---|
| 8415 | Package* p = use->get_package ();
|
|---|
| 8416 | if (p->is_cmt ()) continue;
|
|---|
| 8417 |
|
|---|
| 8418 | if (Cmt::get_debug ())
|
|---|
| 8419 | {
|
|---|
| 8420 | cout << "fill use_includes for " << use->get_package_name ()
|
|---|
| 8421 | << " discarded=" << use->discarded
|
|---|
| 8422 | << " auto_imports=" << use->auto_imports << endl;
|
|---|
| 8423 | }
|
|---|
| 8424 |
|
|---|
| 8425 | if (use->auto_imports == Off) continue;
|
|---|
| 8426 |
|
|---|
| 8427 | use->fill_includes_macro (buffer);
|
|---|
| 8428 | }
|
|---|
| 8429 |
|
|---|
| 8430 | buffer += "\'";
|
|---|
| 8431 |
|
|---|
| 8432 | apply ();
|
|---|
| 8433 | }
|
|---|
| 8434 | }
|
|---|
| 8435 |
|
|---|
| 8436 | /**
|
|---|
| 8437 | * use_fincludes
|
|---|
| 8438 | */
|
|---|
| 8439 | void fill_for_use_fincludes ()
|
|---|
| 8440 | {
|
|---|
| 8441 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8442 |
|
|---|
| 8443 | if (Uses.size () == 0) return;
|
|---|
| 8444 |
|
|---|
| 8445 | if (!Symbol::is_selected ("use_fincludes"))
|
|---|
| 8446 | {
|
|---|
| 8447 | buffer = "macro_append use_fincludes \" $(use_includes)\"";
|
|---|
| 8448 | apply ();
|
|---|
| 8449 | }
|
|---|
| 8450 | }
|
|---|
| 8451 |
|
|---|
| 8452 | /**
|
|---|
| 8453 | * use_stamps
|
|---|
| 8454 | */
|
|---|
| 8455 | void fill_for_use_stamps ()
|
|---|
| 8456 | {
|
|---|
| 8457 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8458 |
|
|---|
| 8459 | if (Uses.size () == 0) return;
|
|---|
| 8460 |
|
|---|
| 8461 | if (!Symbol::is_selected ("use_stamps"))
|
|---|
| 8462 | {
|
|---|
| 8463 | buffer = "macro use_stamps \"";
|
|---|
| 8464 | (Use::current()).fill_macro (buffer, "stamps");
|
|---|
| 8465 |
|
|---|
| 8466 | for (int number = 0; number < Uses.size (); number++)
|
|---|
| 8467 | {
|
|---|
| 8468 | Use* use = Uses[number];
|
|---|
| 8469 |
|
|---|
| 8470 | if (use->discarded) continue;
|
|---|
| 8471 |
|
|---|
| 8472 | Package* p = use->get_package ();
|
|---|
| 8473 | if (p->is_cmt ()) continue;
|
|---|
| 8474 |
|
|---|
| 8475 | use->fill_macro (buffer, "stamps");
|
|---|
| 8476 | }
|
|---|
| 8477 |
|
|---|
| 8478 | buffer += "\"";
|
|---|
| 8479 |
|
|---|
| 8480 | apply ();
|
|---|
| 8481 | }
|
|---|
| 8482 | }
|
|---|
| 8483 |
|
|---|
| 8484 | /**
|
|---|
| 8485 | * use_cflags
|
|---|
| 8486 | */
|
|---|
| 8487 | void fill_for_use_cflags ()
|
|---|
| 8488 | {
|
|---|
| 8489 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8490 |
|
|---|
| 8491 | if (Uses.size () == 0) return;
|
|---|
| 8492 |
|
|---|
| 8493 | if (!Symbol::is_selected ("use_cflags"))
|
|---|
| 8494 | {
|
|---|
| 8495 | Use::fill_macro_all (buffer, "cflags");
|
|---|
| 8496 | apply ();
|
|---|
| 8497 | }
|
|---|
| 8498 | }
|
|---|
| 8499 |
|
|---|
| 8500 | /**
|
|---|
| 8501 | * use_pp_cflags
|
|---|
| 8502 | */
|
|---|
| 8503 | void fill_for_use_pp_cflags ()
|
|---|
| 8504 | {
|
|---|
| 8505 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8506 |
|
|---|
| 8507 | if (Uses.size () == 0) return;
|
|---|
| 8508 |
|
|---|
| 8509 | if (!Symbol::is_selected ("use_pp_cflags"))
|
|---|
| 8510 | {
|
|---|
| 8511 | Use::fill_macro_all (buffer, "pp_cflags");
|
|---|
| 8512 | apply ();
|
|---|
| 8513 | }
|
|---|
| 8514 | }
|
|---|
| 8515 |
|
|---|
| 8516 | /**
|
|---|
| 8517 | * use_cppflags
|
|---|
| 8518 | */
|
|---|
| 8519 | void fill_for_use_cppflags ()
|
|---|
| 8520 | {
|
|---|
| 8521 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8522 |
|
|---|
| 8523 | if (Uses.size () == 0) return;
|
|---|
| 8524 |
|
|---|
| 8525 | if (!Symbol::is_selected ("use_cppflags"))
|
|---|
| 8526 | {
|
|---|
| 8527 | Use::fill_macro_all (buffer, "cppflags");
|
|---|
| 8528 | apply ();
|
|---|
| 8529 | }
|
|---|
| 8530 | }
|
|---|
| 8531 |
|
|---|
| 8532 | /**
|
|---|
| 8533 | * use_pp_cppflags
|
|---|
| 8534 | */
|
|---|
| 8535 | void fill_for_use_pp_cppflags ()
|
|---|
| 8536 | {
|
|---|
| 8537 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8538 |
|
|---|
| 8539 | if (Uses.size () == 0) return;
|
|---|
| 8540 |
|
|---|
| 8541 | if (!Symbol::is_selected ("use_pp_cppflags"))
|
|---|
| 8542 | {
|
|---|
| 8543 | Use::fill_macro_all (buffer, "pp_cppflags");
|
|---|
| 8544 | apply ();
|
|---|
| 8545 | }
|
|---|
| 8546 | }
|
|---|
| 8547 |
|
|---|
| 8548 | /**
|
|---|
| 8549 | * use_fflags
|
|---|
| 8550 | */
|
|---|
| 8551 | void fill_for_use_fflags ()
|
|---|
| 8552 | {
|
|---|
| 8553 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8554 |
|
|---|
| 8555 | if (Uses.size () == 0) return;
|
|---|
| 8556 |
|
|---|
| 8557 | if (!Symbol::is_selected ("use_fflags"))
|
|---|
| 8558 | {
|
|---|
| 8559 | Use::fill_macro_all (buffer, "fflags");
|
|---|
| 8560 | apply ();
|
|---|
| 8561 | }
|
|---|
| 8562 | }
|
|---|
| 8563 |
|
|---|
| 8564 | /**
|
|---|
| 8565 | * use_pp_fflags
|
|---|
| 8566 | */
|
|---|
| 8567 | void fill_for_use_pp_fflags ()
|
|---|
| 8568 | {
|
|---|
| 8569 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8570 |
|
|---|
| 8571 | if (Uses.size () == 0) return;
|
|---|
| 8572 |
|
|---|
| 8573 | if (!Symbol::is_selected ("use_pp_fflags"))
|
|---|
| 8574 | {
|
|---|
| 8575 | Use::fill_macro_all (buffer, "pp_fflags");
|
|---|
| 8576 | apply ();
|
|---|
| 8577 | }
|
|---|
| 8578 | }
|
|---|
| 8579 |
|
|---|
| 8580 | /**
|
|---|
| 8581 | * use_linkopts
|
|---|
| 8582 | */
|
|---|
| 8583 | void fill_for_use_linkopts ()
|
|---|
| 8584 | {
|
|---|
| 8585 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8586 |
|
|---|
| 8587 | if (Uses.size () == 0) return;
|
|---|
| 8588 |
|
|---|
| 8589 | if (!Symbol::is_selected ("use_linkopts"))
|
|---|
| 8590 | {
|
|---|
| 8591 | Use::fill_macro_all (buffer, "linkopts");
|
|---|
| 8592 | apply ();
|
|---|
| 8593 | }
|
|---|
| 8594 | }
|
|---|
| 8595 |
|
|---|
| 8596 | /**
|
|---|
| 8597 | * use_libraries
|
|---|
| 8598 | */
|
|---|
| 8599 | void fill_for_use_libraries ()
|
|---|
| 8600 | {
|
|---|
| 8601 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8602 |
|
|---|
| 8603 | if (Uses.size () == 0) return;
|
|---|
| 8604 |
|
|---|
| 8605 | if (!Symbol::is_selected ("use_libraries"))
|
|---|
| 8606 | {
|
|---|
| 8607 | buffer = "macro use_libraries \"";
|
|---|
| 8608 |
|
|---|
| 8609 | for (int number = 0; number < Uses.size (); number++)
|
|---|
| 8610 | {
|
|---|
| 8611 | Use* use = Uses[number];
|
|---|
| 8612 |
|
|---|
| 8613 | if (use->discarded) continue;
|
|---|
| 8614 |
|
|---|
| 8615 | Package* p = use->get_package ();
|
|---|
| 8616 | if (p->is_cmt ()) continue;
|
|---|
| 8617 |
|
|---|
| 8618 | use->fill_macro (buffer, "libraries");
|
|---|
| 8619 | }
|
|---|
| 8620 |
|
|---|
| 8621 | buffer += "\"";
|
|---|
| 8622 |
|
|---|
| 8623 | apply ();
|
|---|
| 8624 | }
|
|---|
| 8625 | }
|
|---|
| 8626 |
|
|---|
| 8627 | /**
|
|---|
| 8628 | * includes
|
|---|
| 8629 | */
|
|---|
| 8630 | void fill_for_includes ()
|
|---|
| 8631 | {
|
|---|
| 8632 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8633 |
|
|---|
| 8634 | if (Uses.size () == 0) return;
|
|---|
| 8635 |
|
|---|
| 8636 | if (!Symbol::is_selected ("includes"))
|
|---|
| 8637 | {
|
|---|
| 8638 | buffer = "macro_append includes \' ";
|
|---|
| 8639 |
|
|---|
| 8640 | Use& use = Use::current();
|
|---|
| 8641 |
|
|---|
| 8642 | if (use.include_path == "")
|
|---|
| 8643 | {
|
|---|
| 8644 | buffer += "$(ppcmd)\"$(srcdir)\" ";
|
|---|
| 8645 | }
|
|---|
| 8646 | else if (use.include_path != "none")
|
|---|
| 8647 | {
|
|---|
| 8648 | buffer += "$(ppcmd)\"";
|
|---|
| 8649 | buffer += use.include_path;
|
|---|
| 8650 | buffer += "\" ";
|
|---|
| 8651 | }
|
|---|
| 8652 |
|
|---|
| 8653 | for (int include_number = 0;
|
|---|
| 8654 | include_number < use.includes.size ();
|
|---|
| 8655 | include_number++)
|
|---|
| 8656 | {
|
|---|
| 8657 | Include& incl = use.includes[include_number];
|
|---|
| 8658 |
|
|---|
| 8659 | buffer += "$(ppcmd)\"";
|
|---|
| 8660 | buffer += incl.name;
|
|---|
| 8661 | buffer += "\" ";
|
|---|
| 8662 | }
|
|---|
| 8663 |
|
|---|
| 8664 | buffer += "$(use_includes)\'";
|
|---|
| 8665 |
|
|---|
| 8666 | apply ();
|
|---|
| 8667 | }
|
|---|
| 8668 | }
|
|---|
| 8669 |
|
|---|
| 8670 | /**
|
|---|
| 8671 | * fincludes
|
|---|
| 8672 | */
|
|---|
| 8673 | void fill_for_fincludes ()
|
|---|
| 8674 | {
|
|---|
| 8675 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8676 |
|
|---|
| 8677 | if (Uses.size () == 0) return;
|
|---|
| 8678 |
|
|---|
| 8679 | if (!Symbol::is_selected ("fincludes"))
|
|---|
| 8680 | {
|
|---|
| 8681 | buffer = "macro_append fincludes \" $(includes)\"";
|
|---|
| 8682 | apply ();
|
|---|
| 8683 | }
|
|---|
| 8684 | }
|
|---|
| 8685 |
|
|---|
| 8686 | /**
|
|---|
| 8687 | * Macros specific to constituents.
|
|---|
| 8688 | * This includes the compiler flags
|
|---|
| 8689 | * and fills in these macros from uses packages. This takes care
|
|---|
| 8690 | * of -no_auto_imports and -import= directives
|
|---|
| 8691 | *
|
|---|
| 8692 | * <constituent>_use_linkopts
|
|---|
| 8693 | * <prefix>_<constituent>_cflags
|
|---|
| 8694 | * <prefix>_<constituent>_pp_cflags
|
|---|
| 8695 | * <prefix>_<constituent>_cppflags
|
|---|
| 8696 | * <prefix>_<constituent>_pp_cppflags
|
|---|
| 8697 | * <prefix>_<constituent>_fflags
|
|---|
| 8698 | * <prefix>_<constituent>_pp_fflags
|
|---|
| 8699 | * <constituent>linkopts
|
|---|
| 8700 | * <constituent>_GUID
|
|---|
| 8701 | *
|
|---|
| 8702 | */
|
|---|
| 8703 | void fill_for_all_constituents ()
|
|---|
| 8704 | {
|
|---|
| 8705 | /// First, finish the parsing of constituent parameters.
|
|---|
| 8706 | Constituent::parse_all ();
|
|---|
| 8707 |
|
|---|
| 8708 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 8709 |
|
|---|
| 8710 | const Constituent::ConstituentVector& constituents =
|
|---|
| 8711 | Constituent::constituents ();
|
|---|
| 8712 |
|
|---|
| 8713 |
|
|---|
| 8714 | /// Prepare the auto_imports states in a vector
|
|---|
| 8715 |
|
|---|
| 8716 | cmt_vector<bool> base_auto_imports_states;
|
|---|
| 8717 |
|
|---|
| 8718 | base_auto_imports_states.resize (Uses.size ());
|
|---|
| 8719 |
|
|---|
| 8720 | int number;
|
|---|
| 8721 |
|
|---|
| 8722 | for (number = 0; number < Uses.size (); number++)
|
|---|
| 8723 | {
|
|---|
| 8724 | Use* use = Uses[number];
|
|---|
| 8725 | base_auto_imports_states[number] = (use->auto_imports != Off);
|
|---|
| 8726 | }
|
|---|
| 8727 |
|
|---|
| 8728 | /// Now scan all constituents
|
|---|
| 8729 |
|
|---|
| 8730 | for (number = 0; number < constituents.size (); number++)
|
|---|
| 8731 | {
|
|---|
| 8732 | const Constituent& constituent = constituents[number];
|
|---|
| 8733 |
|
|---|
| 8734 | Use::UsePtrVector imports;
|
|---|
| 8735 | int i;
|
|---|
| 8736 |
|
|---|
| 8737 | /**
|
|---|
| 8738 | * Problem for imports in constituents.
|
|---|
| 8739 | *
|
|---|
| 8740 | * 1) use_xxx has holes due to the corresponding
|
|---|
| 8741 | * -no_auto_imports options attached to some
|
|---|
| 8742 | * use statements (including the transitive ones)
|
|---|
| 8743 | *
|
|---|
| 8744 | * 2) the -import=yyy options provided to a given constituent
|
|---|
| 8745 | * should restore the appropriate holes as well as
|
|---|
| 8746 | * all transitive ones.
|
|---|
| 8747 | *
|
|---|
| 8748 | * 3) for use_linkopts, missing pieces must be filled at
|
|---|
| 8749 | * the right position. (for others, order is not relevant
|
|---|
| 8750 | * while transitive access is required for all)
|
|---|
| 8751 | *
|
|---|
| 8752 | */
|
|---|
| 8753 |
|
|---|
| 8754 | if (constituent.type == Document) continue;
|
|---|
| 8755 | if (constituent.imports.size () == 0)
|
|---|
| 8756 | {
|
|---|
| 8757 | buffer = "macro_append ";
|
|---|
| 8758 | buffer += constituent.name;
|
|---|
| 8759 | buffer += "_use_linkopts ";
|
|---|
| 8760 | buffer += " \" ";
|
|---|
| 8761 |
|
|---|
| 8762 | current_use->fill_macro (buffer, "linkopts");
|
|---|
| 8763 |
|
|---|
| 8764 | for (i = 0; i < Uses.size (); i++)
|
|---|
| 8765 | {
|
|---|
| 8766 | if (base_auto_imports_states[i])
|
|---|
| 8767 | {
|
|---|
| 8768 | Use* u = Uses[i];
|
|---|
| 8769 |
|
|---|
| 8770 | if (u->discarded) continue;
|
|---|
| 8771 |
|
|---|
| 8772 | Package* p = u->get_package ();
|
|---|
| 8773 | if (p->is_cmt ()) continue;
|
|---|
| 8774 |
|
|---|
| 8775 | u->fill_macro (buffer, "linkopts");
|
|---|
| 8776 | }
|
|---|
| 8777 | }
|
|---|
| 8778 | buffer += "\"";
|
|---|
| 8779 | apply ();
|
|---|
| 8780 |
|
|---|
| 8781 | /*
|
|---|
| 8782 | buffer = "macro_append ";
|
|---|
| 8783 | buffer += constituent.name;
|
|---|
| 8784 | buffer += "_use_linkopts ";
|
|---|
| 8785 |
|
|---|
| 8786 | buffer += " \" $(use_linkopts)\"";
|
|---|
| 8787 | apply ();
|
|---|
| 8788 | */
|
|---|
| 8789 |
|
|---|
| 8790 | continue;
|
|---|
| 8791 | }
|
|---|
| 8792 |
|
|---|
| 8793 | /**
|
|---|
| 8794 | * Create a private copy of the state vector. This private copy
|
|---|
| 8795 | * will be updated according to -import=xxx modifiers for the
|
|---|
| 8796 | * current constituent.
|
|---|
| 8797 | */
|
|---|
| 8798 | cmt_vector<bool> auto_imports_states (base_auto_imports_states);
|
|---|
| 8799 |
|
|---|
| 8800 | for (i = 0; i < constituent.imports.size (); i++)
|
|---|
| 8801 | {
|
|---|
| 8802 | const cmt_string& import = constituent.imports[i];
|
|---|
| 8803 |
|
|---|
| 8804 | //
|
|---|
| 8805 | // Resolve the imported uses
|
|---|
| 8806 | //
|
|---|
| 8807 |
|
|---|
| 8808 | int use_index = Use::find_index (import, "", "");
|
|---|
| 8809 |
|
|---|
| 8810 | if (use_index >= 0)
|
|---|
| 8811 | {
|
|---|
| 8812 | Use* u = Uses[use_index];
|
|---|
| 8813 |
|
|---|
| 8814 | if (u->discarded) continue;
|
|---|
| 8815 |
|
|---|
| 8816 | if (Cmt::get_debug ())
|
|---|
| 8817 | {
|
|---|
| 8818 | cout << constituent.name << " needs imports " << import << " "
|
|---|
| 8819 | << use_index << " "
|
|---|
| 8820 | << u->get_package()->get_name() << endl;
|
|---|
| 8821 | }
|
|---|
| 8822 |
|
|---|
| 8823 | Package* p = u->get_package ();
|
|---|
| 8824 | if (p->is_cmt ()) continue;
|
|---|
| 8825 |
|
|---|
| 8826 | if (u->auto_imports != Off) continue;
|
|---|
| 8827 |
|
|---|
| 8828 | Use::set_auto_imports_state (use_index, auto_imports_states);
|
|---|
| 8829 | }
|
|---|
| 8830 | }
|
|---|
| 8831 |
|
|---|
| 8832 | if (Cmt::get_debug ())
|
|---|
| 8833 | {
|
|---|
| 8834 | cout << constituent.name << " has imports " << endl;
|
|---|
| 8835 | }
|
|---|
| 8836 |
|
|---|
| 8837 |
|
|---|
| 8838 | /**
|
|---|
| 8839 | * Find all newly exposed packages and precompute this list inside
|
|---|
| 8840 | * a vector.
|
|---|
| 8841 | */
|
|---|
| 8842 | for (i = 0; i < base_auto_imports_states.size (); i++)
|
|---|
| 8843 | {
|
|---|
| 8844 | if (auto_imports_states[i] != base_auto_imports_states[i])
|
|---|
| 8845 | {
|
|---|
| 8846 | Use* u = Uses[i];
|
|---|
| 8847 |
|
|---|
| 8848 | if (u->discarded) continue;
|
|---|
| 8849 |
|
|---|
| 8850 | Package* p = u->get_package ();
|
|---|
| 8851 | if (p->is_cmt ()) continue;
|
|---|
| 8852 |
|
|---|
| 8853 | if (Cmt::get_debug ())
|
|---|
| 8854 | {
|
|---|
| 8855 | cout << constituent.name << " has import " << p->get_name () << endl;
|
|---|
| 8856 | }
|
|---|
| 8857 |
|
|---|
| 8858 | if (u->auto_imports != Off) continue;
|
|---|
| 8859 |
|
|---|
| 8860 | imports.push_back (u);
|
|---|
| 8861 | }
|
|---|
| 8862 | }
|
|---|
| 8863 |
|
|---|
| 8864 | if (imports.size () == 0) return;
|
|---|
| 8865 |
|
|---|
| 8866 | cmt_string prefix;
|
|---|
| 8867 |
|
|---|
| 8868 | //
|
|---|
| 8869 | // Documents are not considered
|
|---|
| 8870 | //
|
|---|
| 8871 | switch (constituent.type)
|
|---|
| 8872 | {
|
|---|
| 8873 | case Application:
|
|---|
| 8874 | prefix = "app_";
|
|---|
| 8875 | break;
|
|---|
| 8876 | case Library:
|
|---|
| 8877 | prefix = "lib_";
|
|---|
| 8878 | break;
|
|---|
| 8879 | }
|
|---|
| 8880 |
|
|---|
| 8881 | buffer = "macro_append ";
|
|---|
| 8882 | buffer += prefix;
|
|---|
| 8883 | buffer += constituent.name;
|
|---|
| 8884 | buffer += "_cflags ";
|
|---|
| 8885 | buffer += " \' ";
|
|---|
| 8886 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8887 | {
|
|---|
| 8888 | Use* u = imports[i];
|
|---|
| 8889 |
|
|---|
| 8890 | u->fill_includes_macro (buffer);
|
|---|
| 8891 | u->fill_macro (buffer, "cflags");
|
|---|
| 8892 | }
|
|---|
| 8893 | buffer += "\'";
|
|---|
| 8894 | apply ();
|
|---|
| 8895 |
|
|---|
| 8896 | buffer = "macro_append ";
|
|---|
| 8897 | buffer += prefix;
|
|---|
| 8898 | buffer += constituent.name;
|
|---|
| 8899 | buffer += "_pp_cflags ";
|
|---|
| 8900 | buffer += " \" ";
|
|---|
| 8901 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8902 | {
|
|---|
| 8903 | Use* u = imports[i];
|
|---|
| 8904 |
|
|---|
| 8905 | u->fill_macro (buffer, "pp_cflags");
|
|---|
| 8906 | }
|
|---|
| 8907 | buffer += "\"";
|
|---|
| 8908 | apply ();
|
|---|
| 8909 |
|
|---|
| 8910 | buffer = "macro_append ";
|
|---|
| 8911 | buffer += prefix;
|
|---|
| 8912 | buffer += constituent.name;
|
|---|
| 8913 | buffer += "_cppflags ";
|
|---|
| 8914 | buffer += " \' ";
|
|---|
| 8915 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8916 | {
|
|---|
| 8917 | Use* u = imports[i];
|
|---|
| 8918 |
|
|---|
| 8919 | u->fill_includes_macro (buffer);
|
|---|
| 8920 | u->fill_macro (buffer, "cppflags");
|
|---|
| 8921 | }
|
|---|
| 8922 | buffer += "\'";
|
|---|
| 8923 | apply ();
|
|---|
| 8924 |
|
|---|
| 8925 | buffer = "macro_append ";
|
|---|
| 8926 | buffer += prefix;
|
|---|
| 8927 | buffer += constituent.name;
|
|---|
| 8928 | buffer += "_pp_cppflags ";
|
|---|
| 8929 | buffer += " \" ";
|
|---|
| 8930 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8931 | {
|
|---|
| 8932 | Use* u = imports[i];
|
|---|
| 8933 |
|
|---|
| 8934 | u->fill_macro (buffer, "pp_cppflags");
|
|---|
| 8935 | }
|
|---|
| 8936 | buffer += "\"";
|
|---|
| 8937 | apply ();
|
|---|
| 8938 |
|
|---|
| 8939 | buffer = "macro_append ";
|
|---|
| 8940 | buffer += prefix;
|
|---|
| 8941 | buffer += constituent.name;
|
|---|
| 8942 | buffer += "_fflags ";
|
|---|
| 8943 | buffer += " \' ";
|
|---|
| 8944 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8945 | {
|
|---|
| 8946 | Use* u = imports[i];
|
|---|
| 8947 |
|
|---|
| 8948 | u->fill_includes_macro (buffer);
|
|---|
| 8949 | u->fill_macro (buffer, "fflags");
|
|---|
| 8950 | }
|
|---|
| 8951 | buffer += "\'";
|
|---|
| 8952 | apply ();
|
|---|
| 8953 |
|
|---|
| 8954 | buffer = "macro_append ";
|
|---|
| 8955 | buffer += prefix;
|
|---|
| 8956 | buffer += constituent.name;
|
|---|
| 8957 | buffer += "_pp_fflags ";
|
|---|
| 8958 | buffer += " \" ";
|
|---|
| 8959 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8960 | {
|
|---|
| 8961 | Use* u = imports[i];
|
|---|
| 8962 |
|
|---|
| 8963 | u->fill_macro (buffer, "pp_fflags");
|
|---|
| 8964 | }
|
|---|
| 8965 | buffer += "\"";
|
|---|
| 8966 | apply ();
|
|---|
| 8967 |
|
|---|
| 8968 | /**
|
|---|
| 8969 | * Setting ${CONSTITUENT}linkopts is a temporary solution
|
|---|
| 8970 | * until the backward compatibility solution for a proper
|
|---|
| 8971 | * replacement of use_linkopts by ${CONSTITUENT}_use_linkopts
|
|---|
| 8972 | * is acheived.
|
|---|
| 8973 | *
|
|---|
| 8974 | */
|
|---|
| 8975 | buffer = "macro_append ";
|
|---|
| 8976 | buffer += constituent.name;
|
|---|
| 8977 | buffer += "linkopts ";
|
|---|
| 8978 | buffer += " \" ";
|
|---|
| 8979 | for (i = 0; i < imports.size (); i++)
|
|---|
| 8980 | {
|
|---|
| 8981 | Use* u = imports[i];
|
|---|
| 8982 |
|
|---|
| 8983 | u->fill_macro (buffer, "linkopts");
|
|---|
| 8984 | }
|
|---|
| 8985 | buffer += "\"";
|
|---|
| 8986 | apply ();
|
|---|
| 8987 |
|
|---|
| 8988 | /**
|
|---|
| 8989 | * Only for linkopts we take care of the order. This means
|
|---|
| 8990 | * that ${CONSTITUENT}_use_linkopts should be used in place of use_linkopts.
|
|---|
| 8991 | *
|
|---|
| 8992 | * (see the application fragments)
|
|---|
| 8993 | * that ${CONSTITUENT}_use_linkopts will be used in place of use_linkopts.
|
|---|
| 8994 | */
|
|---|
| 8995 | buffer = "macro_append ";
|
|---|
| 8996 | buffer += constituent.name;
|
|---|
| 8997 | buffer += "_use_linkopts ";
|
|---|
| 8998 | buffer += " \" ";
|
|---|
| 8999 |
|
|---|
| 9000 | current_use->fill_macro (buffer, "linkopts");
|
|---|
| 9001 |
|
|---|
| 9002 | for (i = 0; i < Uses.size (); i++)
|
|---|
| 9003 | {
|
|---|
| 9004 | if (auto_imports_states[i])
|
|---|
| 9005 | {
|
|---|
| 9006 | Use* u = Uses[i];
|
|---|
| 9007 |
|
|---|
| 9008 | if (u->discarded) continue;
|
|---|
| 9009 |
|
|---|
| 9010 | Package* p = u->get_package ();
|
|---|
| 9011 | if (p->is_cmt ()) continue;
|
|---|
| 9012 |
|
|---|
| 9013 | u->fill_macro (buffer, "linkopts");
|
|---|
| 9014 | }
|
|---|
| 9015 | }
|
|---|
| 9016 | buffer += "\"";
|
|---|
| 9017 | apply ();
|
|---|
| 9018 |
|
|---|
| 9019 | //==== GLAST addition for vs.net ==========
|
|---|
| 9020 | buffer = "macro ";
|
|---|
| 9021 | buffer += constituent.name;
|
|---|
| 9022 | buffer += "_GUID \"{88BF15AB-5A2D-4bea-B64F-02752C2A1F4F}\" ";
|
|---|
| 9023 | apply ();
|
|---|
| 9024 | }
|
|---|
| 9025 | }
|
|---|
| 9026 |
|
|---|
| 9027 | /**
|
|---|
| 9028 | * Macros to be defined once current_package is known
|
|---|
| 9029 | * and even before reading its requirements file.
|
|---|
| 9030 | */
|
|---|
| 9031 | void fill_for_current_package (const cmt_string& current_dir)
|
|---|
| 9032 | {
|
|---|
| 9033 | fill_for_tag ();
|
|---|
| 9034 | fill_for_package (current_dir);
|
|---|
| 9035 | }
|
|---|
| 9036 |
|
|---|
| 9037 | private:
|
|---|
| 9038 | cmt_string fs;
|
|---|
| 9039 | cmt_string buffer;
|
|---|
| 9040 | CmtSystem::cmt_string_vector vb;
|
|---|
| 9041 | cmt_string pwd;
|
|---|
| 9042 | Use* current_use;
|
|---|
| 9043 | cmt_string current_tag;
|
|---|
| 9044 | cmt_string current_package;
|
|---|
| 9045 | cmt_string current_version;
|
|---|
| 9046 | cmt_string current_prefix;
|
|---|
| 9047 | CmtDirStyle current_style;
|
|---|
| 9048 | };
|
|---|
| 9049 |
|
|---|
| 9050 | //----------------------------------------------------------
|
|---|
| 9051 | void Cmt::set_current_access (AccessMode mode)
|
|---|
| 9052 | {
|
|---|
| 9053 | m_current_access = mode;
|
|---|
| 9054 | }
|
|---|
| 9055 |
|
|---|
| 9056 | //----------------------------------------------------------
|
|---|
| 9057 | void Cmt::set_current_build_strategy (int strategy)
|
|---|
| 9058 | {
|
|---|
| 9059 | m_current_build_strategy = strategy;
|
|---|
| 9060 | }
|
|---|
| 9061 |
|
|---|
| 9062 | //----------------------------------------------------------
|
|---|
| 9063 | void Cmt::set_current_setup_strategy (int strategy)
|
|---|
| 9064 | {
|
|---|
| 9065 | m_current_setup_strategy = strategy;
|
|---|
| 9066 | }
|
|---|
| 9067 |
|
|---|
| 9068 | //----------------------------------------------------------
|
|---|
| 9069 | void Cmt::set_scope_filtering_mode (CmtScopeFilteringMode mode)
|
|---|
| 9070 | {
|
|---|
| 9071 | m_scope_filtering_mode = mode;
|
|---|
| 9072 | }
|
|---|
| 9073 |
|
|---|
| 9074 | //----------------------------------------------------------
|
|---|
| 9075 | void Cmt::set_standard_macros ()
|
|---|
| 9076 | {
|
|---|
| 9077 | if (m_standard_macros_done) return;
|
|---|
| 9078 |
|
|---|
| 9079 | m_standard_macros_done = true;
|
|---|
| 9080 |
|
|---|
| 9081 | int number;
|
|---|
| 9082 | cmt_string temp;
|
|---|
| 9083 | Use::UsePtrVector& Uses = Use::get_ordered_uses ();
|
|---|
| 9084 | Use& current_use = Use::current ();
|
|---|
| 9085 |
|
|---|
| 9086 | cmt_string fs = CmtSystem::file_separator ();
|
|---|
| 9087 |
|
|---|
| 9088 | cmt_string pwd = CmtSystem::pwd ();
|
|---|
| 9089 |
|
|---|
| 9090 | if (CmtSystem::test_file ("../cmt/requirements")) m_current_style = cmt_style;
|
|---|
| 9091 | else if (CmtSystem::test_file ("../mgr/requirements")) m_current_style = mgr_style;
|
|---|
| 9092 | else m_current_style = none_style;
|
|---|
| 9093 |
|
|---|
| 9094 | {
|
|---|
| 9095 | cmt_string v;
|
|---|
| 9096 | CmtSystem::dirname (pwd, v);
|
|---|
| 9097 | CmtSystem::basename (v, v);
|
|---|
| 9098 | if (!CmtSystem::is_version_directory (v))
|
|---|
| 9099 | {
|
|---|
| 9100 | m_current_style = no_version_style;
|
|---|
| 9101 | }
|
|---|
| 9102 | }
|
|---|
| 9103 |
|
|---|
| 9104 | // Prepare computation of the best form for relative path from current directory
|
|---|
| 9105 | // to package directories.
|
|---|
| 9106 | CmtSystem::cmt_string_vector vb;
|
|---|
| 9107 | CmtSystem::split (pwd, fs, vb);
|
|---|
| 9108 |
|
|---|
| 9109 |
|
|---|
| 9110 | /**
|
|---|
| 9111 | * TAG management
|
|---|
| 9112 | */
|
|---|
| 9113 |
|
|---|
| 9114 | bool tag_debug = CmtSystem::testenv ("TAGDEBUG");
|
|---|
| 9115 |
|
|---|
| 9116 | if (tag_debug) cerr << "set_standard_macro0> current_tag=" << m_current_tag << endl;
|
|---|
| 9117 |
|
|---|
| 9118 | if (m_current_tag != "")
|
|---|
| 9119 | {
|
|---|
| 9120 | // this is when some -tag= argument was used.
|
|---|
| 9121 | if (tag_debug) cerr << "set_standard_macro0.1> current_tag=" << m_current_tag << endl;
|
|---|
| 9122 | }
|
|---|
| 9123 | else if (Symbol::is_selected ("CMTCONFIG"))
|
|---|
| 9124 | {
|
|---|
| 9125 | // This is when CMTCONFIG has been set from some requirements file
|
|---|
| 9126 | Symbol* macro = Symbol::find ("CMTCONFIG");
|
|---|
| 9127 | if (macro != 0)
|
|---|
| 9128 | {
|
|---|
| 9129 | m_current_tag = macro->build_macro_value ();
|
|---|
| 9130 | if (tag_debug) cerr << "set_standard_macro1> current_tag=" << m_current_tag << endl;
|
|---|
| 9131 | }
|
|---|
| 9132 | }
|
|---|
| 9133 | else
|
|---|
| 9134 | {
|
|---|
| 9135 | // this is when no -tag= argument was used.
|
|---|
| 9136 | if (tag_debug) cerr << "set_standard_macro(before2)> current_tag=" << m_current_tag << endl;
|
|---|
| 9137 | if (current_use.get_package_name () == "CMT")
|
|---|
| 9138 | {
|
|---|
| 9139 | m_current_tag = CmtSystem::getenv ("CMTBIN");
|
|---|
| 9140 | }
|
|---|
| 9141 | else
|
|---|
| 9142 | {
|
|---|
| 9143 | m_current_tag = CmtSystem::getenv ("CMTCONFIG");
|
|---|
| 9144 | }
|
|---|
| 9145 |
|
|---|
| 9146 | if (tag_debug) cerr << "set_standard_macro2> current_tag=" << m_current_tag << endl;
|
|---|
| 9147 | }
|
|---|
| 9148 |
|
|---|
| 9149 | if (m_debug)
|
|---|
| 9150 | {
|
|---|
| 9151 | cout << "set_standard_macro3>" << endl;
|
|---|
| 9152 | }
|
|---|
| 9153 |
|
|---|
| 9154 | StandardMacroBuilder builder (m_current_tag,
|
|---|
| 9155 | m_current_package,
|
|---|
| 9156 | m_current_version,
|
|---|
| 9157 | m_current_prefix,
|
|---|
| 9158 | m_current_style);
|
|---|
| 9159 |
|
|---|
| 9160 |
|
|---|
| 9161 | //
|
|---|
| 9162 | // Definitions for installation area mechanisms
|
|---|
| 9163 | //
|
|---|
| 9164 | if ((get_build_strategy () & InstallAreaMask) == WithInstallArea)
|
|---|
| 9165 | {
|
|---|
| 9166 | CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
|
|---|
| 9167 |
|
|---|
| 9168 | //cout << "#IA6>" << endl;
|
|---|
| 9169 |
|
|---|
| 9170 | ia_mgr.setup_current_installarea ();
|
|---|
| 9171 | }
|
|---|
| 9172 |
|
|---|
| 9173 | builder.fill_for_current_package (m_current_dir);
|
|---|
| 9174 |
|
|---|
| 9175 | builder.fill_for_branches ();
|
|---|
| 9176 | builder.fill_for_project ();
|
|---|
| 9177 | builder.fill_for_use_requirements ();
|
|---|
| 9178 | builder.fill_for_use_includes ();
|
|---|
| 9179 | builder.fill_for_use_fincludes ();
|
|---|
| 9180 | builder.fill_for_use_stamps ();
|
|---|
| 9181 | builder.fill_for_use_cflags ();
|
|---|
| 9182 | builder.fill_for_use_pp_cflags ();
|
|---|
| 9183 | builder.fill_for_use_cppflags ();
|
|---|
| 9184 | builder.fill_for_use_pp_cppflags ();
|
|---|
| 9185 | builder.fill_for_use_fflags ();
|
|---|
| 9186 | builder.fill_for_use_pp_fflags ();
|
|---|
| 9187 | builder.fill_for_use_linkopts ();
|
|---|
| 9188 | builder.fill_for_use_libraries ();
|
|---|
| 9189 | builder.fill_for_includes ();
|
|---|
| 9190 | builder.fill_for_fincludes ();
|
|---|
| 9191 | builder.fill_for_all_constituents ();
|
|---|
| 9192 |
|
|---|
| 9193 | /**
|
|---|
| 9194 | * Macros implied or required to manage constituents.
|
|---|
| 9195 | */
|
|---|
| 9196 |
|
|---|
| 9197 | const Constituent::ConstituentVector& constituents =
|
|---|
| 9198 | Constituent::constituents ();
|
|---|
| 9199 |
|
|---|
| 9200 | if (!Symbol::is_selected ("constituents"))
|
|---|
| 9201 | {
|
|---|
| 9202 | temp = "macro_append constituents \" ";
|
|---|
| 9203 |
|
|---|
| 9204 | for (number = 0; number < constituents.size (); number++)
|
|---|
| 9205 | {
|
|---|
| 9206 | const Constituent& constituent = constituents[number];
|
|---|
| 9207 |
|
|---|
| 9208 | if (constituent.group == 0)
|
|---|
| 9209 | {
|
|---|
| 9210 | temp += constituent.name;
|
|---|
| 9211 | temp += " ";
|
|---|
| 9212 | }
|
|---|
| 9213 | }
|
|---|
| 9214 |
|
|---|
| 9215 | temp += "\"";
|
|---|
| 9216 |
|
|---|
| 9217 | SyntaxParser::parse_requirements_line (temp, ¤t_use);
|
|---|
| 9218 | }
|
|---|
| 9219 |
|
|---|
| 9220 | SyntaxParser::parse_requirements_line ("macro_append all_constituents \" $(constituents)\"",
|
|---|
| 9221 | ¤t_use);
|
|---|
| 9222 |
|
|---|
| 9223 | if (!Symbol::is_selected ("constituentsclean"))
|
|---|
| 9224 | {
|
|---|
| 9225 | temp = "macro_append constituentsclean \" ";
|
|---|
| 9226 |
|
|---|
| 9227 | for (number = constituents.size () - 1; number >= 0 ; number--)
|
|---|
| 9228 | {
|
|---|
| 9229 | const Constituent& constituent = constituents[number];
|
|---|
| 9230 |
|
|---|
| 9231 | if (constituent.group == 0)
|
|---|
| 9232 | {
|
|---|
| 9233 | temp += constituent.name;
|
|---|
| 9234 | temp += "clean ";
|
|---|
| 9235 | }
|
|---|
| 9236 | }
|
|---|
| 9237 |
|
|---|
| 9238 | temp += "\"";
|
|---|
| 9239 |
|
|---|
| 9240 | SyntaxParser::parse_requirements_line (temp, ¤t_use);
|
|---|
| 9241 | }
|
|---|
| 9242 |
|
|---|
| 9243 | SyntaxParser::parse_requirements_line ("macro_append all_constituentsclean \" $(constituentsclean)\"",
|
|---|
| 9244 | ¤t_use);
|
|---|
| 9245 |
|
|---|
| 9246 | const Group::GroupVector& groups = Group::groups ();
|
|---|
| 9247 |
|
|---|
| 9248 | for (number = 0; number < groups.size (); number++)
|
|---|
| 9249 | {
|
|---|
| 9250 | const Group& group = groups[number];
|
|---|
| 9251 |
|
|---|
| 9252 | temp = "macro_append ";
|
|---|
| 9253 | temp += group.name ();
|
|---|
| 9254 | temp += "_constituents \" ";
|
|---|
| 9255 |
|
|---|
| 9256 | int i;
|
|---|
| 9257 |
|
|---|
| 9258 | for (i = 0; i < constituents.size (); i++)
|
|---|
| 9259 | {
|
|---|
| 9260 | const Constituent& constituent = constituents[i];
|
|---|
| 9261 |
|
|---|
| 9262 | if ((constituent.group != 0) &&
|
|---|
| 9263 | (group.name () == constituent.group->name ()))
|
|---|
| 9264 | {
|
|---|
| 9265 | temp += constituent.name;
|
|---|
| 9266 | temp += " ";
|
|---|
| 9267 | }
|
|---|
| 9268 | }
|
|---|
| 9269 |
|
|---|
| 9270 | temp += "\"";
|
|---|
| 9271 |
|
|---|
| 9272 | SyntaxParser::parse_requirements_line (temp, ¤t_use);
|
|---|
| 9273 |
|
|---|
| 9274 | temp = "macro_append ";
|
|---|
| 9275 | temp += group.name ();
|
|---|
| 9276 | temp += "_constituentsclean \" ";
|
|---|
| 9277 |
|
|---|
| 9278 | for (i = constituents.size () - 1; i >= 0 ; i--)
|
|---|
| 9279 | {
|
|---|
| 9280 | const Constituent& constituent = constituents[i];
|
|---|
| 9281 |
|
|---|
| 9282 | if ((constituent.group != 0) &&
|
|---|
| 9283 | (group.name () == constituent.group->name ()))
|
|---|
| 9284 | {
|
|---|
| 9285 | temp += constituent.name;
|
|---|
| 9286 | temp += "clean ";
|
|---|
| 9287 | }
|
|---|
| 9288 | }
|
|---|
| 9289 |
|
|---|
| 9290 | temp += "\"";
|
|---|
| 9291 |
|
|---|
| 9292 | SyntaxParser::parse_requirements_line (temp, ¤t_use);
|
|---|
| 9293 | }
|
|---|
| 9294 |
|
|---|
| 9295 | //
|
|---|
| 9296 | // Definitions for installation area mechanisms. Apply all cmtpath patterns
|
|---|
| 9297 | //
|
|---|
| 9298 | if ((get_build_strategy () & InstallAreaMask) == WithInstallArea)
|
|---|
| 9299 | {
|
|---|
| 9300 | CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
|
|---|
| 9301 |
|
|---|
| 9302 | //cout << "#IA7>" << endl;
|
|---|
| 9303 |
|
|---|
| 9304 | ia_mgr.setup ();
|
|---|
| 9305 | }
|
|---|
| 9306 |
|
|---|
| 9307 | CmtPathPattern::apply_all ();
|
|---|
| 9308 | }
|
|---|
| 9309 |
|
|---|
| 9310 | //----------------------------------------------------------
|
|---|
| 9311 | void Cmt::use_cmt ()
|
|---|
| 9312 | {
|
|---|
| 9313 | UseRef use;
|
|---|
| 9314 | bool recursive_copy = m_recursive;
|
|---|
| 9315 | bool debug_copy = m_debug;
|
|---|
| 9316 |
|
|---|
| 9317 | if (m_default_path.size () <= 0) return;
|
|---|
| 9318 | if (m_current_package == "CMT") return;
|
|---|
| 9319 |
|
|---|
| 9320 | m_recursive = true;
|
|---|
| 9321 | m_debug = false;
|
|---|
| 9322 | use = Use::add (m_default_path, "CMT", m_cmt_version, "", "", 0);
|
|---|
| 9323 | m_recursive = recursive_copy;
|
|---|
| 9324 | m_debug = debug_copy;
|
|---|
| 9325 | }
|
|---|
| 9326 |
|
|---|
| 9327 | //----------------------------------------------------------
|
|---|
| 9328 | void Cmt::use_home_requirements ()
|
|---|
| 9329 | {
|
|---|
| 9330 | use_special_requirements (m_cmt_home,
|
|---|
| 9331 | CmtSystem::get_home_package (),
|
|---|
| 9332 | "requirements");
|
|---|
| 9333 | }
|
|---|
| 9334 |
|
|---|
| 9335 | //----------------------------------------------------------
|
|---|
| 9336 | void Cmt::use_user_context_requirements ()
|
|---|
| 9337 | {
|
|---|
| 9338 | use_special_requirements (m_cmt_user_context,
|
|---|
| 9339 | CmtSystem::get_user_context_package (),
|
|---|
| 9340 | "requirements");
|
|---|
| 9341 | }
|
|---|
| 9342 |
|
|---|
| 9343 | //----------------------------------------------------------
|
|---|
| 9344 | void Cmt::use_special_requirements (const cmt_string& path,
|
|---|
| 9345 | const cmt_string& name,
|
|---|
| 9346 | const cmt_string& file_name)
|
|---|
| 9347 | {
|
|---|
| 9348 | if (path == "")
|
|---|
| 9349 | {
|
|---|
| 9350 | return;
|
|---|
| 9351 | }
|
|---|
| 9352 |
|
|---|
| 9353 | UseRef use;
|
|---|
| 9354 | bool recursive_copy = m_recursive;
|
|---|
| 9355 |
|
|---|
| 9356 | if (m_default_path.size () <= 0) return;
|
|---|
| 9357 | if (m_current_package == "CMT") return;
|
|---|
| 9358 |
|
|---|
| 9359 | m_recursive = true;
|
|---|
| 9360 |
|
|---|
| 9361 | use = Use::add (path, name, "v0", "", "", 0);
|
|---|
| 9362 |
|
|---|
| 9363 | cmt_string f = m_cmt_user_context;
|
|---|
| 9364 | f += CmtSystem::file_separator ();
|
|---|
| 9365 | f += file_name;
|
|---|
| 9366 | SyntaxParser::parse_requirements (f, use);
|
|---|
| 9367 |
|
|---|
| 9368 | m_recursive = recursive_copy;
|
|---|
| 9369 | }
|
|---|
| 9370 |
|
|---|
| 9371 | //-------------------------------------------------
|
|---|
| 9372 | void Cmt::vector_to_string (const CmtSystem::cmt_string_vector& v,
|
|---|
| 9373 | const cmt_string& separator,
|
|---|
| 9374 | cmt_string& result)
|
|---|
| 9375 | {
|
|---|
| 9376 | result.erase (0);
|
|---|
| 9377 |
|
|---|
| 9378 | for (int i = 0; i < v.size (); i++)
|
|---|
| 9379 | {
|
|---|
| 9380 | const cmt_string& s = v[i];
|
|---|
| 9381 | if (s == "") continue;
|
|---|
| 9382 |
|
|---|
| 9383 | if (i > 0) result += separator;
|
|---|
| 9384 | result += v[i];
|
|---|
| 9385 | }
|
|---|
| 9386 | }
|
|---|
| 9387 |
|
|---|
| 9388 | //-------------------------------------------------
|
|---|
| 9389 | cmt_string Cmt::vector_to_string (const CmtSystem::cmt_string_vector& v)
|
|---|
| 9390 | {
|
|---|
| 9391 | cmt_string result;
|
|---|
| 9392 |
|
|---|
| 9393 | vector_to_string (v, " ", result);
|
|---|
| 9394 |
|
|---|
| 9395 | return (result);
|
|---|
| 9396 | }
|
|---|