? |
Definition at line 821 of file cmt_generators.cxx.
References analyze_document_file(), CmtSystem::basename(), cmt_string::c_str(), AnyDocumentGenerator::cleanup_header_fragment, CmtSystem::compress_path(), FragmentHandle::copy(), AnyDocumentGenerator::dependencies_fragment, CmtSystem::dirname(), document_header_fragment, Constituent::exclude_exprs, CmtSystem::file_separator(), CmtGenerator::fill_outputs(), CmtGenerator::filter_path(), Constituent::generator, CmtGenerator::get_all_files(), CmtSystem::get_dot_suffix(), CmtSystem::get_suffix(), Constituent::has_target_tag, FragmentHandle::header(), Constituent::includes, CmtGenerator::is_application, CmtGenerator::is_library, CmtGenerator::m_CONSTITUENT, CmtGenerator::m_CONSTITUENTSUFFIX, CmtGenerator::m_DATE, CmtGenerator::m_FILENAME, CmtGenerator::m_FILEPATH, CmtGenerator::m_FILESUFFIX, CmtGenerator::m_FULLNAME, CmtGenerator::m_GENERATOR, CmtGenerator::m_HASTARGETTAG, CmtGenerator::m_LINE, CmtGenerator::m_NAME, CmtGenerator::m_OBJS, CmtGenerator::m_output_file, CmtGenerator::m_PACKAGE, CmtGenerator::m_PACKINCLUDES, CmtGenerator::m_source_files, CmtGenerator::m_SUFFIX, AnyDocumentGenerator::m_TITLE, CmtGenerator::m_USER, AnyDocumentGenerator::make_header_fragment, Constituent::modules, SourceFile::name(), Constituent::name, FragmentHandle::name(), FragmentHandle::need_dependencies(), CmtSystem::now(), CmtGenerator::prepare_output(), CmtGenerator::prepare_use_context(), reset(), Constituent::select_exprs, CmtGenerator::set_full_name(), cmt_vector< SourceFile >::size(), cmt_vector< cmt_string >::size(), FragmentHandle::suffix(), CmtGenerator::terminate(), CmtSystem::test_directory(), CmtSystem::test_file(), FragmentHandle::trailer(), CmtSystem::user(), Variable::value, and Constituent::variables.
Referenced by Generator::build_constituent_makefile().
00823 {
00824 static cmt_string names;
00825 static cmt_string output_dir;
00826 static cmt_string name;
00827 static cmt_string full_name;
00828 static cmt_string compressed_name;
00829 static cmt_string suffix;
00830 static cmt_string output_suffix;
00831 static cmt_string fragment_suffix;
00832
00833 reset ();
00834
00835 if (!prepare_output (package, constituent)) return;
00836
00837 is_library = false;
00838 is_application = false;
00839 m_GENERATOR = constituent.generator;
00840 m_TITLE = "Document";
00841
00842 int i;
00843
00844 cout << m_TITLE << " " << m_CONSTITUENT << endl;
00845
00846
00847
00848
00849
00850 const CmtSystem::cmt_string_vector& includes = constituent.includes;
00851
00852 for (i = 0; i < includes.size (); i++)
00853 {
00854 const cmt_string& subdir = includes[i];
00855
00856 m_PACKINCLUDES += " -I";
00857 m_PACKINCLUDES += subdir;
00858 }
00859
00860
00861
00862
00863
00864 FragmentHandle fragment (m_GENERATOR);
00865
00866 fragment_suffix = fragment.suffix ();
00867
00868 output_suffix = ".";
00869
00870 if (fragment_suffix == "")
00871 {
00872 output_suffix += fragment.name ();
00873 }
00874 else
00875 {
00876 output_suffix += fragment_suffix;
00877 }
00878
00879
00880
00881
00882
00883 const CmtSystem::cmt_string_vector& sources = constituent.modules;
00884 const cmt_vector& excludes = constituent.exclude_exprs;
00885 const cmt_vector& selects = constituent.select_exprs;
00886
00887 m_LINE = "";
00888
00889 for (i = 0; i < sources.size (); i++)
00890 {
00891 cmt_string& file = sources[i];
00892
00893 set_full_name (full_name, file);
00894 if (full_name == "") continue;
00895
00896 CmtSystem::compress_path (full_name, compressed_name);
00897 full_name = compressed_name;
00898
00899 static CmtSystem::cmt_string_vector files;
00900
00901 int count = get_all_files (full_name, excludes, selects, files);
00902
00903 filter_path (full_name);
00904
00905 if (count > 0)
00906 {
00907 m_LINE += full_name;
00908 m_LINE += " ";
00909 }
00910
00911 for (int j = 0; j < files.size (); j++)
00912 {
00913 const cmt_string& name = files[j];
00914
00915 if (name != "")
00916 {
00917 analyze_document_file (name, constituent.name, output_suffix);
00918 }
00919 }
00920 }
00921
00922 fill_outputs ();
00923
00924 prepare_use_context ();
00925
00926 m_DATE = CmtSystem::now ();
00927 m_USER = CmtSystem::user ();
00928 m_PACKAGE = package;
00929
00930 if (constituent.has_target_tag)
00931 {
00932 m_HASTARGETTAG = "has_target_tag";
00933 }
00934 else
00935 {
00936 m_HASTARGETTAG = "has_no_target_tag";
00937 }
00938
00939 make_header_fragment.copy (m_output_file, constituent.variables, 7,
00940 &m_TITLE,
00941 &m_CONSTITUENT,
00942 &m_CONSTITUENTSUFFIX,
00943 &m_USER,
00944 &m_DATE,
00945 &m_PACKAGE,
00946 &m_HASTARGETTAG);
00947
00948 const cmt_string& header = fragment.header ();
00949
00950
00951
00952
00953
00954 if (header != "")
00955 {
00956 FragmentHandle header_fragment (header);
00957 header_fragment.copy (m_output_file, constituent.variables, 3,
00958 &m_CONSTITUENT,
00959 &m_CONSTITUENTSUFFIX,
00960 &m_OBJS);
00961 }
00962 else
00963 {
00964 document_header_fragment.copy (m_output_file, constituent.variables, 3,
00965 &m_CONSTITUENT,
00966 &m_CONSTITUENTSUFFIX,
00967 &m_OBJS);
00968 }
00969
00970 if (fragment.need_dependencies ())
00971 {
00972 dependencies_fragment.copy (m_output_file, constituent.variables, 3,
00973 &m_CONSTITUENT,
00974 &m_CONSTITUENTSUFFIX,
00975 &m_LINE);
00976 }
00977 else
00978 {
00979 for (i = 0; i < sources.size (); i++)
00980 {
00981 cmt_string& file = sources[i];
00982
00983 set_full_name (full_name, file);
00984 if (full_name == "") continue;
00985
00986 CmtSystem::compress_path (full_name, compressed_name);
00987 full_name = compressed_name;
00988
00989 static CmtSystem::cmt_string_vector files;
00990
00991 get_all_files (full_name, excludes, selects, files);
00992
00993 for (int j = 0; j < files.size (); j++)
00994 {
00995 const cmt_string& name = files[j];
00996
00997 if (name != "")
00998 {
00999 static cmt_string s;
01000 static cmt_string n;
01001
01002 CmtSystem::get_dot_suffix (name, s);
01003 CmtSystem::basename (name, s, n);
01004 CmtSystem::get_suffix (name, s);
01005
01006 fprintf (m_output_file, "%s_%s_dependencies = %s\n",
01007 n.c_str (),
01008 s.c_str (),
01009 name.c_str ());
01010 }
01011 }
01012 }
01013 }
01014
01015 m_SUFFIX = fragment_suffix;
01016 for (i = 0; i < m_source_files.size (); i++)
01017 {
01018 SourceFile& file = m_source_files[i];
01019 const cmt_string& file_name = file.name ();
01020 m_FULLNAME = file_name;
01021 CmtSystem::get_dot_suffix (file_name, suffix);
01022 CmtSystem::basename (file_name, suffix, m_NAME.value);
01023 CmtSystem::dirname (file_name, m_FILEPATH.value);
01024 if (m_FILEPATH.value != "") m_FILEPATH.value += CmtSystem::file_separator ();
01025 filter_path (m_FILEPATH.value);
01026 CmtSystem::basename (file_name, m_FILENAME.value);
01027 CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value);
01028
01029 if (!CmtSystem::test_file (file_name) && !CmtSystem::test_directory (file_name))
01030 {
01031 cout << "#CMT> Warning : Source file " << file_name << " not found" << endl;
01032 }
01033
01034 filter_path (m_FULLNAME.value);
01035
01036 fragment.copy (m_output_file, constituent.variables, 8,
01037 &m_FILEPATH,
01038 &m_SUFFIX,
01039 &m_CONSTITUENT,
01040 &m_CONSTITUENTSUFFIX,
01041 &m_FILENAME,
01042 &m_NAME,
01043 &m_FULLNAME,
01044 &m_FILESUFFIX);
01045 }
01046
01047 const cmt_string& trailer = fragment.trailer ();
01048 if (trailer != "")
01049 {
01050 FragmentHandle trailer_fragment (trailer);
01051 trailer_fragment.copy (m_output_file, constituent.variables, 3,
01052 &m_CONSTITUENT,
01053 &m_CONSTITUENTSUFFIX,
01054 &m_OBJS);
01055 }
01056
01057
01058
01059
01060
01061 cleanup_header_fragment.copy (m_output_file, constituent.variables, 2,
01062 &m_CONSTITUENT,
01063 &m_CONSTITUENTSUFFIX);
01064
01065 terminate ();
01066 }
|