Changeset 429


Ignore:
Timestamp:
Nov 22, 2007, 4:43:10 PM (17 years ago)
Author:
rybkin
Message:

See C.L. 335

Location:
CMT/HEAD
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r428 r429  
     12007-11-22    <rybkin@lal.in2p3.fr> 335
     2
     3        * source/cmt_generators.h: idem
     4        * source/cmt_generators.cxx: idem
     5        * source/cmt_lock.cxx: idem
     6        * mgr/fragments/constituent_lock: idem
     7        * mgr/fragments/nmake/constituent_lock: idem
     8        * mgr/requirements: Implement a locking mechanism to allow simultaneous/parallel
     9        builds for multiple binary tags. Used suggestions from Pere, Stefan, and Andrea
     10        * mgr/lockfile.bat: Basic semaphore-file creator for Windows
     11        * mgr/lockfile.sh: Basic semaphore-file creator for Unix
     12       
    1132007-10-31    <rybkin@lal.in2p3.fr> 334
    214
  • CMT/HEAD/mgr/requirements

    r348 r429  
    445445macro library_suffix ""
    446446
    447 macro lock_command "chmod -R a-w ../*" \   
    448       VisualC      "attrib /S /D +R ..\*"
    449 
    450 macro unlock_command "chmod -R g+w ../*" \   
    451       VisualC      "attrib /S /D -R ..\*"
     447macro lock_command "" \
     448      Linux        "lockfile " \
     449      Darwin       "lockfile " \
     450      VisualC      "%CMTROOT%\mgr\lockfile.bat "
     451
     452macro unlock_command "rm -rf " \   
     453      VisualC        "rmdir "
     454
     455macro lock_name "cmt"
     456macro lock_suffix ".lock"
     457macro lock_file "${lock_name}${lock_suffix}"
    452458
    453459macro preprocessor_command "" \
     
    554560make_fragment group
    555561make_fragment constituent
     562make_fragment constituent_lock
    556563make_fragment constituents_trailer
    557564
  • CMT/HEAD/source/cmt_generators.cxx

    r428 r429  
    24042404  group_fragment.set ("group");
    24052405  constituent_fragment.set ("constituent");
     2406  constituent_lock_fragment.set ("constituent_lock");
    24062407  check_application_header_fragment.set ("check_application_header");
    24072408}
     
    24142415  group_fragment.reset ();
    24152416  constituent_fragment.reset ();
     2417  constituent_lock_fragment.reset ();
    24162418  check_application_header_fragment.reset ();
    24172419}
     
    24522454
    24532455  cmt_string save_file_name = file_name;
    2454   save_file_name += "sav";
     2456  save_file_name += "cmtsave";
    24552457
    24562458  if (CmtSystem::test_file (file_name))
     
    24872489        }
    24882490     
     2491      bool lock = false;
     2492      Symbol* lock_command_macro = Symbol::find ("lock_command");
     2493      if (lock_command_macro != 0)
     2494        {
     2495          cmt_string lock_command = lock_command_macro->resolve_macro_value ();
     2496          if (lock_command != "")
     2497            {
     2498              Symbol* unlock_command_macro = Symbol::find ("unlock_command");
     2499              if (unlock_command_macro != 0)
     2500                {
     2501                  cmt_string unlock_command = unlock_command_macro->resolve_macro_value ();
     2502                  if (unlock_command != "")
     2503                    {
     2504                      lock = true;
     2505                    }
     2506                }
     2507            }
     2508        }
    24892509      for (number = 0; number < constituents.size (); number++)
    24902510        {
     
    25052525            }
    25062526
    2507           constituent_fragment.copy (m_output_file, constituent.variables, 5,
    2508                                      &m_PACKAGE,
    2509                                      &m_CONSTITUENT,
    2510                                      &m_CONSTITUENTSUFFIX,
    2511                                      &m_LINE,
    2512                                      &m_HASTARGETTAG);
     2527          if (constituent.type == Document && lock == true)
     2528            {
     2529              constituent_lock_fragment.copy (m_output_file, constituent.variables,
     2530                                              5,
     2531                                              &m_PACKAGE,
     2532                                              &m_CONSTITUENT,
     2533                                              &m_CONSTITUENTSUFFIX,
     2534                                              &m_LINE,
     2535                                              &m_HASTARGETTAG);
     2536            }
     2537          else
     2538            {
     2539              constituent_fragment.copy (m_output_file, constituent.variables,
     2540                                         5,
     2541                                         &m_PACKAGE,
     2542                                         &m_CONSTITUENT,
     2543                                         &m_CONSTITUENTSUFFIX,
     2544                                         &m_LINE,
     2545                                         &m_HASTARGETTAG);
     2546            }
    25132547
    25142548          if (constituent.need_check)
  • CMT/HEAD/source/cmt_generators.h

    r428 r429  
    208208  FragmentHandle group_fragment;
    209209  FragmentHandle constituent_fragment;
     210  FragmentHandle constituent_lock_fragment;
    210211  FragmentHandle check_application_header_fragment;
    211212};
  • CMT/HEAD/source/cmt_lock.cxx

    r400 r429  
    1414CmtLock::status CmtLock::lock ()
    1515{
    16   status s = check ();
     16//   status s = check ();
    1717
    18   switch (s)
     18//   switch (s)
     19//     {
     20//     case locked_by_user:
     21//       cerr << "Package already locked by you" << endl;
     22//       return (s);
     23//     case locked_by_another_user:
     24//       CmtError::set (CmtError::cannot_lock, "lock> Package already locked by another user");
     25//       return (s);
     26//     case not_locked:
     27//       break;
     28//     }
     29
     30//   cmt_string text = "locked by ";
     31//   text += CmtSystem::user ();
     32//   text += " date ";
     33//   text += CmtSystem::now ();
     34
     35//   if (!text.write ("lock.cmt"))
     36//     {
     37//       CmtError::set (CmtError::cannot_write_lock, "lock>");
     38//       return (still_unlocked);
     39//     }
     40
     41//  cmt_string command = lock_command->build_macro_value ();
     42
     43  cmt_string lock_command;
     44  Symbol* lock_command_macro = Symbol::find ("lock_command");
     45  if (lock_command_macro != 0)
    1946    {
    20     case locked_by_user:
    21       cerr << "Package already locked by you" << endl;
    22       return (s);
    23     case locked_by_another_user:
    24       CmtError::set (CmtError::cannot_lock, "lock> Package already locked by another user");
    25       return (s);
    26     case not_locked:
    27       break;
     47      lock_command = lock_command_macro->resolve_macro_value ();
    2848    }
    29 
    30   cmt_string text = "locked by ";
    31   text += CmtSystem::user ();
    32   text += " date ";
    33   text += CmtSystem::now ();
    34 
    35   if (!text.write ("lock.cmt"))
     49  if (lock_command == "")
    3650    {
    3751      CmtError::set (CmtError::cannot_write_lock, "lock>");
     
    3953    }
    4054
    41   Symbol* lock_command = Symbol::find ("lock_command");
    42   if (lock_command != 0)
     55  cmt_string lock_file;
     56  Symbol* lock_file_macro = Symbol::find ("lock_file");
     57  if (lock_file_macro != 0)
    4358    {
    44       cmt_string command = lock_command->build_macro_value ();
     59      lock_file = lock_file_macro->resolve_macro_value ();
     60    }
     61  if (lock_file == "")
     62    {
     63      CmtError::set (CmtError::cannot_write_lock, "lock>");
     64      return (still_unlocked);
     65    }
    4566
    46       if (command != "")
    47         {
    48           if (CmtSystem::execute (command) != 0)
    49             {
    50               CmtError::set (CmtError::cannot_run_lock_command, "lock>");
    51               return (still_unlocked);
    52             }
    53         }
     67  cmt_string command = lock_command + " " + lock_file;
     68
     69  if (CmtSystem::execute (command) != 0)
     70    {
     71      CmtError::set (CmtError::cannot_run_lock_command, "lock>");
     72      return (still_unlocked);
    5473    }
    5574
     
    7291      return (s);
    7392    case not_locked:
    74       cerr << "The package was not locked" << endl;
     93      cerr << "Package not locked" << endl;
    7594      return (s);
    7695    }
    7796
    78   Symbol* unlock_command = Symbol::find ("unlock_command");
    79   if (unlock_command != 0)
     97//   Symbol* unlock_command = Symbol::find ("unlock_command");
     98//   if (unlock_command != 0)
     99//     {
     100//       cmt_string command = unlock_command->build_macro_value ();
     101
     102//       if (command != "")
     103//      {
     104//        if (CmtSystem::execute (command) != 0)
     105//          {
     106//            CmtError::set (CmtError::cannot_run_unlock_command, "unlock>");
     107//            return (still_locked);
     108//          }
     109//      }
     110//     }
     111
     112//   if (!CmtSystem::remove_file ("lock.cmt"))
     113//     {
     114//       CmtError::set (CmtError::cannot_remove_lock, "unlock>");
     115//       return (still_locked);
     116//     }
     117
     118  cmt_string unlock_command;
     119  Symbol* unlock_command_macro = Symbol::find ("unlock_command");
     120  if (unlock_command_macro != 0)
    80121    {
    81       cmt_string command = unlock_command->build_macro_value ();
    82 
    83       if (command != "")
    84         {
    85           if (CmtSystem::execute (command) != 0)
    86             {
    87               CmtError::set (CmtError::cannot_run_unlock_command, "unlock>");
    88               return (still_locked);
    89             }
    90         }
     122      unlock_command = unlock_command_macro->resolve_macro_value ();
     123    }
     124  if (unlock_command == "")
     125    {
     126      CmtError::set (CmtError::cannot_remove_lock, "unlock>");
     127      return (still_locked);
    91128    }
    92129
    93   if (!CmtSystem::remove_file ("lock.cmt"))
     130  cmt_string lock_file;
     131  Symbol* lock_file_macro = Symbol::find ("lock_file");
     132  if (lock_file_macro != 0)
     133    {
     134      lock_file = lock_file_macro->resolve_macro_value ();
     135    }
     136  if (lock_file == "")
    94137    {
    95138      CmtError::set (CmtError::cannot_remove_lock, "unlock>");
     139      return (still_locked);
     140    }
     141
     142  cmt_string command = unlock_command + " " + lock_file;
     143
     144  if (CmtSystem::execute (command) != 0)
     145    {
     146      CmtError::set (CmtError::cannot_run_unlock_command, "unlock>");
    96147      return (still_locked);
    97148    }
     
    105156CmtLock::status CmtLock::check ()
    106157{
    107   cmt_string me = CmtSystem::user ();
    108   cmt_string text;
     158//   cmt_string me = CmtSystem::user ();
     159//   cmt_string text;
    109160
    110   if (text.read ("lock.cmt"))
     161//   if (text.read ("lock.cmt"))
     162//     {
     163//       CmtSystem::cmt_string_vector words;
     164
     165//       CmtSystem::split (text, " ", words);
     166
     167//       if (words.size () >= 3)
     168//      {
     169//        if (words[2] == me)
     170//          {
     171//            return (locked_by_user);
     172//          }
     173//        else
     174//          {
     175//            return (locked_by_another_user);
     176//          }
     177//      }
     178//     }
     179  cmt_string lock_file;
     180  Symbol* lock_file_macro = Symbol::find ("lock_file");
     181  if (lock_file_macro != 0)
    111182    {
    112       CmtSystem::cmt_string_vector words;
     183      lock_file = lock_file_macro->resolve_macro_value ();
     184    }
    113185
    114       CmtSystem::split (text, " ", words);
    115 
    116       if (words.size () >= 3)
    117         {
    118           if (words[2] == me)
    119             {
    120               return (locked_by_user);
    121             }
    122           else
    123             {
    124               return (locked_by_another_user);
    125             }
    126         }
     186  if (CmtSystem::test_file (lock_file) || CmtSystem::test_directory (lock_file))
     187    {
     188      return (locked_by_user);
    127189    }
    128190       
Note: See TracChangeset for help on using the changeset viewer.