source: CMT/HEAD/source/cmt_generator.cxx @ 467

Last change on this file since 467 was 467, checked in by rybkin, 16 years ago

See C.L. 368

  • Property svn:eol-style set to native
File size: 21.7 KB
Line 
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 <errno.h>
8#include <stdio.h>
9
10#ifndef WIN32
11#include <unistd.h>
12#endif
13
14#include "cmt_generator.h"
15#include "cmt_use.h"
16#include "cmt_symbol.h"
17
18#include "cmt_generators.h"
19#include "cmt_log.h"
20
21//------------------------------------------------------------------------
22void SourceFile::set (const cmt_string name, Language& language, const cmt_string output)
23{
24  m_name = name;
25  m_language = &language;
26  m_output = output;
27 
28  CmtSystem::reduce_file_separators (m_name);
29}
30
31cmt_string SourceFile::name () const
32{
33  return (m_name);
34}
35
36Language& SourceFile::language () const
37{
38  return (*m_language);
39}
40
41cmt_string SourceFile::output () const
42{
43  return (m_output);
44}
45//------------------------------------------------------------------------
46
47//--------------------------------------------------
48CmtGenerator::CmtGenerator ()
49{
50  m_CONSTITUENT.set ("CONSTITUENT");
51  m_LINKMACRO.set ("LINKMACRO");
52  m_DOCPATH.set ("DOCPATH");
53  m_PACKAGEPATH.set ("PACKAGEPATH");
54  m_PACKAGEPREFIX.set ("PACKAGEPREFIX");
55  m_PACKAGE.set ("PACKAGE");
56  m_VERSION.set ("VERSION");
57  m_MGRSTYLE.set ("MGRSTYLE");
58  m_TITLE.set ("TITLE");
59  m_GROUP.set ("GROUP");
60  m_CONSTITUENT.set ("CONSTITUENT");
61  m_CONSTITUENTSUFFIX.set ("CONSTITUENTSUFFIX");
62  m_LIBRARYSUFFIX.set ("LIBRARYSUFFIX");
63  m_USER.set ("USER");
64  m_DATE.set ("DATE");
65  m_PROTOTARGET.set ("PROTOTARGET");
66  m_OBJS.set ("OBJS");
67  m_CLASSES.set ("CLASSES");
68  m_PROTOSTAMPS.set ("PROTOSTAMPS");
69  m_NAME.set ("NAME");
70  m_FILEPATH.set ("FILEPATH");
71  m_FILESUFFIX.set ("FILESUFFIX");
72  m_SUFFIX.set ("SUFFIX");
73  m_FILENAME.set ("FILENAME");
74  m_LINKMACRO.set ("LINKMACRO");
75  m_LINE.set ("LINE");
76  m_ADDINCLUDE.set ("ADDINCLUDE");
77  m_FULLNAME.set ("FULLNAME");
78  m_DIRNAME.set ("DIRNAME");
79  m_OUTPUTNAME.set ("OUTPUTNAME");
80  m_ALLOS9SOURCES.set ("ALLOS9SOURCES");
81  m_NODEBUGUSELINKOPTS.set ("NODEBUGUSELINKOPTS");
82  m_DEBUGUSELINKOPTS.set ("DEBUGUSELINKOPTS");
83  m_USEINCLUDES.set ("USEINCLUDES");
84  m_HASTARGETTAG.set ("HASTARGETTAG");
85}
86
87//--------------------------------------------------
88void CmtGenerator::reset ()
89{
90  m_CONSTITUENT = "";
91  m_LINKMACRO = "";
92  m_DOCPATH = "";
93  m_PACKAGEPATH = "";
94  m_PACKAGEPREFIX = "";
95  m_PACKAGE = "";
96  m_VERSION = "";
97  m_MGRSTYLE = "";
98  m_TITLE = "";
99  m_GROUP = "";
100  m_CONSTITUENTSUFFIX = "";
101  m_LIBRARYSUFFIX = "";
102  m_USER = "";
103  m_DATE = "";
104  m_PROTOTARGET = "";
105  m_OBJS = "";
106  m_CLASSES = "";
107  m_PROTOSTAMPS = "";
108  m_NAME = "";
109  m_FILEPATH = "";
110  m_FILESUFFIX = "";
111  m_SUFFIX = "";
112  m_FILENAME = "";
113  m_LINE = "";
114  m_ADDINCLUDE = "";
115  m_FULLNAME = "";
116  m_OUTPUTNAME = "";
117  m_ALLOS9SOURCES = "";
118  m_NODEBUGUSELINKOPTS = "";
119  m_DEBUGUSELINKOPTS = "";
120  m_USEINCLUDES = "";
121  m_HASTARGETTAG = "";
122  m_PACKINCLUDES = "";
123  m_PACKOS9      = false;
124  m_GENERATOR    = "";
125
126  is_library     = false;
127  is_application = false;
128  srcdir       = "";
129  docdir       = "";
130  cmtdir       = "";
131  incdir       = "";
132  src          = "$(src)";
133  doc          = "$(doc)";
134  inc          = "$(inc)";
135  mgr          = "$(mgr)";
136  cmt          = "$(cmt)";
137  protos       = "";
138  protonames   = "";
139  os9sources   = "";
140
141  m_source_files.clear ();
142
143  Language::setup_all_fragments ();
144
145  CmtSystem::cd (Cmt::get_current_dir ());
146
147  cmt_string branch = CmtSystem::current_branch ();
148
149  if ((branch == "mgr") || (branch == "cmt"))
150    {
151      if (CmtSystem::test_directory ("../src"))
152        {
153          srcdir = "..";
154          srcdir += CmtSystem::file_separator ();
155          srcdir += "src";
156          srcdir += CmtSystem::file_separator ();
157        }
158      else
159        {
160          srcdir = "";
161        }
162
163      if (CmtSystem::test_directory ("../doc"))
164        {
165          docdir = "..";
166          docdir += CmtSystem::file_separator ();
167          docdir += "doc";
168          docdir += CmtSystem::file_separator ();
169        }
170      else
171        {
172          docdir = "";
173        }
174
175      if (CmtSystem::test_directory ("../cmt"))
176        {
177          cmtdir = "..";
178          cmtdir += CmtSystem::file_separator ();
179          cmtdir += "cmt";
180          cmtdir += CmtSystem::file_separator ();
181        }
182      else if (CmtSystem::test_directory ("../mgr"))
183        {
184          cmtdir = "..";
185          cmtdir += CmtSystem::file_separator ();
186          cmtdir += "mgr";
187          cmtdir += CmtSystem::file_separator ();
188        }
189      else
190        {
191          cmtdir = CmtSystem::pwd ();
192          cmtdir += CmtSystem::file_separator ();
193        }
194
195      if (CmtSystem::test_directory ("../src"))
196        {
197          incdir = "..";
198          incdir += CmtSystem::file_separator ();
199          incdir += "src";
200          incdir += CmtSystem::file_separator ();
201        }
202      else
203        {
204          incdir = "";
205        }
206    }
207  else
208    {
209      srcdir = ".";
210      srcdir += CmtSystem::file_separator ();
211      docdir = ".";
212      docdir += CmtSystem::file_separator ();
213      cmtdir = CmtSystem::pwd ();
214      cmtdir += CmtSystem::file_separator ();
215      incdir = ".";
216      incdir += CmtSystem::file_separator ();
217    }
218}
219
220//--------------------------------------------------
221bool CmtGenerator::prepare_output (const cmt_string& package,
222                                   const Constituent& constituent,
223                                   const cmt_string& file)
224{
225  m_PACKAGE = package;
226  m_CONSTITUENT = constituent.name;
227  m_CONSTITUENTSUFFIX = constituent.suffix;
228
229  m_PACKOS9 = constituent.need_OS9;
230
231  m_output_file_name = cmtdir + m_CONSTITUENT + ".";
232
233  if (Cmt::build_nmake ())
234    {
235      m_output_file_name += "nmake";
236    }
237  else
238    {
239      m_output_file_name += "make";
240    }
241 
242  if (file != "") m_output_file_name = file;
243
244  m_output_file_name += "new";
245
246
247  m_output_file = fopen (m_output_file_name.c_str (), "wb");
248  if (m_output_file != NULL)
249    {
250      return (true);
251    }
252  else
253    {
254      return (false);
255    }
256}
257
258//--------------------------------------------------
259void CmtGenerator::check (const cmt_string& name)
260{
261  static cmt_string old;
262  static cmt_string backup;
263
264  old = name;
265
266  int pos = old.find_last_of ("new");
267  old.erase (pos);
268
269  if (!CmtSystem::compare_files (old, name))
270    {
271      backup = old;
272      backup += "sav";
273
274      unlink (backup.c_str ());
275      rename (old.c_str (), backup.c_str ());
276      rename (name.c_str (), old.c_str ());
277    }
278  else
279    {
280      unlink (name);
281    }
282}
283
284//--------------------------------------------------
285void CmtGenerator::commit (const cmt_string& name)
286{
287  static cmt_string old;
288  static cmt_string backup;
289
290  old = name;
291
292  int pos = old.find_last_of ("new");
293  old.erase (pos);
294
295  if (CmtSystem::test_file (old))
296    {
297      backup = old;
298      backup += "sav";
299
300      unlink (backup.c_str ());
301      rename (old.c_str (), backup.c_str ());
302    }
303
304  rename (name.c_str (), old.c_str ());
305}
306
307//--------------------------------------------------
308void CmtGenerator::terminate ()
309{
310  fclose (m_output_file);
311
312  //--- Complete the operation --------------
313
314  commit (m_output_file_name);
315}
316
317//--------------------------------------------------
318void CmtGenerator::fill_outputs ()
319{
320  bool first = true;
321
322  m_OBJS = "";
323
324  for (int i = 0; i < m_source_files.size (); i++)
325    {
326      const SourceFile& file = m_source_files[i];
327      const cmt_string output = file.output ();
328
329      if (output != "")
330        {
331          if (first)
332            {
333              first = false;
334            }
335          else
336            {
337              m_OBJS += " ";
338            }
339
340          m_OBJS += output;
341        }
342
343      if (Cmt::get_debug ())
344        {
345          cout << "CmtGenerator::fill_outputs> output=" << output << " OBJS=" << m_OBJS << endl;
346        }
347
348    }
349
350  if (Cmt::get_debug ())
351    {
352      cout << "CmtGenerator::fill_outputs> OBJS=" << m_OBJS << endl;
353    }
354
355}
356
357//--------------------------------------------------
358void CmtGenerator::prepare_use_context ()
359{
360  cmt_string path;
361  cmt_string substitution;
362
363  Use* use = &Use::current ();
364
365  m_deps_builder.clear ();
366
367  if (use->include_path != "none")
368    {
369      if (use->include_path == "")
370        {
371          m_deps_builder.add (incdir, "$(src)");
372        }
373      else
374        {
375          substitution = use->include_path;
376         
377          path = substitution;
378          Symbol::expand (path);
379         
380          CmtSystem::reduce_file_separators (path);
381
382          m_deps_builder.add (path, substitution);
383        }
384    }
385
386  m_deps_builder.add_includes (*use);
387
388  Use::UsePtrVector& uses = Use::get_ordered_uses ();
389
390  if (uses.size () > 0)
391    {
392      int number;
393
394      for (number = 0; number < uses.size (); number++)
395        {
396          use = uses[number];
397          if (use->discarded) continue;
398
399          if (use->real_path != "")
400            {
401              if (use->include_path != "none")
402                {
403                  if (use->include_path == "")
404                    {
405                      use->get_full_path (path);
406                      path += CmtSystem::file_separator ();
407                      path += "src";
408
409                      substitution = "$(";
410                      substitution += use->prefix;
411                      substitution += "ROOT)";
412                      substitution += CmtSystem::file_separator ();
413                      substitution += "src";
414                      substitution += CmtSystem::file_separator ();
415                    }
416                  else
417                    {
418                      substitution = use->include_path;
419
420                      path = substitution;
421                      Symbol::expand (path);
422
423                      CmtSystem::reduce_file_separators (path);
424                    }
425
426                  m_deps_builder.add (path, substitution);
427                }
428
429              m_deps_builder.add_includes (*use);
430            }
431        }
432    }
433}
434
435//--------------------------------------------------
436void CmtGenerator::filter_path (cmt_string& text)
437{
438  CmtSystem::compress_path (text);
439
440  text.replace_all ("./../src/../", "../");
441  text.replace_all ("./../src/", "$(src)");
442
443  text.replace_all (".\\..\\src\\..\\", "..\\");
444  text.replace_all (".\\..\\src\\", "$(src)");
445
446  text.replace_all ("../src/../", "../");
447  text.replace_all ("../src/", "$(src)");
448
449  text.replace_all ("..\\src\\..\\", "..\\");
450  text.replace_all ("..\\src\\", "$(src)");
451
452  text.replace_all ("../doc/../", "../");
453  text.replace_all ("../doc/", "$(doc)");
454
455  text.replace_all ("..\\doc\\..\\", "..\\");
456  text.replace_all ("..\\doc\\", "$(doc)");
457
458  text.replace_all ("$(src)$(src)", "$(src)");
459}
460
461/**
462   Scan a complete file spec (with possibly wild cards and directory)
463   given in full_name ad fill in a vector of found file names.
464
465   Result of the scan is filtered against matching suffixes
466
467   Returns the count of non empty file names really found.
468
469*/
470int CmtGenerator::get_all_files (const cmt_string& full_name,
471                                 const cmt_vector<cmt_regexp>& exclude_exprs,
472                                 const cmt_vector<cmt_regexp>& select_exprs,
473                                 CmtSystem::cmt_string_vector& files)
474{
475  static cmt_string suffix;
476  static cmt_string name;
477
478  bool has_excludes = false;
479  bool has_selects = false;
480
481  suffix = "";
482  name = "";
483
484  files.clear ();
485
486  has_excludes = (exclude_exprs.size () > 0);
487  has_selects = (select_exprs.size () > 0);
488
489  CmtSystem::get_dot_suffix (full_name, suffix);
490
491  bool wilcarded_suffix = false;
492
493  if (suffix == ".*") wilcarded_suffix = true;
494
495  int count = 0;
496
497  if (full_name.find ('*') != cmt_string::npos)
498    {
499      CmtSystem::scan_dir (full_name, files);
500
501      if (Cmt::get_debug ())
502        {
503          cout << "CMT::get_all_files> full_name=" << full_name <<
504            " pwd=" << CmtSystem::pwd () << endl;
505          cout << "CMT::get_all_files> files.size=" <<  files.size () << endl;
506        }
507
508      /**
509
510      We have to treat patterns of the form *.xxx (ie with a
511      suffix) thus we filter out everything that could have been
512      collected with a different suffix because the
513      CmtSystem::scan_dir function only handles patterns of the
514      form xxx* (ie with trailing *)
515
516      [If the original suffix was empty (ie files specified using
517      xx*) this means getting files without any dot-suffix. This
518      may be incorrect??]
519
520      */
521
522      for (int j = 0; j < files.size (); j++)
523        {
524          cmt_string& n = files[j];
525
526          bool rejected = false;
527
528          if (n == "")
529            {
530              rejected = true;
531            }
532
533          if (!rejected && has_selects)
534            {
535              rejected = true;
536
537              for (int k = 0; k < select_exprs.size (); k++)
538                {
539                  const cmt_regexp& exp = select_exprs[k];
540                  if (exp.match (n))
541                    {
542                      rejected = false;
543                      break;
544                    }
545                }
546            }
547
548          if (!rejected && has_excludes)
549            {
550              for (int k = 0; k < exclude_exprs.size (); k++)
551                {
552                  const cmt_regexp& exp = exclude_exprs[k];
553                  if (exp.match (n))
554                    {
555                      rejected = true;
556                      break;
557                    }
558                }
559            }
560
561          if (!rejected)
562            {
563              static cmt_string s;
564
565              CmtSystem::get_dot_suffix (n, s);
566              if (!wilcarded_suffix && (s != suffix)) 
567                {
568                  rejected = true;
569                }
570              else
571                {
572                  count++;
573                }
574            }
575
576          if (Cmt::get_debug ())
577            {
578              if (rejected)
579                {
580                  cout << "CMT::get_all_files> reject " <<  n << endl;
581                }
582              else
583                {
584                  cout << "CMT::get_all_files> keep " <<  n << endl;
585                }
586            }
587
588          if (rejected)
589            {
590              n = "";
591            }
592        }
593    }
594  else
595    {
596      if (full_name != "")
597        {
598          bool rejected = false;
599
600          if (has_excludes)
601            {
602              for (int k = 0; k < exclude_exprs.size (); k++)
603                {
604                  const cmt_regexp& exp = exclude_exprs[k];
605                  if (exp.match (full_name))
606                    {
607                      rejected = true;
608                      break;
609                    }
610                }
611            }
612
613          if (!rejected)
614            {
615              cmt_string& n = files.add ();
616
617              n = full_name;
618
619              count++;
620            }
621        }
622    }
623
624  return (count);
625}
626
627//--------------------------------------------------
628void CmtGenerator::set_full_name (cmt_string& full_name, cmt_string& file)
629{
630  full_name = "";
631
632  Symbol::expand (file);
633
634  if (file == "") return;
635 
636  if (!CmtSystem::absolute_path (file))
637    {
638      full_name = srcdir;
639      if (full_name != "") full_name += CmtSystem::file_separator ();
640    }
641 
642  full_name += file;
643
644  CmtSystem::reduce_file_separators (full_name);
645}
646
647//------------------------------------------------------------------------
648static ApplicationGenerator ApplicationContext;
649static LibraryGenerator LibraryContext;
650static DocumentGenerator DocumentContext;
651static ReadmeGenerator ReadmeContext;
652static PrototypeGenerator PrototypeContext;
653static DefaultMakefileGenerator DefaultMakefileContext;
654static MSDEVGenerator MSDEVContext;
655static VSNETGenerator VSNETContext;
656static MakeSetupGenerator MakeSetupContext;
657static ConstituentsMakefileGenerator ConstituentsMakefileContext;
658static DependencyGenerator DependencyContext;
659
660//--------------------------------------------------
661int Generator::build_msdev_workspace (const Constituent::ConstituentVector& constituents)
662{
663  return (MSDEVContext.build_workspace (constituents));
664}
665
666//--------------------------------------------------
667int Generator::build_msdev (const Constituent& constituent)
668{
669  return (MSDEVContext.build_project (constituent));
670}
671
672//--------------------------------------------------
673int Generator::build_vsnet_workspace (const Constituent::ConstituentVector& constituents)
674{
675  return (VSNETContext.build_workspace (constituents));
676}
677
678//--------------------------------------------------   
679int Generator::build_vsnet (const Constituent& constituent)
680{
681  return (VSNETContext.build_project (constituent));
682}
683
684//--------------------------------------------------
685void Generator::build_make_setup (const cmt_string& package)
686{
687  MakeSetupContext.build (package);
688}
689
690//--------------------------------------------------
691void Generator::build_constituents_makefile (const cmt_string& package,
692                                             const CmtSystem::cmt_string_vector& arguments)
693{
694  ConstituentsMakefileContext.build (package, arguments);
695}
696
697//--------------------------------------------------
698int Generator::build_constituent_makefile (const Constituent& constituent,
699                                           const cmt_string& file)
700{
701  const cmt_string& package = Cmt::get_current_package ();
702
703  switch (constituent.type)
704    {
705    case Application:
706      ApplicationContext.build (package, constituent, file);
707      break;
708    case Library:
709      LibraryContext.build (package, constituent, file);
710      break;
711    case Document:
712      DocumentContext.build (package, constituent, file);
713      break;
714    }
715
716  return (0);
717}
718
719//--------------------------------------------------
720void Generator::build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments)
721{
722  cmt_string name;
723  cmt_string file;
724
725  if (arguments.size () == 1)
726    {
727      file = "";
728      name = arguments[0];
729    }
730  else if (arguments.size () == 2) // arguments[0].substr (0, 5) == "-out="
731    {
732      cmt_string arg = arguments[0];
733      arg.erase (0, 5);
734      file = arg;
735      name = arguments[1];
736    }
737  else
738    {
739      CmtMessage::error ("build constituent_makefile : wrong arguments");
740      //      cerr << "#CMT> build constituent_makefile : wrong arguments" << endl;
741      return;
742    }
743
744  const Constituent* constituent = Constituent::find (name);
745  if (constituent != 0) build_constituent_makefile (*constituent, file);
746}
747
748//--------------------------------------------------
749void Generator::build_default_makefile ()
750{
751  DefaultMakefileContext.build ();
752}
753
754//--------------------------------------------------
755void Generator::build_dependencies (const CmtSystem::cmt_string_vector& arguments)
756{
757  DependencyContext.build (arguments);
758}
759
760//--------------------------------------------------
761void Generator::build_prototype (const cmt_string& file_name)
762{
763  PrototypeContext.build (file_name);
764}
765
766//--------------------------------------------------
767void Generator::build_readme (const CmtSystem::cmt_string_vector& arguments)
768{
769  ReadmeContext.build (arguments);
770}
771
772class WinDefAwk : public PAwk
773{
774public :
775  WinDefAwk (const cmt_string& library_name)
776  {
777    m_name = library_name;
778  }
779
780  void begin ()
781  {
782    cout << "LIBRARY " << m_name << endl;
783    cout << "EXPORTS" << endl;
784  }
785
786  void filter (const cmt_string& line)
787  {
788    if (line.find ("External") == cmt_string::npos) return;
789    if (line.find ("??_") != cmt_string::npos)
790      {
791        if (line.find ("operator/=") == cmt_string::npos) return;
792        // Keep operator /= .
793      }
794
795    CmtSystem::cmt_string_vector words;
796    CmtSystem::split (line, " \t", words);
797    if (words.size () >= 7)
798      {
799        int pos = 7;
800
801        cmt_string& fifth_word = words[4];
802        if (fifth_word == "()") pos = 7;
803        else if (fifth_word == "External") pos = 6;
804        else return;
805
806        cmt_string& symbol = words[pos];
807        if (symbol[0] == '_') symbol.erase (0, 1);
808        symbol.replace_all ("\r", "");
809        symbol.replace_all ("\n", "");
810
811        if ((pos == 6) && 
812            ((line.find(": static") != cmt_string::npos) ||
813             (line.find("(class") != cmt_string::npos)) )
814          {
815            // static data members are not DATA :
816            // extern objects are not DATA :
817            cout << " " << symbol << " " << endl;
818          } 
819        else if (pos == 6)
820          {
821            // DATA :
822            cout << " " << symbol << "\tDATA" << endl;
823          } 
824        else
825          {
826            // code :
827            cout << " " << symbol << " " << endl;
828          } 
829      }
830  }
831
832  void end ()
833  {
834  }
835
836private:
837  cmt_string m_name;
838};
839
840//--------------------------------------------------
841//void Generator::build_windefs (const cmt_string& library_name)
842void Generator::build_windefs (const CmtSystem::cmt_string_vector& arguments)
843{
844  cmt_string name;
845  //  CmtSystem::cmt_string_vector files;
846  cmt_string files;
847
848  for (int i = 0; i < arguments.size (); i++)
849    {
850      const cmt_string& w = arguments[i];
851      if (w.substr (0, 6) == "-name=" || w.substr (0, 6) == "-name:" ||
852          w.substr (0, 6) == "/name:" || w.substr (0, 6) == "/name=")
853        w.substr (6, name);
854      else if (w.substr (0, 1) == "@" && w.size () > 1)
855        {
856          cmt_string commandfile;
857          w.substr (1, commandfile);
858          if (!CmtSystem::test_file (commandfile))
859            {
860              CmtMessage::warning ("No such file `" + commandfile + "'.");
861              continue;
862            }
863          cmt_string text;
864          if (!text.read (commandfile))
865            {
866              CmtMessage::warning ("Could not read `" + commandfile + "'.");
867              continue;
868            }
869          text.replace_all ("\r", " ");
870          text.replace_all ("\n", " ");
871          files += " " + text;
872          /*
873          CmtSystem::cmt_string_vector words;
874          CmtSystem::split (text, " \t", words);
875          for (int i = 0; i < words.size (); i++)
876            {
877              files.push_back (words[i]);
878            }
879          */
880        }
881      else
882        files += " " + w;
883      //        files.push_back (w);
884    }
885
886  if (files.size () == 0)
887    {
888      CmtMessage::error ("build_windefs: no files specified");
889      return;
890    }
891  if (name == "")
892    {
893      CmtSystem::cmt_string_vector words;
894      CmtSystem::split (files, " \t", words);
895      if (words.size () == 0)
896        {
897          CmtMessage::error ("build_windefs: no files specified");
898          return;
899        }
900      cmt_string suffix;
901      CmtSystem::get_dot_suffix (words[0], suffix);
902      CmtSystem::basename (words[0], suffix, name);
903    }
904  if (name == "")
905    {
906      CmtMessage::error ("build_windefs: cannot determine library name");
907      return;
908    }
909
910  //  cmt_string bin;
911
912  //  CmtSystem::dirname (library_name, bin);
913  //  CmtSystem::get_dot_suffix (library_name, suffix);
914  //  CmtSystem::basename (library_name, suffix, name);
915 
916  //  if (!CmtSystem::cd (bin)) return;
917 
918  //  cmt_string command;
919 
920  cmt_string command ("dumpbin /symbols");
921  //  command += library_name;
922  /*
923  for (int i = 0; i < files.size (); i++)
924    {
925      command += " " + files[i];
926    }
927  */
928  command += " " + files;
929       
930  WinDefAwk filter (name);
931 
932  filter.run (command, "SECT");
933}
934
935//--------------------------------------------------
936void Packager::begin ()
937{
938  m_package_name = "";
939}
940
941void Packager::filter (const cmt_string& line)
942{
943  CmtSystem::cmt_string_vector words;
944
945  CmtSystem::split (line, " ", words);
946  if (words.size () > 1)
947    {
948      cmt_string& w = words[0];
949
950      if (w == "package")
951        {
952          m_package_name = words[1];
953
954          int pos = m_package_name.find (";");
955          if (pos != cmt_string::npos) m_package_name.erase (pos);
956          m_package_name.replace_all (".", CmtSystem::file_separator ());
957        }
958    }
959}
960
961cmt_string& Packager::package_name ()
962{
963  return (m_package_name);
964}
965
Note: See TracBrowser for help on using the repository browser.