? |
Definition at line 2574 of file cmt_generators.cxx.
References add_line_to_text(), DependencyFilter::add_source(), Cmt::build_nmake(), cmt_string::c_str(), CmtSystem::compress_path(), Use::current(), CmtSystem::current_branch(), Constituent::exclude_exprs, Symbol::expand(), CmtSystem::file_separator(), cmt_string::find(), Constituent::find(), CmtGenerator::get_all_files(), Use::get_package(), CmtSystem::getenv(), DependencyFilter::has_source(), Package::is_cmt(), Constituent::modules, cmt_string::npos, CmtGenerator::prepare_use_context(), cmt_string::read(), CmtGenerator::reset(), Awk::run(), Constituent::select_exprs, CmtGenerator::set_full_name(), cmt_vector< cmt_string >::size(), and cmt_string::write().
Referenced by Generator::build_dependencies().
02575 {
02576 reset ();
02577 prepare_use_context ();
02578
02579 const Constituent* constituent_ptr = Constituent::find (name);
02580 if (constituent_ptr == 0)
02581 {
02582
02583 return;
02584 }
02585
02586 const Constituent& constituent = *constituent_ptr;
02587
02588 cmt_string file_name;
02589 cmt_string full_name;
02590 cmt_string compressed_name;
02591 cmt_string suffix;
02592 cmt_string dependencies;
02593
02594 cmt_string branch = CmtSystem::current_branch ();
02595
02596 if ((branch == "mgr") || (branch == "cmt"))
02597 {
02598 Use& current_use = Use::current ();
02599
02600 Package* p = current_use.get_package ();
02601
02602 if (p->is_cmt ())
02603 {
02604 m_output_file_name = "../";
02605 m_output_file_name += CmtSystem::getenv ("CMTBIN");
02606 m_output_file_name += CmtSystem::file_separator ();
02607 }
02608 else
02609 {
02610 m_output_file_name = "${bin}";
02611 }
02612
02613 Symbol::expand (m_output_file_name);
02614
02615
02616
02617 }
02618
02619 m_output_file_name += name;
02620 m_output_file_name += "_";
02621 m_output_file_name += "dependencies.";
02622 if (Cmt::build_nmake ())
02623 {
02624 m_output_file_name += "nmake";
02625 }
02626 else
02627 {
02628 m_output_file_name += "make";
02629 }
02630
02631 static DependencyFilter filter;
02632
02633 dependencies.read (m_output_file_name);
02634
02635 filter.run (dependencies);
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650 const CmtSystem::cmt_string_vector& sources = constituent.modules;
02651 const cmt_vector& excludes = constituent.exclude_exprs;
02652 const cmt_vector& selects = constituent.select_exprs;
02653
02654 bool all_sources = false;
02655
02656 int source_number = argc;
02657 int i;
02658
02659 for (i = argc-1; i >= 0; i--)
02660 {
02661 file_name = argv[i];
02662
02663
02664 if (file_name.find ("requirements") != cmt_string::npos) source_number--;
02665 else if (file_name.find (".make") != cmt_string::npos) source_number--;
02666 else if (file_name == "-all_sources")
02667 {
02668 source_number = sources.size ();
02669 all_sources = true;
02670 }
02671 }
02672
02673
02674 if (all_sources)
02675 {
02676 for (i = 0; i < sources.size (); i++)
02677 {
02678 file_name = sources[i];
02679
02680 set_full_name (full_name, file_name);
02681 if (full_name == "") continue;
02682
02683 CmtSystem::compress_path (full_name, compressed_name);
02684 full_name = compressed_name;
02685
02686 static CmtSystem::cmt_string_vector files;
02687
02688 get_all_files (full_name, excludes, selects, files);
02689
02690 for (int j = 0; j < files.size (); j++)
02691 {
02692 const cmt_string& name = files[j];
02693
02694 if (name != "")
02695 {
02696 const cmt_string& line = build (name);
02697
02698
02699
02700 add_line_to_text (line, dependencies);
02701 }
02702 }
02703 }
02704 }
02705 else
02706 {
02707 for (i = 0; i < source_number; i++)
02708 {
02709 file_name = argv[i];
02710
02711 set_full_name (full_name, file_name);
02712 if (full_name == "") continue;
02713
02714 CmtSystem::compress_path (full_name, compressed_name);
02715 full_name = compressed_name;
02716
02717 const cmt_string& line = build (full_name);
02718
02719
02720
02721 add_line_to_text (line, dependencies);
02722
02723
02724 filter.add_source (full_name);
02725
02726 }
02727
02728
02729
02730
02731
02732 for (i = 0; i < sources.size (); i++)
02733 {
02734 file_name = sources[i];
02735
02736 set_full_name (full_name, file_name);
02737 if (full_name == "") continue;
02738
02739 CmtSystem::compress_path (full_name, compressed_name);
02740 full_name = compressed_name;
02741
02742 static CmtSystem::cmt_string_vector files;
02743
02744 get_all_files (full_name, excludes, selects, files);
02745
02746 for (int j = 0; j < files.size (); j++)
02747 {
02748 const cmt_string& name = files[j];
02749
02750 if (name != "")
02751 {
02752 if (!filter.has_source (name))
02753 {
02754 const cmt_string& line = build (name);
02755
02756
02757
02758 add_line_to_text (line, dependencies);
02759 }
02760 }
02761 }
02762 }
02763 }
02764
02765 FILE* f = fopen (m_output_file_name.c_str (), "wb");
02766
02767 if (f == 0)
02768 {
02769 cerr << "Cannot open " << m_output_file_name << " for write" << endl;
02770 }
02771 else
02772 {
02773 dependencies.write (f);
02774 fclose (f);
02775 }
02776 }
|