Changeset 588
- Timestamp:
- Nov 27, 2011, 4:36:15 PM (12 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 4 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r586 r588 1 2011-11-27 <rybkin@lal.in2p3.fr> 465 2 3 * source/cmt_system.cxx: In function CmtSystem::remove_file, do not use 4 custom error message 5 * source/cmt_symbol.h: In class Symbol, add const qualifier to 6 check_tag_used function argument, to resolve_macro_value function 7 * source/cmt_symbol.cxx: idem, add same actions for 8 action_build_broadcast_config as for action_build_constituents_config, 9 action_build_constituent_config 10 * source/cmt_use.h: In class Use, introduce absolute_library_path, 11 remove_library_links functions 12 * source/cmt_use.cxx: Implement introduced functions, in install_library 13 helper function, check return value of called functions, set error (rather 14 than print error message) as appropriate, implement uninstall_library 15 helper function, refactor build_library_links function to use 16 absolute_library_path 17 * source/cmt_deps_builder.h: Make m_filter member of class 18 DepsBuilder::HeaderFilter to be owned by class and cleared accordingly 19 * source/cmt_deps_builder.cxx: In header_file_action, build_deps functions 20 check return value of read function, set error as appropriate, also set 21 error if path specified for dependencies calculation not found. In class 22 DepsBuilder, run function, pass $(app_$(CONSTITUENT)_cppflags), 23 $(lib_$(CONSTITUENT)_cppflags) to external dependencies generator specified 24 via preprocessor_command macro, if any 25 * source/cmt_generators.h: In classes DocumentGenerator, LibraryGenerator, 26 in function build, introduce argument bool& dependencies, in class 27 DocumentGenerator, introduce members Variable m_FILEEXTENSION, 28 FragmentHandle dependency_fragment, in class LibraryGenerator, declare 29 specific function fill_names_outputs. Introduce class 30 PackagesMakefileGenerator, rewrite class DependencyGenerator 31 * source/cmt_generators.cxx: In class LibraryGenerator, implement 32 fill_names_outputs, in class DocumentGenerator function build, add 33 dependency_fragment for each source file with additional template 34 FILEEXTENSION (also added for fragment) so that 35 ${CONSTITUENT}_dependencies.make gets rebuilt whenever source file OR its 36 dependencies change. Implement class PackagesMakefileGenerator used to 37 build BCAST mode Makefile. In class DependencyGenerator, re-implement 38 function build (const CmtSystem::cmt_string_vector&) so that it makes use 39 of files and includes from CLI input, if any, enhance its algorithm, 40 enhance function prepare_header_file_filters so that it makes use of input 41 file dependencies[_CONSTITUENT].in without CMT 42 * source/cmt_generator.h: In class CmtGenerator, remove prepare_use_context 43 function, m_deps_builder member. In class Generator, introduce argument 44 bool& dependencies in build_constituent_makefile function, declare 45 build_library_links_infile, build_dependencies_infile, 46 build_packages_makefile functions 47 * source/cmt_generator.cxx: In class CmtGenerator function reset, reset 48 m_bin, m_output_file_name, m_output_file, m_constituent members, in class 49 Generator, implement build_library_links_infile, build_dependencies_infile, 50 build_packages_makefile functions, in class InGenerator constructor, add 51 document dependency fragment 52 * source/cmt_constituent.h: In class Constituent, change add_for_action 53 function signature 54 * source/cmt_constituent.cxx: In class Constituent, in function parse, 55 do not treat action_value variable definition specially, in function 56 add_for_action, do not assign target_<name> tag to document corresponding 57 to action by default but only if this tag is used somewhere 58 * source/cmt_commands.cxx: In class ArgParser, in function do_build, 59 introduce broadcast_config command and its options processing, enhance 60 dependencies command options processing so that it makes use of files and 61 includes from CLI input and can have global options specified mixed with 62 its options. In class CommandHelp, in constructor, add help info for 63 broadcast_config, dependencies commands 64 * source/cmt_parser.h: In enumeration ActionType, add value 65 action_build_broadcast_config 66 * source/cmt_parser.cxx: In class Cmt, in function do_broadcast, unset 67 CMTBCAST variable in environment of command(s) being broadcast to avoid 68 looping, in function do_build_constituent_config, generate dependencies 69 infile if needed only, incorporate call to do_check_configuration into 70 function do_build_constituents_config so as not to invoke 71 cmt check configuration command in Makefile, as part of 72 do_build_constituents_config, generate library_links infile, and 73 dependencies infile for constituents without target tag, implement function 74 do_build_broadcast_config to generate broadcast Makefile, and broadcast 75 specific macros Makefile, enhance do_build_library_links function to work 76 with generated library_links infile, make function do_check_configuration 77 set error if non-constant cmtpath_pattern found for package outside CMTPATH 78 - cannot be applied, re-implement do_remove_library_links function making 79 use of remove_library_links from class Use. In function 80 fill_for_all_constituents of class StandardMacroBuilder, print warning 81 message if package requested for import cannot be imported for constituent 82 without target tag during cmt build constituents_config, otherwise during 83 cmt build constituent_config 84 * source/cmt_cmtpath_pattern.h: In class CmtPathPattern, introduce function 85 is_constant 86 * source/cmt_cmtpath_pattern.cxx: Implement is_constant function 87 * source/cmt.h: In class Cmt, introduce function do_build_broadcast_config 88 * mgr/fragments/package: Introduce fragment for broadcast Makefile 89 generation 90 * mgr/fragments/packages_header: idem 91 * mgr/fragments/packages_trailer: idem 92 * mgr/fragments/dependency: Introduce fragment for document Makefile 93 generation 94 * mgr/fragments/dependencies: Use $(build_dependencies) command with 95 dependencies infile and include directories and source files supplied 96 via CLI 97 * mgr/fragments/constituent: In QUICK mode, rebuild constituent Makefile if 98 any requirements file changes. Make constituent uninstall targets 99 independent of constituent Makefile (so that no rebuild happens before 100 uninstall), make remove_library_links dependent on constituent uninstall 101 targets to ensure library links uninstallation order 102 * mgr/fragments/constituent_lock: idem 103 * mgr/fragments/constituents_header: In QUICK mode, run 104 $(build_library_links) command with library_links infile, if any 105 requirements file changes, keep .DEFAULT target if PEDANTIC is undefined, 106 specify explicit (with empty command) rules for requirements files for 107 optimisation 108 * mgr/fragments/constituents_trailer: In QUICK mode, run 109 $(remove_library_links) command with library_links infile, make uninstall 110 target (rather than clean target) dependent on remove_library_links target 111 to ensure library links uninstallation 112 * mgr/fragments/make_header: Define dependencies infile for use with 113 $(build_dependencies) command 114 * mgr/fragments/cpp: Add explicit dependency on source file to 115 ${CONSTITUENT}_dependencies.make 116 * mgr/fragments/cpp_library: idem 117 * mgr/fragments/c: idem 118 * mgr/fragments/c_library: idem 119 * mgr/fragments/fortran: idem 120 * mgr/fragments/fortran_library: idem 121 * mgr/fragments/lex: idem 122 * mgr/fragments/lex_library: idem 123 * mgr/fragments/yacc: idem 124 * mgr/fragments/yacc_library: idem 125 * mgr/requirements: Declare fragments package, packages_header, 126 packages_trailer, dependency 127 * src/Makefile.core: Add .in to known suffixes 128 * src/Makefile.header: Introduce and implement BCAST mode, making use of 129 cmt build broadcast_config command. In QUICK mode, rebuild constituents or 130 broadcast Makefile and corresponding macros files if any requirements file 131 changes, specify explicit (with empty command) rules for requirements files 132 for optimisation, implement dynamic help messages on targets available for 133 BCAST mode 134 * src/setup.csh: Set MAKEFLAGS, if unset, to set number of job slots to 135 number of processors, and enable CMT QUICK mode 136 * src/setup.sh: idem. Use only shell parameter expansion to determine 137 whether shell is intercative. 138 1 139 2011-07-06 <rybkin@lal.in2p3.fr> 464 2 140 -
CMT/HEAD/mgr/fragments/c
r487 r588 20 20 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 21 21 22 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 23 22 24 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) 23 25 endif -
CMT/HEAD/mgr/fragments/c_library
r487 r588 20 20 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 21 21 22 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 23 22 24 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) 23 25 endif -
CMT/HEAD/mgr/fragments/constituent
r561 r588 44 44 endif 45 45 46 not_${CONSTITUENT}_dependencies = { n=0; for p in $?; do m=0; for d in $(${CONSTITUENT}_dependencies); do if [ $$p = $$d ]; then m=1; break; fi; done; if [ $$m -eq 0 ]; then n=1; break; fi; done; [ $$n -eq 1 ]; } 47 46 48 ifdef STRUCTURED_OUTPUT 47 49 ${CONSTITUENT}dirs : … … 73 75 $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 74 76 else 75 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) 76 if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 77 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \ 77 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(use_requirements) 78 @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 79 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \ 80 $(not_${CONSTITUENT}_dependencies) ; then \ 78 81 test -z "$(cmtmsg)" || \ 79 82 echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \ … … 89 92 $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 90 93 else 91 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) 92 if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 93 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \ 94 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(bin)${CONSTITUENT}.in 95 @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 96 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \ 97 $(not_${CONSTITUENT}_dependencies) ; then \ 94 98 test -z "$(cmtmsg)" || \ 95 99 echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \ … … 104 108 ${CONSTITUENT} :: $(${CONSTITUENT}_dependencies) $(cmt_local_${CONSTITUENT}_makefile) dirs ${CONSTITUENT}dirs 105 109 $(echo) "(constituents.make) Starting ${CONSTITUENT}" 106 @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 110 @if test -f $(cmt_local_${CONSTITUENT}_makefile); then \ 111 $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \ 112 fi 113 # @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 107 114 $(echo) "(constituents.make) ${CONSTITUENT} done" 108 115 … … 126 133 $(echo) "(constituents.make) install ${CONSTITUENT} done" 127 134 128 uninstall : :${CONSTITUENT}uninstall135 uninstall : ${CONSTITUENT}uninstall 129 136 130 137 $(foreach d,$(${CONSTITUENT}_dependencies),$(eval $(d)uninstall_dependencies += ${CONSTITUENT}uninstall)) 131 138 132 ${CONSTITUENT}uninstall : : $(${CONSTITUENT}uninstall_dependencies)$(cmt_local_${CONSTITUENT}_makefile)139 ${CONSTITUENT}uninstall : $(${CONSTITUENT}uninstall_dependencies) ##$(cmt_local_${CONSTITUENT}_makefile) 133 140 $(echo) "(constituents.make) Starting uninstall ${CONSTITUENT}" 134 @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall 141 @if test -f $(cmt_local_${CONSTITUENT}_makefile); then \ 142 $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall; \ 143 fi 144 # @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall 135 145 $(echo) "(constituents.make) uninstall ${CONSTITUENT} done" 146 147 remove_library_links :: ${CONSTITUENT}uninstall 136 148 137 149 ifndef PEDANTIC -
CMT/HEAD/mgr/fragments/constituent_lock
r561 r588 44 44 endif 45 45 46 not_${CONSTITUENT}_dependencies = { n=0; for p in $?; do m=0; for d in $(${CONSTITUENT}_dependencies); do if [ $$p = $$d ]; then m=1; break; fi; done; if [ $$m -eq 0 ]; then n=1; break; fi; done; [ $$n -eq 1 ]; } 47 46 48 ifdef STRUCTURED_OUTPUT 47 49 ${CONSTITUENT}dirs : … … 73 75 $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 74 76 else 75 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) 76 if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 77 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \ 77 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(use_requirements) 78 @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 79 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \ 80 $(not_${CONSTITUENT}_dependencies) ; then \ 78 81 test -z "$(cmtmsg)" || \ 79 82 echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \ … … 89 92 $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 90 93 else 91 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) 92 if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 93 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \ 94 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(bin)${CONSTITUENT}.in 95 @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 96 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \ 97 $(not_${CONSTITUENT}_dependencies) ; then \ 94 98 test -z "$(cmtmsg)" || \ 95 99 echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \ … … 107 111 retval=$$?; \ 108 112 trap '${unlock_command} ${CONSTITUENT}${lock_suffix}; exit $${retval}' 1 2 15; \ 113 if test -f $(cmt_local_${CONSTITUENT}_makefile); then \ 109 114 $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \ 115 fi; \ 110 116 retval=$$?; ${unlock_command} ${CONSTITUENT}${lock_suffix}; exit $${retval} 111 117 $(echo) "(constituents.make) ${CONSTITUENT} done" … … 130 136 $(echo) "(constituents.make) install ${CONSTITUENT} done" 131 137 132 uninstall : :${CONSTITUENT}uninstall138 uninstall : ${CONSTITUENT}uninstall 133 139 134 140 $(foreach d,$(${CONSTITUENT}_dependencies),$(eval $(d)uninstall_dependencies += ${CONSTITUENT}uninstall)) 135 141 136 ${CONSTITUENT}uninstall : : $(${CONSTITUENT}uninstall_dependencies)$(cmt_local_${CONSTITUENT}_makefile)142 ${CONSTITUENT}uninstall : $(${CONSTITUENT}uninstall_dependencies) ##$(cmt_local_${CONSTITUENT}_makefile) 137 143 $(echo) "(constituents.make) Starting uninstall ${CONSTITUENT}" 138 @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall 144 @if test -f $(cmt_local_${CONSTITUENT}_makefile); then \ 145 $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall; \ 146 fi 147 # @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall 139 148 $(echo) "(constituents.make) uninstall ${CONSTITUENT} done" 149 150 remove_library_links :: ${CONSTITUENT}uninstall 140 151 141 152 ifndef PEDANTIC -
CMT/HEAD/mgr/fragments/constituents_header
r488 r588 26 26 #cmt_final_setup = $(bin)$(package)setup.make 27 27 28 cmt_build_library_linksstamp = $(bin)cmt_build_library_links.stamp 28 29 #-------------------------------------------------------- 29 30 … … 73 74 74 75 ifndef QUICK 75 all :: build_library_links 76 $(echo) "(constituents.make) all done" 76 all :: build_library_links ; 77 else 78 all :: $(cmt_build_library_linksstamp) ; 77 79 endif 78 80 … … 88 90 # if test ! -d $(bin) ; then $(mkdir) -p $(bin) ; fi 89 91 90 requirements :91 @if test ! -r requirements ; then echo "No requirements file" ; fi92 #requirements : 93 # @if test ! -r requirements ; then echo "No requirements file" ; fi 92 94 93 95 build_library_links : dirs … … 97 99 # $(build_library_links) 98 100 101 $(cmt_build_library_linksstamp) : $(cmt_final_setup) $(cmt_local_tagfile) $(bin)library_links.in 102 $(echo) "(constituents.make) Rebuilding library links"; \ 103 $(build_library_links) -f=$(bin)library_links.in -without_cmt 104 $(silent) \touch $@ 105 99 106 makefiles : ; 100 107 108 ifndef PEDANTIC 101 109 .DEFAULT :: 110 #.DEFAULT : 102 111 $(echo) "(constituents.make) $@: No rule for such target" >&2 103 # @echo "#CMT> Warning: $@: Using default commands" >&2; exit 112 endif 104 113 105 # @if test "$@" = "$(cmt_lock_setup)"; then \ 106 # /bin/rm -f $(cmt_lock_setup); \ 107 # touch $(cmt_lock_setup); \ 108 #fi 114 ${CMTROOT}/src/Makefile.core : ; 115 ifdef use_requirements 116 $(use_requirements) : ; 117 endif 109 118 110 119 #-- end of constituents_header ------ -
CMT/HEAD/mgr/fragments/constituents_trailer
r487 r588 1 1 #-- start of constituents_trailer ------ 2 2 3 clean :: remove_library_links 3 uninstall : remove_library_links ; 4 clean :: 5 $(cleanup_echo) $(cmt_build_library_linksstamp) 6 -$(cleanup_silent) \rm -f $(cmt_build_library_linksstamp) 7 #clean :: remove_library_links 4 8 5 9 remove_library_links :: 10 ifndef QUICK 6 11 $(echo) "(constituents.make) Removing library links"; \ 7 12 $(remove_library_links) 13 else 14 $(echo) "(constituents.make) Removing library links"; \ 15 $(remove_library_links) -f=$(bin)library_links.in -without_cmt 16 endif 8 17 9 18 makefilesclean :: … … 15 24 clean :: makefilesclean 16 25 17 binclean :: clean18 $(echo) "(constituents.make) Removing binary directory $(bin)"19 @if test ! "$(bin)" = "./"; then \20 /bin/rm -rf $(bin); \21 fi22 23 26 #-- end of constituents_trailer ------ -
CMT/HEAD/mgr/fragments/cpp
r487 r588 20 20 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 21 21 22 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 23 22 24 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) 23 25 endif -
CMT/HEAD/mgr/fragments/cpp_library
r487 r588 20 20 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 21 21 22 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 23 22 24 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) 23 25 endif -
CMT/HEAD/mgr/fragments/dependencies
r548 r588 1 #-- start of dependenc y------------------1 #-- start of dependencies ------------------ 2 2 ifneq ($(MAKECMDGOALS),${CONSTITUENT}clean) 3 3 ifneq ($(MAKECMDGOALS),uninstall) 4 4 5 #$(bin)${CONSTITUENT}_dependencies.make :: dirs 6 7 ifndef QUICK 8 $(bin)${CONSTITUENT}_dependencies.make : ${LINE} $(use_requirements) $(cmt_final_setup_${CONSTITUENT}) 9 else 10 $(bin)${CONSTITUENT}_dependencies.make : 11 endif 5 $(bin)${CONSTITUENT}_dependencies.make : $(use_requirements) $(cmt_final_setup_${CONSTITUENT}) 12 6 $(echo) "(${CONSTITUENT}.make) Rebuilding $@"; \ 13 $(build_dependencies) ${CONSTITUENT} -all_sources -out=$@ ${LINE} 14 15 #$(${CONSTITUENT}_dependencies) 7 $(build_dependencies) -out=$@ -start_all ${LINE} -end_all $(includes) $(app_${CONSTITUENT}_cppflags) $(lib_${CONSTITUENT}_cppflags) ${CONSTITUENT} $? -f=$(cmt_dependencies_in_${CONSTITUENT}) -without_cmt 16 8 17 9 -include $(bin)${CONSTITUENT}_dependencies.make … … 19 11 endif 20 12 endif 21 #-- end of dependenc y-------------------13 #-- end of dependencies ------------------- -
CMT/HEAD/mgr/fragments/fortran
r469 r588 2 2 3 3 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 4 5 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 4 6 5 7 $(bin)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) -
CMT/HEAD/mgr/fragments/fortran_library
r469 r588 2 2 3 3 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 4 5 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 4 6 5 7 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) -
CMT/HEAD/mgr/fragments/lex
r436 r588 2 2 3 3 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 4 5 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 4 6 5 7 $(bin)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) -
CMT/HEAD/mgr/fragments/lex_library
r436 r588 2 2 3 3 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 4 5 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 4 6 5 7 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) -
CMT/HEAD/mgr/fragments/make_header
r487 r588 46 46 47 47 cmt_final_setup_${CONSTITUENT} = $(bin)setup_${CONSTITUENT}.make 48 cmt_dependencies_in_${CONSTITUENT} = $(bin)dependencies_${CONSTITUENT}.in 48 49 #cmt_final_setup_${CONSTITUENT} = $(bin)${PACKAGE}_${CONSTITUENT}setup.make 49 50 cmt_local_${CONSTITUENT}_makefile = $(bin)${CONSTITUENT}.make … … 52 53 53 54 cmt_final_setup_${CONSTITUENT} = $(bin)setup.make 55 cmt_dependencies_in_${CONSTITUENT} = $(bin)dependencies.in 54 56 #cmt_final_setup_${CONSTITUENT} = $(bin)${PACKAGE}setup.make 55 57 cmt_local_${CONSTITUENT}_makefile = $(bin)${CONSTITUENT}.make … … 83 85 endif 84 86 87 ${CMTROOT}/src/Makefile.core : ; 85 88 ifdef use_requirements 86 89 $(use_requirements) : ; -
CMT/HEAD/mgr/fragments/yacc
r436 r588 2 2 3 3 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 4 5 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 4 6 5 7 $(bin)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) -
CMT/HEAD/mgr/fragments/yacc_library
r436 r588 2 2 3 3 $(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies) 4 5 $(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME} 4 6 5 7 $(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies) -
CMT/HEAD/mgr/requirements
r561 r588 588 588 make_fragment constituents_trailer 589 589 590 make_fragment packages_header 591 make_fragment package 592 make_fragment packages_trailer 593 590 594 make_fragment dependencies 591 595 make_fragment dependencies_and_triggers 596 make_fragment dependency 592 597 593 598 make_fragment readme_header -
CMT/HEAD/source/cmt.h
r565 r588 111 111 static void do_build_constituents_makefile (const ArgParser& ap); 112 112 static void do_build_constituents_config (const ArgParser& ap); 113 static void do_build_broadcast_config (const ArgParser& ap); 113 114 static void do_build_dependencies (const ArgParser& ap, 114 115 int argc, -
CMT/HEAD/source/cmt_cmtpath_pattern.cxx
r400 r588 278 278 } 279 279 280 bool CmtPathPattern::is_constant () const 281 { 282 return ((line.find ("<path>") == cmt_string::npos) && 283 (line.find ("<project>") == cmt_string::npos)); 284 } -
CMT/HEAD/source/cmt_cmtpath_pattern.h
r283 r588 35 35 void apply () const; 36 36 void expand (cmt_string& line, const cmt_string& path, const cmt_string& project) const; 37 bool is_constant () const; 37 38 38 39 cmt_string line; -
CMT/HEAD/source/cmt_commands.cxx
r568 r588 694 694 } 695 695 } 696 else if (arg == "broadcast_config") 697 { 698 cmt.m_action = action_build_broadcast_config; 699 700 if (cmt.m_scope_filtering_mode == default_filtering_mode) 701 { 702 cmt.m_scope_filtering_mode = reach_private_uses; 703 } 704 705 while (argc > 0) 706 { 707 cmt_string arg(argv[0]); 708 if (arg.substr (0, 5) == "-out=") 709 { 710 fill_one_argument (); 711 } 712 else 713 { 714 help_action = action_help; 715 CmtError::set (CmtError::syntax_error, arg + ": wrong argument"); 716 break; 717 } 718 } 719 } 696 720 else if (arg == "dependencies") 697 721 { 698 722 if (argc > 0) 699 723 { 700 fill_arguments (); 724 // fill_arguments (); 725 while (argc > 0) 726 { 727 cmt_string arg(argv[0]); 728 if (arg.substr (0, 3) == "-f=") 729 { 730 shift (); 731 extra_file = arg.substr (3); 732 } 733 else if (arg.substr (0, 3) == "-e=") 734 { 735 shift (); 736 extra_line = arg.substr (3); 737 } 738 else if (arg == "-with_cmt") 739 { 740 shift (); 741 cmt.m_use_cmt = true; 742 } 743 else if (arg == "-without_cmt") 744 { 745 shift (); 746 cmt.m_use_cmt = false; 747 } 748 else 749 { 750 fill_one_argument (); 751 } 752 } 701 753 cmt.m_action = action_build_dependencies; 702 754 } 703 755 else 704 756 { 705 CmtMessage::error ("syntax: arguments missing");757 //CmtMessage::error ("syntax: arguments missing"); 706 758 // if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl; 759 CmtError::set (CmtError::syntax_error, "arguments missing"); 707 760 help_action = action_help; 708 761 cmt.m_action = action_build_dependencies; … … 2309 2362 void CommandHelp::show (ActionType action) 2310 2363 { 2311 // cerr << "CommandHelp::show> action = " << action << endl;2364 // cerr << "CommandHelp::show> action = " << action << endl; 2312 2365 2313 2366 static HelpTexts& help_texts = get_help_texts (); … … 2375 2428 help_texts.add () = "build constituents_makefile [-out=<path>] : generate constituents Makefile"; 2376 2429 help_texts.add () = "build constituents_config [-out=<path>] [-with_cmt] [-without_cmt] : generate constituents Makefile, tag specific Makefile, and setup definitions file, also input requirements file for constituent(s) without associated tag"; 2377 help_texts.add () = "build dependencies : generate dependencies"; 2430 help_texts.add () = "build broadcast_config [-out=<path>] : generate broadcast Makefile, and broadcast specific macros Makefile"; 2431 help_texts.add () = "build dependencies [-out=<path>] [-all_sources] [-no_stamps] [-I<directory>]... [-start_all FILE... -end_all] NAME FILE... : generate dependencies for FILEs of constituent NAME"; 2378 2432 help_texts.add () = "build library_links : build symbolic links towards all imported libraries"; 2379 2433 help_texts.add () = "build make_setup : build a compiled version of setup scripts"; … … 2477 2531 help.add (action_build_constituents_makefile, help_texts[action_build_constituents_makefile]); 2478 2532 help.add (action_build_constituents_config, help_texts[action_build_constituents_config]); 2533 help.add (action_build_broadcast_config, help_texts[action_build_broadcast_config]); 2479 2534 help.add (action_build_dependencies, help_texts[action_build_dependencies]); 2480 2535 help.add (action_build_library_links, help_texts[action_build_library_links]); -
CMT/HEAD/source/cmt_constituent.cxx
r561 r588 47 47 if (symbol.type != Symbol::SymbolAction) continue; 48 48 49 /* 49 50 if (symbol.value_lists.size () < 1) continue; 50 51 … … 55 56 add_for_action (symbol.name); 56 57 } 58 */ 59 add_for_action (symbol); 57 60 } 58 61 … … 368 371 //cerr << "Constituent " << name << " Analyzing module " << ew << endl; 369 372 370 if (ew.substr (0, 13) == "action_value=")371 {372 it.set (ew);373 }374 else375 {373 // if (ew.substr (0, 13) == "action_value=") 374 // { 375 // it.set (ew); 376 // } 377 // else 378 // { 376 379 CmtSystem::split (ew, " \t", ws); 377 380 … … 383 386 it.set (w); 384 387 } 385 }388 // } 386 389 } 387 390 … … 417 420 418 421 //---------------------------------------------------------- 419 Constituent* Constituent::add_for_action (const cmt_string& name) 420 { 421 Constituent* constituent; 422 423 constituent = add (Document, name, "cmt_action_runner"); 422 Constituent* Constituent::add_for_action (const Symbol& symbol) 423 //Constituent* Constituent::add_for_action (const cmt_string& name) 424 { 425 Constituent* constituent (0); 426 if (symbol.value_lists.size () < 1) return constituent; 427 428 const Tag* tag = Tag::find ("target_" + symbol.name); 429 const bool target_tag_used 430 (Tag::check_tag_used (tag) || Symbol::check_tag_used (tag)); 431 432 cmt_string value = symbol.build_macro_value (); 433 if ( "" == value && !target_tag_used) return constituent; 434 435 constituent = add (Document, symbol.name, "cmt_action_runner"); 424 436 425 437 constituent->group = Group::add ("cmt_actions"); 426 constituent->has_target_tag = true; 438 439 // Do NOT assign target_<name> by default 440 // but only if this tag is used somewhere 441 if (target_tag_used) 442 constituent->has_target_tag = true; 427 443 428 444 cmt_string& p1 = constituent->parameters.add (); 429 445 p1 = "action_value="; 430 p1 += "$("; 431 p1 += name; 432 p1 += ")"; 446 Symbol::expand (value); 447 // quote since split will later be applied 448 // - in parse 449 p1 += CmtSystem::quote (value, " \t"); 450 // p1 += "$("; 451 // p1 += symbol.name; 452 // p1 += ")"; 433 453 434 454 return (constituent); … … 549 569 if (!simulation) 550 570 { 551 Generator::build_constituent_makefile (*this); 571 bool dependencies (false); 572 Generator::build_constituent_makefile (*this, dependencies); 552 573 } 553 574 } -
CMT/HEAD/source/cmt_constituent.h
r561 r588 23 23 const cmt_string& name, 24 24 const cmt_string& generator); 25 static Constituent* add_for_action (const cmt_string& name); 25 static Constituent* add_for_action (const Symbol& action); 26 //static Constituent* add_for_action (const cmt_string& name); 26 27 static void show (const cmt_string& name); 27 28 static void parse_all (); -
CMT/HEAD/source/cmt_deps_builder.cxx
r427 r588 11 11 #include "cmt_symbol.h" 12 12 #include "cmt_log.h" 13 #include "cmt_error.h" 13 14 14 15 // … … 92 93 { 93 94 cmt_string stamp_file; 95 log << "|header_file_action> header " << header_file_path << " against stamp " << stamp_file << log_endl; 94 96 if (header_filters[i].use_stamp (header_file_path, stamp_file)) 95 97 { … … 113 115 /////////////////////////////////////////////////////////////////////////////////////////////////////// 114 116 cmt_string text; 115 text.read (header_file_path); 117 if (!text.read (header_file_path)) 118 { 119 CmtError::set (CmtError::file_access_error, header_file_path); 120 return; 121 } 116 122 char* ptr = &text[0]; 117 123 cmt_string new_dir; … … 725 731 { 726 732 cmt_string text; 727 text.read (full_name); 733 if (!text.read (full_name)) 734 { 735 CmtError::set (CmtError::file_access_error, full_name); 736 return -2; 737 } 728 738 char* ptr = &text[0]; 729 739 cmt_string new_dir; … … 746 756 { 747 757 log << "CMT> build_deps3" << log_endl; 758 CmtError::set (CmtError::path_not_found, name); 748 759 } 749 760 return path_index; … … 811 822 812 823 //-------------------------------------------------------------------------- 824 DepsBuilder::DepsBuilder () 825 { } 826 827 //-------------------------------------------------------------------------- 828 DepsBuilder::~DepsBuilder () 829 { 830 clear (); 831 } 832 833 //-------------------------------------------------------------------------- 813 834 void DepsBuilder::clear () 814 835 { … … 820 841 } 821 842 m_header_filters.clear (); 843 m_deps.clear (); 844 m_all_deps.clear (); 822 845 } 823 846 … … 829 852 return; 830 853 } 854 855 cmt_string p = path; 831 856 if (path[path.size () - 1] == CmtSystem::file_separator ()) 832 857 { 833 cmt_string p = path;834 p.erase (path.size () - 1);835 m_include_paths.push_back (p);836 }837 else838 { 839 m_include_paths.push_back (path);840 }841 858 p = path.substr(0, path.size () - 1); 859 } 860 for (int k = m_include_paths.size () - 1; k >= 0; k--) 861 if (m_include_paths[k] == p) 862 { 863 return; 864 } 865 866 m_include_paths.push_back (p); 842 867 m_substitutions.push_back (substitution); 843 868 } … … 919 944 920 945 //-------------------------------------------------------------------------- 921 CmtSystem::cmt_string_vector& DepsBuilder::run (const cmt_string& file_name) 946 CmtSystem::cmt_string_vector& DepsBuilder::run (const cmt_string& file_name, 947 const cmt_string& constituent_name) 922 948 { 923 949 Log; 924 950 925 951 log << "Starting deps builder on " << file_name << log_endl; 952 CmtMessage::info ("calculating dependencies for " + file_name); 926 953 927 954 m_deps.clear (); … … 974 1001 // missing) 975 1002 // 976 preprocessor += " ";977 1003 macro = Symbol::find ("includes"); 978 preprocessor += macro->resolve_macro_value (); 1004 if (0 != macro) 1005 { 1006 preprocessor += " "; 1007 preprocessor += macro->resolve_macro_value (); 1008 } 1009 macro = Symbol::find ("app_" + constituent_name + "_cppflags"); 1010 if (0 != macro) 1011 { 1012 preprocessor += " "; 1013 preprocessor += macro->resolve_macro_value (); 1014 } 1015 macro = Symbol::find ("lib_" + constituent_name + "_cppflags"); 1016 if (0 != macro) 1017 { 1018 preprocessor += " "; 1019 preprocessor += macro->resolve_macro_value (); 1020 } 1021 979 1022 preprocessor += " "; 980 1023 preprocessor += file_name; … … 982 1025 cmt_string output; 983 1026 984 CmtSystem::execute (preprocessor, output); 1027 int status = CmtSystem::execute (preprocessor, output); 1028 if (0 != status) 1029 { 1030 CmtError::set (CmtError::execution_failed, preprocessor, status); 1031 return m_deps; 1032 } 985 1033 986 1034 // … … 1041 1089 1042 1090 //-------------------------------------------------------------------------- 1043 void DepsBuilder::add_header_filter (const Use* use, c onst cmt_regexp* filter, const cmt_string& stamp)1091 void DepsBuilder::add_header_filter (const Use* use, cmt_regexp* filter, const cmt_string& stamp) 1044 1092 { 1045 1093 add_header_filter (HeaderFilter (use, filter, stamp)); -
CMT/HEAD/source/cmt_deps_builder.h
r427 r588 23 23 : m_use (0), m_filter (0) { } 24 24 25 HeaderFilter (const Use* use, c onst cmt_regexp* filter, const cmt_string& stamp)25 HeaderFilter (const Use* use, cmt_regexp* filter, const cmt_string& stamp) 26 26 : m_use (use), m_filter (filter), m_stamp (stamp) { } 27 27 … … 38 38 { 39 39 m_use = 0; 40 if (m_filter) delete m_filter; 40 if (m_filter) 41 { 42 m_filter->clear (); 43 delete m_filter; 44 } 41 45 m_filter = 0; 42 46 m_stamp = cmt_string (); … … 46 50 47 51 const Use* m_use; 48 c onst cmt_regexp* m_filter;52 cmt_regexp* m_filter; 49 53 cmt_string m_stamp; 50 54 }; … … 55 59 void add (const cmt_string& path, const cmt_string& substitution); 56 60 void add_includes (const Use& use); 57 void add_header_filter (const Use* use, c onst cmt_regexp* filter, const cmt_string& stamp);61 void add_header_filter (const Use* use, cmt_regexp* filter, const cmt_string& stamp); 58 62 void add_header_filter (const HeaderFilter& hf); 59 CmtSystem::cmt_string_vector& run (const cmt_string& file_name); 63 CmtSystem::cmt_string_vector& run (const cmt_string& file_name, 64 const cmt_string& constituent_name); 60 65 61 DepsBuilder () 62 { }66 DepsBuilder (); 67 ~DepsBuilder (); 63 68 64 69 private: 65 70 66 DepsBuilder (const DepsBuilder&) 67 { }71 DepsBuilder (const DepsBuilder&); 72 DepsBuilder& operator = (const DepsBuilder&); 68 73 69 74 CmtSystem::cmt_string_vector m_include_paths; 70 75 CmtSystem::cmt_string_vector m_substitutions; 71 76 HeaderFilters m_header_filters; 72 73 77 CmtSystem::cmt_string_vector m_deps; 74 78 CmtSystem::cmt_string_vector m_all_deps; -
CMT/HEAD/source/cmt_generator.cxx
r561 r588 19 19 #include "cmt_log.h" 20 20 #include "cmt_error.h" 21 22 #include "cmt_install_area.h" 21 23 22 24 //------------------------------------------------------------------------ … … 143 145 144 146 m_source_files.clear (); 147 m_bin = ""; 148 m_output_file_name = ""; 149 m_output_file = 0; 150 m_constituent = 0; 145 151 146 152 Language::setup_all_fragments (); … … 350 356 if (Cmt::get_debug ()) 351 357 { 352 cout << "CmtGenerator::fill_names_ 358 cout << "CmtGenerator::fill_names_outputs>" << endl; 353 359 cout << "name=" << name << " LINE=" << m_LINE << endl; 354 360 cout << "output=" << output << " OBJS=" << m_OBJS << endl; … … 399 405 } 400 406 407 /* 401 408 //-------------------------------------------------- 402 409 void CmtGenerator::prepare_use_context () … … 476 483 } 477 484 } 478 485 */ 479 486 //-------------------------------------------------- 480 487 void CmtGenerator::filter_path (cmt_string& text) … … 700 707 static MakeSetupGenerator MakeSetupContext; 701 708 static ConstituentsMakefileGenerator ConstituentsMakefileContext; 709 static PackagesMakefileGenerator PackagesMakefileContext; 702 710 static DependencyGenerator DependencyContext; 703 711 … … 813 821 814 822 //-------------------------------------------------- 823 int Generator::build_library_links_infile (const cmt_string& outdir) 824 { 825 #ifndef WIN32 826 cmt_string file ("library_links.in"); 827 if (outdir != "") 828 { 829 if (outdir [outdir.size () - 1] != CmtSystem::file_separator ()) 830 file = outdir + CmtSystem::file_separator () + file; 831 else 832 file = outdir + file; 833 } 834 835 bool wrote (false); 836 ostringstream ls; 837 838 Use::UsePtrVector& Uses = Use::get_ordered_uses (); 839 Use& current_use = Use::current (); 840 Use::UsePtrVector uses (Uses); 841 uses.push_back (&Use::current ()); 842 843 cmt_string shlibsuffix; 844 { 845 Symbol* macro = Symbol::find ("shlibsuffix"); 846 if (macro == 0) 847 { 848 CmtError::set(CmtError::configuration_error, "shlibsuffix undefined"); 849 return -1; 850 } 851 shlibsuffix = macro->build_macro_value (); 852 Symbol::expand (shlibsuffix); 853 } 854 855 for (int i = 0; i < uses.size (); i++) 856 { 857 Use* use = uses[i]; 858 859 if (use == 0) continue; 860 if (use->discarded) continue; 861 if (use->m_hidden) continue; 862 863 if (use->get_package_name () == "CMT") continue; 864 if (!use->located ()) continue; 865 //use->remove_library_links (cmtinstallarea, tag, shlibsuffix, symunlinkcmd); 866 cmt_string s (use->get_package_name ()); 867 s += "_libraries"; 868 const Symbol* libraries_macro = Symbol::find (s); 869 if (libraries_macro == 0) continue; 870 cmt_string libraries = libraries_macro->build_macro_value (); 871 Symbol::expand (libraries); 872 static CmtSystem::cmt_string_vector values; 873 874 CmtSystem::split (libraries, " \t", values); 875 876 for (int j = 0; j < values.size (); j++) 877 { 878 const cmt_string& library = values[j]; 879 880 static cmt_string libname; 881 static cmt_string name; 882 883 // Is it a simple name or a complete path? 884 885 libname = library; 886 Symbol::expand (libname); 887 if (0 == libname.size ()) continue; 888 889 CmtSystem::cmt_string_vector paths; 890 use->absolute_library_path (libname, 891 shlibsuffix, 892 paths); 893 for (int k = 0; k < paths.size (); k++) 894 { 895 cmt_string path (paths[k]); 896 Symbol::expand (path); 897 if (0 == path.size ()) continue; 898 if (wrote) ls << " "; 899 else wrote = true; 900 ls << CmtSystem::quote (path, " \t"); 901 } 902 } 903 } 904 ostringstream os; 905 if (wrote) 906 { 907 os << "macro "; 908 os << current_use.get_package_name () + "_libraries "; 909 os << CmtSystem::quote (ls.str ().c_str (), " \t"); 910 os << "\n"; 911 912 os << "macro shlibsuffix "; 913 os << CmtSystem::quote (shlibsuffix, " \t"); 914 os << "\n"; 915 916 cmt_string symlinkcmd; 917 { 918 Symbol* macro = Symbol::find ("library_install_command"); 919 if (macro != 0) 920 { 921 symlinkcmd = macro->build_macro_value (); 922 Symbol::expand (symlinkcmd); 923 } 924 } 925 os << "macro library_install_command "; 926 os << CmtSystem::quote (symlinkcmd, " \t"); 927 os << "\n"; 928 929 cmt_string symunlinkcmd; 930 { 931 Symbol* macro = Symbol::find ("symunlink"); 932 if (macro != 0) 933 { 934 symunlinkcmd = macro->build_macro_value (); 935 Symbol::expand (symunlinkcmd); 936 } 937 } 938 os << "macro symunlink "; 939 os << CmtSystem::quote (symunlinkcmd, " \t"); 940 os << "\n"; 941 942 if (current_use.get_strategy ("InstallArea")) 943 { 944 os << "build_strategy with_installarea\n"; 945 946 const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); 947 948 cmt_string cmtinstallarea = ia_mgr.get_installarea (); 949 { 950 Symbol* symbol = Symbol::find ("CMTINSTALLAREA"); 951 if (symbol != 0) 952 { 953 cmtinstallarea = symbol->build_macro_value (); 954 Symbol::expand (cmtinstallarea); 955 } 956 } 957 os << "macro CMTINSTALLAREA "; 958 os << CmtSystem::quote (cmtinstallarea, " \t"); 959 os << "\n"; 960 961 cmt_string tag; 962 { 963 Symbol* macro = Symbol::find ("tag"); 964 if (macro != 0) 965 { 966 tag = macro->build_macro_value (); 967 Symbol::expand (tag); 968 } 969 } 970 os << "macro tag "; 971 os << CmtSystem::quote (tag, " \t"); 972 os << "\n"; 973 } 974 // cerr << os.str (); 975 } 976 977 // Write input requirements file 978 979 // static InGenerator InGen (usecmt); 980 981 bool gen (true); 982 // ostringstream os; 983 ofstream s; 984 // s.open (file); 985 s.open (file, ios::in); 986 if (s) // file already exists 987 { 988 // InGen.build (constituent, os); 989 ostringstream osn; 990 osn << s.rdbuf (); 991 if (os.str () == osn.str ()) 992 { 993 // cerr << file << " up-to-date" << endl; 994 gen = false; 995 } 996 } 997 s.clear (); 998 s.close (); 999 s.clear (); 1000 if (gen) 1001 { 1002 s.open (file); 1003 if (!s) 1004 { 1005 CmtError::set (CmtError::file_access_error, file); 1006 return -1; 1007 } 1008 s.exceptions (ios::failbit | ios::badbit); 1009 try 1010 { 1011 // if (os.str ().size () != 0) 1012 // { 1013 // cerr << file << " contents already generated" << endl; 1014 s << os.str (); 1015 // } 1016 // else 1017 // { 1018 // InGen.build (constituent, s); 1019 // } 1020 s.close (); // ios_base::failbit 1021 } 1022 catch (const ios::failure& e) 1023 { 1024 CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ())); 1025 return -1; 1026 } 1027 } 1028 1029 #endif 1030 return 0; 1031 } 1032 1033 //-------------------------------------------------- 1034 int Generator::build_dependencies_infile (const Constituent* pconstituent, 1035 const cmt_string& outdir, 1036 bool usecmt) 1037 { 1038 cmt_string file ("dependencies"); 1039 if (0 != pconstituent) 1040 file += "_" + pconstituent->name; 1041 file += ".in"; 1042 1043 if (outdir != "") 1044 { 1045 if (outdir [outdir.size () - 1] != CmtSystem::file_separator ()) 1046 file = outdir + CmtSystem::file_separator () + file; 1047 else 1048 file = outdir + file; 1049 } 1050 1051 ostringstream os; 1052 1053 cmt_string preprocessor; 1054 Symbol* macro = Symbol::find ("preprocessor_command"); 1055 if (macro != 0) 1056 { 1057 preprocessor = macro->resolve_macro_value (); 1058 } 1059 1060 if (preprocessor == "") 1061 { 1062 const Use* current_use = &Use::current (); 1063 Use::UsePtrVector uses (Use::get_ordered_uses ()); 1064 uses.push_back (&Use::current ()); 1065 1066 if (current_use->include_path == "none") 1067 os << "include_path none\n"; 1068 1069 for (int i = uses.size () - 1; i >= 0; i--) 1070 { 1071 const Use* use = uses[i]; 1072 if (use->discarded) continue; 1073 if (use->m_hidden) continue; 1074 if (!use->located ()) continue; 1075 1076 cmt_string package_name = use->get_package_name (); 1077 if (package_name == "CMT") continue; 1078 1079 const Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter"); 1080 if (filter_macro == 0) continue; 1081 1082 const Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp"); 1083 cmt_string stamp; 1084 if (stamp_macro != 0) 1085 { 1086 stamp = stamp_macro->resolve_macro_value (); 1087 } 1088 else 1089 { 1090 use->get_full_path (stamp); 1091 switch (use->style) 1092 { 1093 case cmt_style: 1094 stamp += CmtSystem::file_separator (); 1095 stamp += "cmt"; 1096 break; 1097 case mgr_style: 1098 stamp += CmtSystem::file_separator (); 1099 stamp += "mgr"; 1100 break; 1101 } 1102 stamp += CmtSystem::file_separator (); 1103 stamp += "cmt_header_file.stamp"; 1104 } 1105 if (!CmtSystem::test_file (stamp)) continue; 1106 1107 os << "macro " + package_name + "_header_file_filter "; 1108 os << CmtSystem::quote (filter_macro->resolve_macro_value (), " \t"); 1109 os << "\n"; 1110 os << "macro " + package_name + "_header_file_stamp "; 1111 os << CmtSystem::quote (stamp, " \t"); 1112 os << "\n"; 1113 } 1114 } 1115 else 1116 { 1117 os << "macro preprocessor_command "; 1118 os << CmtSystem::quote (preprocessor, " \t"); 1119 os << "\n"; 1120 macro = Symbol::find ("includes"); 1121 if (0 != macro) 1122 { 1123 os << "macro includes "; 1124 os << CmtSystem::quote (macro->resolve_macro_value (), " \t"); 1125 os << "\n"; 1126 } 1127 if (0 == pconstituent) 1128 { 1129 const Constituent::ConstituentVector& constituents = 1130 Constituent::constituents (); 1131 for (int n = 0; n < constituents.size (); n++) 1132 { 1133 const Constituent& constituent = constituents[n]; 1134 if (constituent.has_target_tag) continue; 1135 if (constituent.type == Document) continue; 1136 cmt_string prefix; 1137 switch (constituent.type) 1138 { 1139 case Application: 1140 prefix = "app_"; 1141 break; 1142 case Library: 1143 prefix = "lib_"; 1144 break; 1145 } 1146 cmt_string macro_name (prefix + constituent.name + "_cppflags"); 1147 macro = Symbol::find (macro_name); 1148 if (0 != macro) 1149 { 1150 os << "macro_append " + macro_name + " "; 1151 os << CmtSystem::quote (macro->resolve_macro_value (), " \t"); 1152 os << "\n"; 1153 } 1154 } 1155 } 1156 else if (pconstituent->type != Document) 1157 { 1158 const Constituent& constituent = *pconstituent; 1159 cmt_string prefix; 1160 switch (constituent.type) 1161 { 1162 case Application: 1163 prefix = "app_"; 1164 break; 1165 case Library: 1166 prefix = "lib_"; 1167 break; 1168 } 1169 cmt_string macro_name (prefix + constituent.name + "_cppflags"); 1170 macro = Symbol::find (macro_name); 1171 if (0 != macro) 1172 { 1173 os << "macro_append " + macro_name + " "; 1174 os << CmtSystem::quote (macro->resolve_macro_value (), " \t"); 1175 os << "\n"; 1176 } 1177 } 1178 } 1179 1180 // Write input requirements file 1181 1182 bool gen (true); 1183 // ostringstream os; 1184 ofstream s; 1185 // s.open (file); 1186 s.open (file, ios::in); 1187 if (s) // file already exists 1188 { 1189 // InGen.build (constituent, os); 1190 ostringstream osn; 1191 osn << s.rdbuf (); 1192 if (os.str () == osn.str ()) 1193 { 1194 // cerr << file << " up-to-date" << endl; 1195 gen = false; 1196 } 1197 } 1198 s.clear (); 1199 s.close (); 1200 s.clear (); 1201 if (gen) 1202 { 1203 s.open (file); 1204 if (!s) 1205 { 1206 CmtError::set (CmtError::file_access_error, file); 1207 return -1; 1208 } 1209 s.exceptions (ios::failbit | ios::badbit); 1210 try 1211 { 1212 // if (os.str ().size () != 0) 1213 // { 1214 // cerr << file << " contents already generated" << endl; 1215 s << os.str (); 1216 // } 1217 // else 1218 // { 1219 // InGen.build (constituent, s); 1220 // } 1221 s.close (); // ios_base::failbit 1222 } 1223 catch (const ios::failure& e) 1224 { 1225 CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ())); 1226 return -1; 1227 } 1228 } 1229 1230 return 0; 1231 } 1232 1233 //-------------------------------------------------- 815 1234 int Generator::build_constituent_makefile (const Constituent& constituent, 1235 bool& dependencies, 816 1236 const cmt_string& file) 817 1237 { … … 824 1244 //break; 825 1245 case Library: 826 LibraryContext.build (package, constituent, file);1246 LibraryContext.build (package, constituent, dependencies, file); 827 1247 break; 828 1248 case Document: 829 DocumentContext.build (package, constituent, file);1249 DocumentContext.build (package, constituent, dependencies, file); 830 1250 break; 831 1251 } … … 860 1280 861 1281 const Constituent* constituent = Constituent::find (name); 862 if (constituent != 0) build_constituent_makefile (*constituent, file); 1282 if (constituent != 0) 1283 { 1284 bool dependencies (false); 1285 build_constituent_makefile (*constituent, dependencies, file); 1286 } 863 1287 } 864 1288 … … 867 1291 { 868 1292 DefaultMakefileContext.build (); 1293 } 1294 1295 //-------------------------------------------------- 1296 void Generator::build_packages_makefile (const cmt_string& package, 1297 const cmt_string& file) 1298 { 1299 PackagesMakefileContext.build (package, file); 1300 // UsesMakefileContext.build (package, file); 869 1301 } 870 1302 … … 1213 1645 CmtSystem::cmt_string_vector document; 1214 1646 document.push_back ("document_header"); 1647 document.push_back ("dependency"); 1215 1648 m_document.set_names (document); 1216 1649 m_document.set_uses (usecmt); -
CMT/HEAD/source/cmt_generator.h
r561 r588 12 12 #include "cmt_language.h" 13 13 #include "cmt_awk.h" 14 #include "cmt_deps_builder.h"15 14 16 15 class Packager : public FAwk … … 59 58 void fill_outputs (); 60 59 61 void prepare_use_context ();60 // void prepare_use_context (); 62 61 63 62 void set_full_name (cmt_string& full_name, cmt_string& file); … … 96 95 cmt_string m_output_file_name; 97 96 FILE* m_output_file; 98 99 DepsBuilder m_deps_builder;100 97 101 98 Constituent* m_constituent; … … 215 212 // Build the makefile fragment for one constituent 216 213 static int build_constituent_makefile (const Constituent& constituent, 214 bool& dependencies, 217 215 const cmt_string& file = ""); 218 216 static void build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments); … … 221 219 bool usecmt = true); 222 220 221 static int build_library_links_infile (const cmt_string& outdir = ""); 222 223 static int build_dependencies_infile (const Constituent* constituent, 224 const cmt_string& outdir = "", 225 bool usecmt = true); 226 223 227 static void build_default_makefile (); 228 229 // Build the packages (N)Make file 230 static void build_packages_makefile (const cmt_string& package, 231 const cmt_string& file = ""); 224 232 225 233 // Build the dependencies for one module -
CMT/HEAD/source/cmt_generators.cxx
r561 r588 12 12 #include "cmt_error.h" 13 13 #include <assert.h> 14 #include "cmt_project.h" 14 15 15 16 //-------------------------------------------------- … … 200 201 if (Cmt::get_debug ()) 201 202 { 202 cout << " CmtGenerator::analyze_file> constituent=" <<203 cout << "LibraryGenerator::analyze_file> constituent=" << 203 204 constituent.name << 204 205 " obj=" << obj << endl; … … 408 409 409 410 //-------------------------------------------------- 411 void LibraryGenerator::fill_names_outputs () 412 { 413 bool l_first = true; 414 bool o_first = true; 415 416 m_LINE = ""; 417 m_OBJS = ""; 418 419 for (int i = 0; i < m_source_files.size (); i++) 420 { 421 const SourceFile& file = m_source_files[i]; 422 const cmt_string name = file.name (); 423 const cmt_string output = file.output (); 424 Language& language = file.language (); 425 426 if (output != "") 427 { 428 if (o_first) 429 { 430 o_first = false; 431 } 432 else 433 { 434 m_OBJS += " "; 435 } 436 m_OBJS += output; 437 438 if (language == Language::null () || !language.native_dependencies ()) 439 { 440 if (l_first) 441 { 442 l_first = false; 443 } 444 else 445 { 446 m_LINE += " "; 447 } 448 m_LINE += name; 449 } 450 } 451 452 if (Cmt::get_debug ()) 453 { 454 cout << "LibraryGenerator::fill_names_outputs>" << endl; 455 cout << "name=" << name << " LINE=" << m_LINE << endl; 456 cout << "output=" << output << " OBJS=" << m_OBJS << endl; 457 } 458 } 459 460 filter_path (m_LINE.value); 461 } 462 463 //-------------------------------------------------- 410 464 void LibraryGenerator::build (const cmt_string& package, 411 465 const Constituent& constituent, 466 bool& dependencies, 412 467 const cmt_string& file_name) 413 468 { … … 735 790 } 736 791 } 792 dependencies = need_dependencies; 737 793 738 794 if (constituent.build_triggers) … … 893 949 DocumentGenerator::DocumentGenerator () 894 950 { 951 m_FILEEXTENSION.set ("FILEEXTENSION"); 952 895 953 document_header_fragment.set ("document_header"); 954 dependency_fragment.set ("dependency"); 896 955 } 897 956 … … 900 959 { 901 960 AnyDocumentGenerator::reset (); 961 m_FILEEXTENSION = ""; 962 902 963 document_header_fragment.reset (); 964 dependency_fragment.reset (); 903 965 } 904 966 … … 906 968 void DocumentGenerator::build (const cmt_string& package, 907 969 const Constituent& constituent, 970 bool& dependencies, 908 971 const cmt_string& file_name) 909 972 { … … 1062 1125 } 1063 1126 1127 dependencies = fragment.need_dependencies (); 1064 1128 if (fragment.need_dependencies ()) 1065 1129 { … … 1123 1187 if (m_FILEPATH.value != "") m_FILEPATH.value += CmtSystem::file_separator (); 1124 1188 filter_path (m_FILEPATH.value); 1125 CmtSystem::basename (file_name, m_FILENAME.value); 1126 CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value); 1189 m_FILENAME.value = m_NAME.value + suffix; 1190 //CmtSystem::basename (file_name, m_FILENAME.value); 1191 m_FILESUFFIX.value = suffix; 1192 //CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value); 1193 CmtSystem::get_suffix (m_FILENAME.value, m_FILEEXTENSION .value); 1127 1194 /* 1128 1195 if (!CmtSystem::test_file (file_name) && !CmtSystem::test_directory (file_name)) … … 1133 1200 filter_path (m_FULLNAME.value); 1134 1201 1135 fragment.copy (m_output_file, constituent.variables, 8, 1202 if (fragment.need_dependencies ()) 1203 { 1204 // ensure that ${CONSTITUENT}_dependencies.make gets rebuilt 1205 // whenever source file OR its dependencies change 1206 dependency_fragment.copy (m_output_file, constituent.variables, 9, 1207 &m_FILEPATH, 1208 &m_SUFFIX, 1209 &m_CONSTITUENT, 1210 &m_CONSTITUENTSUFFIX, 1211 &m_FILENAME, 1212 &m_NAME, 1213 &m_FULLNAME, 1214 &m_FILESUFFIX, 1215 &m_FILEEXTENSION); 1216 } 1217 1218 fragment.copy (m_output_file, constituent.variables, 9, 1136 1219 &m_FILEPATH, 1137 1220 &m_SUFFIX, … … 1141 1224 &m_NAME, 1142 1225 &m_FULLNAME, 1143 &m_FILESUFFIX); 1226 &m_FILESUFFIX, 1227 &m_FILEEXTENSION); 1144 1228 } 1145 1229 … … 1201 1285 } 1202 1286 1287 //-------------------------------------------------- 1203 1288 ReadmeGenerator::ReadmeGenerator () 1204 1289 { … … 2702 2787 } 2703 2788 2704 2705 2789 //-------------------------------------------------- 2790 2791 PackagesMakefileGenerator::PackagesMakefileGenerator () 2792 { 2793 m_DEPENDENCIES.set ("DEPENDENCIES"); 2794 m_PACKAGEMGRPATH.set ("PACKAGEMGRPATH"); 2795 m_PACKAGEFULLNAME.set ("PACKAGEFULLNAME"); 2796 m_ISLOCAL.set ("ISLOCAL"); 2797 2798 packages_header_fragment.set ("packages_header"); 2799 packages_trailer_fragment.set ("packages_trailer"); 2800 package_fragment.set ("package"); 2801 } 2802 2803 void PackagesMakefileGenerator::reset () 2804 { 2805 CmtGenerator::reset (); 2806 m_DEPENDENCIES = ""; 2807 m_PACKAGEMGRPATH = ""; 2808 m_PACKAGEFULLNAME = ""; 2809 m_ISLOCAL = ""; 2810 2811 packages_header_fragment.reset (); 2812 packages_trailer_fragment.reset (); 2813 package_fragment.reset (); 2814 } 2815 2816 //-------------------------------------------------- 2817 void PackagesMakefileGenerator::build (const cmt_string& package, 2818 const cmt_string& file) 2819 { 2820 reset (); 2821 2822 cmt_string file_name (file); 2823 if (file_name == "") 2824 { 2825 file_name = "packages."; 2826 2827 if (Cmt::build_nmake ()) 2828 { 2829 file_name += "nmake"; 2830 } 2831 else 2832 { 2833 file_name += "make"; 2834 } 2835 } 2836 2837 cmt_string save_file_name = file_name; 2838 save_file_name += "cmtsave"; 2839 2840 if (CmtSystem::test_file (file_name)) 2841 { 2842 rename (file_name, save_file_name); 2843 } 2844 2845 cmt_string new_file_name = file_name; 2846 new_file_name += "new"; 2847 2848 m_output_file = fopen (new_file_name, "wb"); 2849 if (m_output_file != NULL) 2850 { 2851 m_PACKAGE = package; 2852 2853 packages_header_fragment.copy (m_output_file, 1, &m_PACKAGE); 2854 2855 Project* cur = Project::get_current (); 2856 Use::UsePtrVector uses (Use::get_ordered_uses ()); 2857 uses.push_back (&Use::current ()); 2858 cmt_string temp; 2859 for (int i = uses.size () - 1; i >= 0; i--) 2860 { 2861 Use* use = uses[i]; 2862 if (use->discarded) continue; 2863 if (use->m_hidden) continue; 2864 if (!use->located ()) continue; 2865 if (use->get_package ()->is_cmt ()) continue; 2866 2867 if (use->get_project () == cur) 2868 m_ISLOCAL = "is_local"; 2869 else 2870 m_ISLOCAL = "is_not_local"; 2871 2872 temp = use->get_full_path (); 2873 switch (use->style) 2874 { 2875 case cmt_style: 2876 temp += CmtSystem::file_separator (); 2877 temp += "cmt"; 2878 break; 2879 case mgr_style: 2880 temp += CmtSystem::file_separator (); 2881 temp += "mgr"; 2882 break; 2883 } 2884 #ifdef WIN32 2885 temp += " "; 2886 #endif 2887 m_PACKAGEMGRPATH = temp; 2888 // fprintf (m_output_file, "%s\n", temp.c_str()); 2889 2890 temp = ""; 2891 if (Symbol* s = Symbol::find (use->get_package_name () + "_offset")) 2892 { 2893 cmt_string o = s->build_macro_value (); 2894 if (o != "") 2895 { 2896 temp += o; 2897 temp += CmtSystem::file_separator (); 2898 } 2899 } 2900 else 2901 { 2902 CmtMessage::warning 2903 (CmtError::get_error_name (CmtError::symbol_not_found) 2904 + ": macro " + use->get_package_name () + "_offset"); 2905 } 2906 temp += use->get_package_name (); 2907 temp.replace_all (CmtSystem::file_separator (), "_"); 2908 #ifdef WIN32 2909 temp += " "; 2910 #endif 2911 m_PACKAGEFULLNAME = temp; 2912 // fprintf (m_output_file, "%s\n", temp.c_str()); 2913 2914 m_PACKAGE = use->get_package_name (); 2915 2916 Use::UsePtrVector subuses; 2917 for (int i = 0; i < use->sub_uses.size (); i++) 2918 { 2919 if (use->sub_uses[i]->m_index >= 0 && !use->sub_uses[i]->discarded) 2920 { 2921 if (use->sub_uses[i]->m_hidden) continue; 2922 subuses.push_back (use->sub_uses[i]); 2923 } 2924 else 2925 { 2926 Use* au (Use::find_valid (use->sub_uses[i]->get_package_name ())); 2927 if (au) 2928 { 2929 subuses.push_back (au); 2930 } 2931 } 2932 } 2933 m_DEPENDENCIES = ""; 2934 for (int i = 0; i < subuses.size (); i++) 2935 { 2936 if (i != 0) 2937 { 2938 m_DEPENDENCIES += " " + subuses[i]->get_package_name (); 2939 } 2940 else 2941 { 2942 m_DEPENDENCIES += subuses[i]->get_package_name (); 2943 } 2944 } 2945 2946 package_fragment.copy (m_output_file, 5, &m_PACKAGE, &m_DEPENDENCIES, 2947 &m_PACKAGEMGRPATH, &m_PACKAGEFULLNAME, &m_ISLOCAL); 2948 } 2949 2950 if (Symbol* s = Symbol::find ("CMTINSTALLAREA")) 2951 { 2952 cmt_string o = s->build_macro_value (); 2953 Symbol::expand (o); 2954 if (o != "") 2955 { 2956 temp = "CMTINSTALLAREA="; 2957 temp += o; 2958 #ifdef WIN32 2959 temp += " "; 2960 #endif 2961 fprintf (m_output_file, "%s\n", temp.c_str()); 2962 } 2963 } 2964 2965 packages_trailer_fragment.copy (m_output_file, 0); 2966 2967 CmtSystem::close_ostream (m_output_file, new_file_name); 2968 // fclose (m_output_file); 2969 2970 commit (new_file_name); 2971 } 2972 else 2973 { 2974 CmtError::set (CmtError::file_access_error, new_file_name); 2975 } 2976 } 2977 2978 //-------------------------------------------------- 2706 2979 2707 2980 /** … … 2794 3067 }; 2795 3068 3069 //-------------------------------------------------- 3070 void DependencyGenerator::reset () 3071 { 3072 CmtGenerator::reset (); 3073 m_deps_builder.clear (); 3074 m_stamps = true; 3075 m_name = ""; 3076 } 3077 3078 //-------------------------------------------------- 3079 void DependencyGenerator::prepare_includes () 3080 { 3081 cmt_string path; 3082 cmt_string substitution; 3083 3084 Use* use = &Use::current (); 3085 3086 // m_deps_builder.clear (); 3087 3088 if (use->include_path != "none") 3089 { 3090 if (use->include_path == "") 3091 { 3092 m_deps_builder.add (incdir, "$(src)"); 3093 } 3094 else 3095 { 3096 substitution = use->include_path; 3097 3098 path = substitution; 3099 Symbol::expand (path); 3100 3101 CmtSystem::reduce_file_separators (path); 3102 3103 m_deps_builder.add (path, substitution); 3104 } 3105 } 3106 3107 m_deps_builder.add_includes (*use); 3108 3109 Use::UsePtrVector& uses = Use::get_ordered_uses (); 3110 3111 if (uses.size () > 0) 3112 { 3113 int number; 3114 3115 for (number = 0; number < uses.size (); number++) 3116 { 3117 use = uses[number]; 3118 if (use->discarded) continue; 3119 3120 if (use->real_path != "") 3121 { 3122 if (use->include_path != "none") 3123 { 3124 if (use->include_path == "") 3125 { 3126 use->get_full_path (path); 3127 path += CmtSystem::file_separator (); 3128 path += "src"; 3129 3130 substitution = "$("; 3131 substitution += use->prefix; 3132 substitution += "ROOT)"; 3133 substitution += CmtSystem::file_separator (); 3134 substitution += "src"; 3135 substitution += CmtSystem::file_separator (); 3136 } 3137 else 3138 { 3139 substitution = use->include_path; 3140 3141 path = substitution; 3142 Symbol::expand (path); 3143 3144 CmtSystem::reduce_file_separators (path); 3145 } 3146 3147 m_deps_builder.add (path, substitution); 3148 } 3149 3150 m_deps_builder.add_includes (*use); 3151 } 3152 } 3153 } 3154 } 3155 3156 //-------------------------------------------------- 3157 void DependencyGenerator::prepare_header_file_filters () 3158 { 3159 const Use* current_use = &Use::current (); 3160 Use::UsePtrVector uses (Use::get_ordered_uses ()); 3161 uses.push_back (&Use::current ()); 3162 bool current_only (true); 3163 for (int i = uses.size () - 1; i >= 0; i--) 3164 { 3165 const Use* use = uses[i]; 3166 //cerr << "prepare_header_file_filters(0)> " << use->get_package_name () << "[" << use->get_index () << "]\n"; 3167 if (use->discarded) continue; 3168 if (use->m_hidden) continue; 3169 if (!use->located ()) continue; 3170 3171 if (current_only && use != current_use) 3172 current_only = false; 3173 3174 cmt_string package_name = use->get_package_name (); 3175 if (package_name == "CMT") continue; 3176 3177 const Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter"); 3178 if (filter_macro == 0) continue; 3179 3180 const Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp"); 3181 cmt_string stamp; 3182 if (stamp_macro != 0) 3183 { 3184 stamp = stamp_macro->resolve_macro_value (); 3185 } 3186 else 3187 { 3188 use->get_full_path (stamp); 3189 switch (use->style) 3190 { 3191 case cmt_style: 3192 stamp += CmtSystem::file_separator (); 3193 stamp += "cmt"; 3194 break; 3195 case mgr_style: 3196 stamp += CmtSystem::file_separator (); 3197 stamp += "mgr"; 3198 break; 3199 } 3200 stamp += CmtSystem::file_separator (); 3201 stamp += "cmt_header_file.stamp"; 3202 //stamp += "cmt_all_headers.stamp"; 3203 //<package>/cmt/cmt_all_headers.stamp 3204 } 3205 if (!CmtSystem::test_file (stamp)) continue; 3206 3207 //cerr << "0: adding filter: " << use->get_package_name () << "[" << use->get_index () << "]\n"; 3208 cmt_regexp* filter = new cmt_regexp (filter_macro->resolve_macro_value ()); 3209 assert (filter != 0); 3210 3211 m_deps_builder.add_header_filter (use, filter, stamp); 3212 } 3213 3214 if (current_only) 3215 { // we are most likely reading dependencies[_CONSTITUENT].in without CMT 3216 for (int number = 0; number < Symbol::symbol_number (); number++) 3217 { 3218 const Symbol& symbol = Symbol::symbol (number); 3219 if (symbol.type != Symbol::SymbolMacro) continue; 3220 int r = symbol.name.find_last_of ("_header_file_filter"); 3221 if (r == cmt_string::npos || 3222 (r + 19) != symbol.name.size () || 3223 r == 0) continue; 3224 3225 cmt_string package_name = symbol.name.substr(0, r); 3226 const Use* use = Use::find (package_name); 3227 if (use == current_use) continue; 3228 if (0 != use && use->discarded) continue; 3229 if (0 != use && use->m_hidden) continue; 3230 if (0 != use && !use->located ()) continue; 3231 3232 //Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter"); 3233 //if (filter_macro == 0) continue; 3234 3235 const Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp"); 3236 cmt_string stamp; 3237 if (stamp_macro != 0) 3238 { 3239 stamp = stamp_macro->resolve_macro_value (); 3240 } 3241 else if (0 != use) 3242 { 3243 use->get_full_path (stamp); 3244 switch (use->style) 3245 { 3246 case cmt_style: 3247 stamp += CmtSystem::file_separator (); 3248 stamp += "cmt"; 3249 break; 3250 case mgr_style: 3251 stamp += CmtSystem::file_separator (); 3252 stamp += "mgr"; 3253 break; 3254 } 3255 stamp += CmtSystem::file_separator (); 3256 stamp += "cmt_header_file.stamp"; 3257 } 3258 if (!CmtSystem::test_file (stamp)) continue; 3259 3260 //cerr << "1: adding filter: " << package_name << "\n"; 3261 cmt_regexp* filter = new cmt_regexp (symbol.resolve_macro_value ()); 3262 assert (filter != 0); 3263 3264 m_deps_builder.add_header_filter (use, filter, stamp); 3265 } 3266 } 3267 } 3268 3269 //-------------------------------------------------- 2796 3270 void DependencyGenerator::build (const CmtSystem::cmt_string_vector& arguments) 2797 3271 { 2798 3272 reset (); 2799 prepare_use_context ();2800 2801 prepare_header_file_filters ();2802 2803 const cmt_string& name = arguments[0];2804 2805 m_constituent = Constituent::find (name);2806 if (m_constituent == 0)2807 {2808 // Error : wrong constituent name...2809 return;2810 }2811 2812 const Constituent& constituent = *m_constituent;2813 2814 cmt_string file_name;2815 cmt_string full_name;2816 cmt_string compressed_name;2817 // cmt_string suffix;2818 cmt_string dependencies;2819 3273 2820 3274 // 2821 // Scan the sources.3275 // Parse arguments first 2822 3276 // 2823 2824 // 2825 // We have to rebuild the dependencies for : 2826 // 2827 // o all sources if the parameter -all_sources has been received 2828 // o otherwise, 2829 // + all source names provided in the argument list (if any) 2830 // + all source names missing from the existing dependency file (if any) 2831 // 2832 2833 const CmtSystem::cmt_string_vector& sources = constituent.modules; 2834 const cmt_vector<cmt_regexp>& excludes = constituent.exclude_exprs; 2835 const cmt_vector<cmt_regexp>& selects = constituent.select_exprs; 2836 2837 m_stamps = true; 3277 CmtSystem::cmt_string_vector cli_input, all; 2838 3278 bool all_sources = false; 2839 2840 int source_number = arguments.size (); 2841 int i; 2842 2843 //cerr << "source_number=" << source_number << endl; 2844 2845 for (i = source_number-1; i >= 0; i--) 2846 { 2847 file_name = arguments[i]; 2848 2849 //cerr << "file_name=" << file_name << endl; 2850 2851 // Get rid of files that may come from the makefile fragment 2852 if (file_name.find ("requirements") != cmt_string::npos) source_number--; 2853 else if (file_name.substr (0, 5) == "-out=" || 2854 file_name.substr (0, 5) == "-out:" || 2855 file_name.substr (0, 5) == "/out:" || 2856 file_name.substr (0, 5) == "/out=") 2857 { 2858 source_number--; 3279 bool config_files (false); 3280 bool start_all (false); 3281 3282 for (int i = 0; i < arguments.size (); i++) 3283 { 3284 cmt_string file_name = arguments[i]; 3285 3286 //cerr << "i: " << i << " file_name=" << file_name << endl; 3287 3288 if (file_name.substr (0, 5) == "-out=" || 3289 file_name.substr (0, 5) == "-out:" || 3290 file_name.substr (0, 5) == "/out:" || 3291 file_name.substr (0, 5) == "/out=") 3292 { 2859 3293 file_name.erase (0, 5); 2860 3294 m_output_file_name = file_name; 2861 3295 } 2862 else if (file_name.find (".make") != cmt_string::npos) source_number--;2863 3296 else if (file_name == "-all_sources" || 2864 3297 file_name == "/all_sources") 2865 3298 { 2866 source_number = sources.size ();2867 3299 all_sources = true; 2868 3300 } … … 2870 3302 file_name == "/no_stamps") 2871 3303 { 2872 source_number--;2873 3304 m_stamps = false; 2874 3305 } 2875 } 3306 else if (file_name.substr (0, 2) == "-I" || 3307 file_name.substr (0, 2) == "/I") 3308 { 3309 file_name.erase (0, 2); 3310 //cerr << "include: " << file_name << endl; 3311 m_deps_builder.add (file_name, file_name); 3312 } 3313 else if (file_name == "-start_all" || 3314 file_name == "/start_all") 3315 { 3316 if (start_all) 3317 { 3318 CmtError::set(CmtError::syntax_error, 3319 "Unexpected option " + file_name); 3320 return; 3321 } 3322 start_all = true; 3323 } 3324 else if (file_name == "-end_all" || 3325 file_name == "/end_all") 3326 { 3327 if (!start_all) 3328 { 3329 CmtMessage::warning 3330 (CmtError::get_error_name (CmtError::syntax_error) 3331 + ": Unexpected option " + file_name); 3332 } 3333 start_all = false; 3334 } 3335 else if (file_name.substr (0, 1) == "-" 3336 #ifdef WIN32 3337 || file_name.substr (0, 1) == "/" 3338 #endif 3339 ) 3340 { 3341 if (CmtMessage::active (Verbose)) 3342 CmtMessage::warning 3343 (CmtError::get_error_name (CmtError::warning) 3344 + ": Unknown option " + file_name); 3345 } 3346 else if (file_name.substr (file_name.size () - 12) == "requirements" || 3347 file_name.substr (file_name.size () - 5) == ".make" || 3348 file_name.substr (file_name.size () - 3) == ".mk" || 3349 file_name.substr (file_name.size () - 6) == ".nmake" || 3350 file_name.substr (file_name.size () - 3) == ".in" || 3351 file_name.substr (file_name.size () - 6) == ".stamp") 3352 { 3353 // Configuration changed, 3354 // want to rebuild dependencies from scratch 3355 if (!config_files) config_files = true; 3356 if (!all_sources) all_sources = true; 3357 } 3358 else if (start_all) 3359 { 3360 all.push_back (file_name); 3361 } 3362 else if (m_name.size () != 0) 3363 { 3364 cli_input.push_back (file_name); 3365 } 3366 else 3367 { 3368 if (file_name.size () != 0) 3369 m_name = file_name; 3370 } 3371 } 3372 3373 if (start_all) 3374 CmtMessage::warning 3375 (CmtError::get_error_name (CmtError::syntax_error) 3376 + ": Missing option -end_all"); 3377 3378 //cerr << "m_name: " << m_name << endl; 3379 if (m_name.size () == 0) 3380 { 3381 CmtError::set(CmtError::syntax_error, 3382 "Name missing as first argument"); 3383 return; 3384 } 3385 3386 //cerr << "config_files: " << config_files << endl; 3387 3388 m_constituent = Constituent::find (m_name); 3389 3390 if (!config_files && 0 == cli_input.size () && 3391 0 == all.size () && 0 == m_constituent) 3392 { 3393 CmtError::set(CmtError::syntax_error, 3394 m_name + ": Files arguments missing"); 3395 return; 3396 } 3397 /* 3398 cerr << "cli_input:"; 3399 for (int i = 0; i < cli_input.size (); i++) 3400 cerr << " " << cli_input[i]; 3401 cerr << "\n"; 3402 3403 cerr << "all:"; 3404 for (int i = 0; i < all.size (); i++) 3405 cerr << " " << all[i]; 3406 cerr << "\n"; 3407 */ 3408 prepare_includes (); 3409 prepare_header_file_filters (); 2876 3410 2877 3411 // … … 2922 3456 { 2923 3457 m_output_file_name = m_bin; 2924 m_output_file_name += name;3458 m_output_file_name += m_name; 2925 3459 m_output_file_name += "_"; 2926 3460 m_output_file_name += "dependencies."; … … 2935 3469 } 2936 3470 2937 if (all_sources) 2938 { 2939 for (i = 0; i < sources.size (); i++) 2940 { 2941 file_name = sources[i]; 2942 2943 set_full_name (full_name, file_name); 2944 if (full_name == "") continue; 2945 2946 CmtSystem::compress_path (full_name, compressed_name); 2947 full_name = compressed_name; 2948 2949 static CmtSystem::cmt_string_vector files; 2950 2951 get_all_files (full_name, excludes, selects, files); 2952 2953 for (int j = 0; j < files.size (); j++) 2954 { 2955 const cmt_string& name = files[j]; 2956 2957 if (name != "") 2958 { 2959 const cmt_string& line = build (name); 2960 2961 add_line_to_text (line, dependencies); 2962 } 2963 } 2964 } 2965 } 2966 else 2967 { 2968 // 2969 // New read the existing dependency file if any and filter it to 2970 // extract the source names 2971 // 2972 static DependencyFilter filter; 2973 dependencies.read (m_output_file_name); 2974 filter.run (dependencies); 2975 2976 for (i = 1; i < source_number; i++) 2977 { 2978 file_name = arguments[i]; 2979 2980 set_full_name (full_name, file_name); 2981 if (full_name == "") continue; 2982 2983 CmtSystem::compress_path (full_name, compressed_name); 2984 full_name = compressed_name; 2985 2986 const cmt_string& line = build (full_name); 2987 2988 add_line_to_text (line, dependencies); 2989 2990 filter.add_source (full_name); 2991 2992 } 2993 2994 // Now : are there still any missing source file in dependencies?? 2995 2996 for (i = 0; i < sources.size (); i++) 2997 { 2998 file_name = sources[i]; 2999 3000 set_full_name (full_name, file_name); 3001 if (full_name == "") continue; 3002 3003 CmtSystem::compress_path (full_name, compressed_name); 3004 full_name = compressed_name; 3005 3006 static CmtSystem::cmt_string_vector files; 3007 3008 get_all_files (full_name, excludes, selects, files); 3009 3010 for (int j = 0; j < files.size (); j++) 3011 { 3012 const cmt_string& name = files[j]; 3013 if (name != "") 3014 { 3015 if (!filter.has_source (name)) 3016 { 3017 const cmt_string& line = build (name); 3018 3019 add_line_to_text (line, dependencies); 3020 } 3021 } 3022 } 3023 } 3024 } 3471 //------------------------------------------------------------------------------- 3472 // 3473 // For Makefile, we need to select, from cli_input, source files only, 3474 // there may be dependencies of source files (typically, header files) as well 3475 // 3476 cmt_string dependencies; 3477 if (!all_sources) 3478 { 3479 // want to validate cli_input against 3480 // either 3481 // o all cli sources 3482 // or 3483 // o m_constituent sources 3484 set_source_files (all); 3485 if (0 == validate (cli_input)) 3486 { 3487 // cli_input contains source files ONLY 3488 // calculate dependencies for them ONLY 3489 if (CmtSystem::test_file (m_output_file_name)) 3490 { 3491 if (!dependencies.read (m_output_file_name)) 3492 { 3493 CmtError::set (CmtError::file_access_error, m_output_file_name); 3494 return; 3495 } 3496 } 3497 fill_dependencies (dependencies, cli_input); 3498 } 3499 else 3500 { 3501 all_sources = true; 3502 // calculate dependencies for 3503 // all cli sources 3504 // or 3505 // m_constituent sources 3506 fill_dependencies (dependencies); 3507 } 3508 /* 3509 if (0 != all.size ()) 3510 { 3511 // o all cli sources 3512 int n_invalid = 0; 3513 for (int i = 0; i < cli_input.size (); i++) 3514 { 3515 bool valid = false; 3516 for (int j = 0; j < all.size (); j++) 3517 if (cli_input[i] == all[j]) 3518 { 3519 valid = true; 3520 break; 3521 } 3522 if (!valid) 3523 { 3524 n_invalid += 1; 3525 break; 3526 } 3527 } 3528 if (0 == n_invalid) 3529 { 3530 // cli_input contains source files ONLY 3531 // calculate dependencies for them ONLY 3532 if (CmtSystem::test_file (m_output_file_name)) 3533 { 3534 if (!dependencies.read (m_output_file_name)) 3535 { 3536 CmtError::set (CmtError::file_access_error, m_output_file_name); 3537 return; 3538 } 3539 } 3540 fill_dependencies (dependencies, cli_input); 3541 } 3542 else 3543 { 3544 all_sources = true; 3545 // calculate dependencies for all (all cli sources) 3546 fill_dependencies (dependencies, all); 3547 } 3548 } 3549 else // 0 == all.size () 3550 { 3551 // set_source_files (); 3552 if (int n = set_source_files ()) 3553 // if (0 != m_source_files.size ()) 3554 { 3555 // o m_constituent sources 3556 int n_invalid = 0; 3557 for (int i = 0; i < cli_input.size (); i++) 3558 { 3559 bool valid = false; 3560 for (int j = 0; j < n; j++) 3561 if (cli_input[i] == m_source_files[j].name ()) 3562 { 3563 valid = true; 3564 break; 3565 } 3566 if (!valid) 3567 { 3568 n_invalid += 1; 3569 break; 3570 } 3571 } 3572 if (0 == n_invalid) 3573 { 3574 // cli_input contains source files ONLY 3575 // calculate dependencies for them ONLY 3576 if (CmtSystem::test_file (m_output_file_name)) 3577 { 3578 if (!dependencies.read (m_output_file_name)) 3579 { 3580 CmtError::set (CmtError::file_access_error, m_output_file_name); 3581 return; 3582 } 3583 } 3584 fill_dependencies (dependencies, cli_input); 3585 } 3586 else 3587 { 3588 all_sources = true; 3589 // calculate dependencies for m_source_files 3590 // (m_constituent sources) 3591 fill_dependencies (dependencies); 3592 } 3593 } 3594 else // 0 == m_source_files.size ()) 3595 { 3596 // no source files to validate against 3597 fill_dependencies (dependencies, cli_input); 3598 } 3599 } 3600 */ 3601 } 3602 else // all_sources = true 3603 { 3604 if (int n = set_source_files (all)) 3605 { 3606 // calculate dependencies for m_source_files 3607 // either 3608 // o all cli sources 3609 // or 3610 // o m_constituent sources 3611 // if any existing 3612 fill_dependencies (dependencies); 3613 } 3614 else 3615 { 3616 // calculate dependencies for all we have 3617 fill_dependencies (dependencies, cli_input); 3618 } 3619 /* 3620 if (0 != all.size ()) 3621 { 3622 // calculate dependencies for all (all cli sources) 3623 fill_dependencies (dependencies, all); 3624 } 3625 else 3626 { 3627 if (int n = set_source_files ()) 3628 { 3629 // calculate dependencies for m_source_files (m_constituent sources) 3630 fill_dependencies (dependencies); 3631 } 3632 else 3633 { 3634 // calculate dependencies for all we have 3635 fill_dependencies (dependencies, cli_input); 3636 } 3637 } 3638 */ 3639 } 3640 3641 if (CmtError::has_pending_error ()) 3642 { 3643 if (CmtError::get_last_error_code () == CmtError::path_not_found || 3644 CmtError::get_last_error_code () == CmtError::file_access_error || 3645 CmtError::get_last_error_code () == CmtError::execution_failed) 3646 return; 3647 } 3648 //------------------------------------------------------------------------------- 3025 3649 3026 3650 FILE* f = fopen (m_output_file_name.c_str (), "wb"); … … 3030 3654 dependencies.write (f); 3031 3655 CmtSystem::close_ostream (f, m_output_file_name); 3032 // fclose (f);3033 3656 } 3034 3657 else 3035 3658 { 3036 3659 CmtError::set (CmtError::file_access_error, m_output_file_name); 3037 // CmtMessage::error ("Cannot open " + m_output_file_name + " for write");3038 3660 } 3039 3661 … … 3043 3665 //-------------------------------------------------- 3044 3666 // o text contains lines with a pattern like : 3045 // key = xxxxx 3046 // 3667 // key = value 3047 3668 // o line follows the same pattern 3048 3669 // 3049 // This function appends <line> to <text> only if the key found in 3050 // <line> is not found in <text> 3670 // This function 3671 // o if the key found in <line> is found in <text>, removes the first line in <text> with the key, if any 3672 // o appends <line> to <text> 3051 3673 //-------------------------------------------------- 3052 void DependencyGenerator::add_line_to_text (const cmt_string& line, cmt_string& text) 3674 void DependencyGenerator::add_line_to_text (const cmt_string& line, cmt_string& text) const 3053 3675 { 3054 3676 static const cmt_string empty; … … 3091 3713 } 3092 3714 3715 //-------------------------------------------------- 3093 3716 cmt_string DependencyGenerator::build (const cmt_string& file_name) 3094 3717 { 3095 3718 Log; 3096 3719 3097 const Constituent& constituent = *m_constituent;3720 // const Constituent& constituent = *m_constituent; 3098 3721 3099 3722 static cmt_string full_name; … … 3105 3728 line = ""; 3106 3729 3730 /* 3107 3731 if (!CmtSystem::absolute_path (file_name)) 3108 3732 { 3109 3733 full_name = srcdir; 3110 3734 } 3735 */ 3111 3736 3112 3737 full_name += file_name; … … 3116 3741 CmtSystem::get_suffix (full_name, suffix); 3117 3742 3118 if (name == "requirements") return (line); 3119 3120 const CmtSystem::cmt_string_vector& deps = m_deps_builder.run (full_name); 3743 // if (name == "requirements") return (line); 3744 3745 const CmtSystem::cmt_string_vector& deps = m_deps_builder.run (full_name, m_name); 3746 if (CmtError::has_pending_error ()) 3747 { 3748 return line; 3749 } 3750 // CmtError::set (CmtError::execution_failed, preprocessor, status); 3751 // CmtError::set (CmtError::file_access_error, header_file_path); 3752 // CmtError::set (CmtError::path_not_found, name); 3121 3753 3122 3754 line = name; … … 3157 3789 if (m_stamps) 3158 3790 { 3159 cmt_string stamp_output_base = constituent.name; 3791 cmt_string stamp_output_base = m_name; 3792 // cmt_string stamp_output_base = constituent.name; 3160 3793 stamp_output_base += "_deps"; 3161 3794 … … 3165 3798 if (!CmtSystem::mkdir (stamp_output)) 3166 3799 { 3167 CmtMessage::error ("Cannot create the binary output directory for this constituent " + stamp_output); 3168 // cerr << "Cannot create the binary output directory for this constituent" << endl; 3800 CmtError::set (CmtError::file_access_error, 3801 + "Cannot create directory " + stamp_output 3802 + " for " + m_name); 3803 return line; 3169 3804 } 3170 3805 … … 3185 3820 if (CmtSystem::test_file (stamp_output)) 3186 3821 { 3187 old_stamp.read (stamp_output); 3188 } 3189 3190 if (line != old_stamp) 3191 { 3192 line.write (stamp_output); 3822 if (!old_stamp.read (stamp_output)) 3823 { 3824 CmtError::set (CmtError::file_access_error, stamp_output); 3825 return line; 3826 } 3827 // old_stamp.read (stamp_output); 3828 } 3829 3830 if (line != old_stamp.substr(0, old_stamp.size () - 1)) 3831 { 3832 if (!(line + "\n").write (stamp_output)) 3833 { 3834 CmtError::set (CmtError::file_access_error, stamp_output); 3835 return line; 3836 } 3837 // (line + "\n").write (stamp_output); 3193 3838 } 3194 3839 } … … 3198 3843 3199 3844 //-------------------------------------------------- 3200 void DependencyGenerator::prepare_header_file_filters () 3201 { 3202 // Use::UsePtrVector& uses = Use::get_ordered_uses (); 3203 Use::UsePtrVector uses (Use::get_ordered_uses ()); 3204 uses.push_back (&Use::current ()); 3205 for (int i = uses.size () - 1; i >= 0; i--) 3206 { 3207 Use* use = uses[i]; 3208 if (use->discarded) continue; 3209 if (use->m_hidden) continue; 3210 if (!use->located ()) continue; 3211 3212 cmt_string package_name = use->get_package_name (); 3213 if (package_name == "CMT") continue; 3214 3215 Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter"); 3216 if (filter_macro == 0) continue; 3217 3218 Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp"); 3219 cmt_string stamp; 3220 if (stamp_macro != 0) 3221 { 3222 stamp = stamp_macro->resolve_macro_value (); 3223 } 3224 else 3225 { 3226 use->get_full_path (stamp); 3227 stamp += CmtSystem::file_separator (); 3228 if (use->style == mgr_style) stamp += "mgr"; 3229 else stamp += "cmt"; 3230 stamp += CmtSystem::file_separator (); 3231 stamp += "cmt_header_file.stamp"; 3232 //stamp += "cmt_all_headers.stamp"; 3233 //<package>/cmt/cmt_all_headers.stamp 3234 } 3235 if (!CmtSystem::test_file (stamp)) continue; 3236 3237 cmt_regexp* filter = new cmt_regexp (filter_macro->resolve_macro_value ()); 3238 assert (filter != 0); 3239 3240 m_deps_builder.add_header_filter (use, filter, stamp); 3241 } 3242 } 3845 int DependencyGenerator::fill_dependencies (cmt_string& dependencies) 3846 { 3847 CmtSystem::cmt_string_vector sources; 3848 for (int i = 0; i < m_source_files.size (); i++) 3849 { 3850 const SourceFile& file = m_source_files[i]; 3851 sources.push_back (file.name ()); 3852 } 3853 return fill_dependencies (dependencies, sources); 3854 } 3855 3856 //-------------------------------------------------- 3857 int DependencyGenerator::fill_dependencies (cmt_string& dependencies, 3858 const CmtSystem::cmt_string_vector& sources) 3859 { 3860 int retval (0); 3861 cmt_string file_name; 3862 cmt_string compressed_name; 3863 3864 for (int i = 0; i < sources.size (); i++) 3865 { 3866 file_name = sources[i]; 3867 //set_full_name (full_name, file_name); 3868 CmtSystem::reduce_file_separators (file_name); 3869 if (file_name == "") continue; 3870 CmtSystem::compress_path (file_name, compressed_name); 3871 file_name = compressed_name; 3872 //cerr << "file_name: " << file_name << endl; 3873 if (file_name == "") continue; 3874 3875 const cmt_string& line = build (file_name); 3876 if (CmtError::has_pending_error ()) 3877 { 3878 // if (CmtError::get_last_error_code () == CmtError::file_access_error) 3879 return -1; 3880 } 3881 3882 //cerr << "line: " << line << endl; 3883 add_line_to_text (line, dependencies); 3884 //cerr << "dependencies: " << dependencies << endl; 3885 } 3886 3887 return retval; 3888 } 3889 3890 //-------------------------------------------------- 3891 int DependencyGenerator::set_source_files (const CmtSystem::cmt_string_vector& files) 3892 { 3893 m_source_files.clear (); 3894 3895 for (int j = 0; j < files.size (); j++) 3896 { 3897 const cmt_string& name = files[j]; 3898 if (name == "") continue; 3899 3900 bool included = false; 3901 for (int k = m_source_files.size () - 1; k >= 0; k--) 3902 if (m_source_files[k].name () == name) 3903 { 3904 included = true; 3905 break; 3906 } 3907 if (included) continue; 3908 3909 SourceFile& source = m_source_files.add (); 3910 source.set (name, Language::null (), ""); 3911 } 3912 3913 if (m_source_files.size ()) return m_source_files.size (); 3914 else return set_source_files (); 3915 } 3916 3917 //-------------------------------------------------- 3918 int DependencyGenerator::set_source_files () 3919 { 3920 if (0 == m_constituent && 0 != m_name.size ()) 3921 m_constituent = Constituent::find (m_name); 3922 if (0 == m_constituent) return 0; 3923 3924 m_source_files.clear (); 3925 3926 const CmtSystem::cmt_string_vector& sources = m_constituent->modules; 3927 const cmt_vector<cmt_regexp>& excludes = m_constituent->exclude_exprs; 3928 const cmt_vector<cmt_regexp>& selects = m_constituent->select_exprs; 3929 3930 cmt_string file_name, full_name; 3931 cmt_string compressed_name; 3932 cmt_string visited, token; 3933 3934 for (int i = 0; i < sources.size (); i++) 3935 { 3936 file_name = sources[i]; 3937 set_full_name (full_name, file_name); 3938 if (full_name == "") continue; 3939 3940 CmtSystem::compress_path (full_name, compressed_name); 3941 full_name = compressed_name; 3942 3943 static CmtSystem::cmt_string_vector files; 3944 3945 get_all_files (full_name, excludes, selects, files); 3946 3947 for (int j = 0; j < files.size (); j++) 3948 { 3949 const cmt_string& name = files[j]; 3950 3951 if (name == "") continue; 3952 3953 cmt_string suffix; 3954 CmtSystem::get_suffix (name, suffix); 3955 Language& language = Language::find_with_suffix (suffix); 3956 3957 if ((m_constituent->type == Application || m_constituent->type == Library) 3958 && language != Language::null () && language.native_dependencies ()) 3959 continue; 3960 3961 bool included = false; 3962 for (int k = m_source_files.size () - 1; k >= 0; k--) 3963 if (m_source_files[k].name () == name) 3964 { 3965 included = true; 3966 break; 3967 } 3968 if (included) continue; 3969 3970 SourceFile& source = m_source_files.add (); 3971 source.set (name, language, ""); 3972 } 3973 } 3974 return m_source_files.size (); 3975 } 3976 3977 //-------------------------------------------------- 3978 /** 3979 * Returns 0, if each file in files is found in m_source_files, 3980 * otherwise returns 1 3981 */ 3982 //-------------------------------------------------- 3983 int DependencyGenerator::validate (const CmtSystem::cmt_string_vector& files) const 3984 { 3985 int n_invalid = 0; 3986 for (int i = 0; i < files.size (); i++) 3987 { 3988 bool valid = false; 3989 for (int j = 0; j < m_source_files.size (); j++) 3990 if (files[i] == m_source_files[j].name ()) 3991 { 3992 valid = true; 3993 break; 3994 } 3995 if (!valid) 3996 { 3997 n_invalid += 1; 3998 break; 3999 } 4000 } 4001 4002 return n_invalid; 4003 } -
CMT/HEAD/source/cmt_generators.h
r561 r588 11 11 #include "cmt_fragment.h" 12 12 #include "cmt_generator.h" 13 #include "cmt_deps_builder.h" 13 14 14 15 class AnyDocumentGenerator : public CmtGenerator … … 36 37 void build (const cmt_string& package, 37 38 const Constituent& constituent, 39 bool& dependencies, 38 40 const cmt_string& file = ""); 41 // returned bool& value indicates whether dependencies_fragment added to makefile 39 42 40 43 private: … … 44 47 const cmt_string& output_suffix); 45 48 49 Variable m_FILEEXTENSION; 50 46 51 FragmentHandle document_header_fragment; 52 FragmentHandle dependency_fragment; 47 53 }; 48 54 … … 53 59 void build (const cmt_string& package, 54 60 const Constituent& constituent, 61 bool& dependencies, 55 62 const cmt_string& file = ""); 63 // returned bool& value indicates whether dependencies_fragment added to makefile 56 64 57 65 protected: … … 63 71 void prepare_proto_file (const cmt_string& file); 64 72 void module_file_action (SourceFile& file, const Constituent& constituent); 73 void fill_names_outputs (); 65 74 66 75 FragmentHandle library_header_fragment; … … 214 223 }; 215 224 225 class PackagesMakefileGenerator : public CmtGenerator 226 { 227 public: 228 PackagesMakefileGenerator (); 229 void build (const cmt_string& package, 230 const cmt_string& file); 231 // const CmtSystem::cmt_string_vector& arguments); 232 233 private: 234 void reset (); 235 236 Variable m_DEPENDENCIES; 237 Variable m_PACKAGEMGRPATH; 238 Variable m_PACKAGEFULLNAME; 239 Variable m_ISLOCAL; 240 241 FragmentHandle packages_header_fragment; 242 FragmentHandle packages_trailer_fragment; 243 FragmentHandle package_fragment; 244 }; 245 216 246 class DependencyGenerator : public CmtGenerator 217 247 { 218 248 public: 219 249 void build (const CmtSystem::cmt_string_vector& arguments); 250 void prepare_includes (); 220 251 void prepare_header_file_filters (); 221 222 private: 223 void add_line_to_text (const cmt_string& line, cmt_string& text); 252 void reset (); 253 254 protected: 255 int set_source_files (); 256 int set_source_files (const CmtSystem::cmt_string_vector& files); 257 int validate (const CmtSystem::cmt_string_vector& files) const; 258 259 private: 260 void add_line_to_text (const cmt_string& line, cmt_string& text) const; 224 261 cmt_string build (const cmt_string& file_name); 262 int fill_dependencies (cmt_string& dependencies, 263 const CmtSystem::cmt_string_vector& source); 264 int fill_dependencies (cmt_string& dependencies); 265 DepsBuilder m_deps_builder; 225 266 bool m_stamps; 267 cmt_string m_name; 226 268 }; 227 269 -
CMT/HEAD/source/cmt_parser.cxx
r575 r588 1888 1888 Cmt::reset_all_sets_done (); 1889 1889 Symbol::all_set (); 1890 if (CmtSystem::testenv ("CMTBCAST")) 1891 CmtSystem::putenv ("CMTBCAST", ""); 1890 1892 1891 1893 for (i = 0; i < uses.size (); i++) … … 2125 2127 return; 2126 2128 } 2127 Generator::build_constituent_makefile (*constituent, out); 2129 bool dependencies (false); 2130 Generator::build_constituent_makefile (*constituent, dependencies, out); 2128 2131 // if (ap.arguments.size () > 0) 2129 2132 // { … … 2167 2170 return; 2168 2171 } 2169 Generator::build_constituent_makefile (*constituent, out); 2170 if (!constituent->has_target_tag) return; 2172 if (!constituent->has_target_tag) 2173 { 2174 bool dependencies (false); 2175 Generator::build_constituent_makefile (*constituent, dependencies, out); 2176 return; 2177 } 2171 2178 // cerr << "constituent: " << name << endl; 2172 2179 … … 2266 2273 } 2267 2274 } 2275 2276 int retval (0); 2277 2278 bool dependencies (false); 2279 Generator::build_constituent_makefile (*constituent, dependencies, out); 2280 2281 if (dependencies) 2282 retval = Generator::build_dependencies_infile (constituent, outdir/*, usecmt*/); 2268 2283 } 2269 2284 … … 2300 2315 return; 2301 2316 } 2317 do_check_configuration (ap); 2318 if (CmtError::get_last_error_code () == CmtError::configuration_error) 2319 return; 2320 2302 2321 set_standard_macros (); 2303 2322 … … 2415 2434 } 2416 2435 2436 int retval (0); 2437 2417 2438 Generator::build_constituents_makefile (Me.m_current_package, out); 2418 2439 // Generator::build_constituents_makefile (Me.m_current_package, ap.arguments); 2419 2440 2441 retval = Generator::build_library_links_infile (outdir); 2442 if (0 != retval) return; 2443 2420 2444 const Constituent::ConstituentVector& constituents = 2421 2445 Constituent::constituents (); 2446 bool deps (false); 2422 2447 for (int n = 0; n < constituents.size (); n++) 2423 2448 { 2424 2449 const Constituent& constituent = constituents[n]; 2425 2450 if (constituent.has_target_tag) continue; 2426 Generator::build_constituent_infile (constituent, outdir, usecmt); 2427 } 2451 2452 retval = Generator::build_constituent_infile (constituent, outdir, usecmt); 2453 if (0 != retval) return; 2454 2455 if (!deps) 2456 if (constituent.type == Application || 2457 constituent.type == Library || 2458 (constituent.type == Document && 2459 FragmentHandle (constituent.generator).need_dependencies ())) 2460 { 2461 deps = true; 2462 } 2463 } 2464 2465 if (deps) 2466 retval = Generator::build_dependencies_infile (0, outdir, usecmt); 2467 } 2468 2469 //---------------------------------------------------------- 2470 void Cmt::do_build_broadcast_config (const ArgParser& ap) 2471 { 2472 if (CmtLock::check () == CmtLock::locked_by_another_user) 2473 { 2474 CmtError::set (CmtError::conflicting_lock, "build_broadcast_config>"); 2475 return; 2476 } 2477 set_standard_macros (); 2478 2479 cmt_string out, outdir, name ("broadcast"); 2480 for (int i = 0; i < ap.arguments.size (); i++) 2481 { 2482 const cmt_string& arg = ap.arguments[i]; 2483 if (arg.substr (0, 5) == "-out=") 2484 { 2485 arg.substr (5, out); 2486 CmtSystem::dirname (out, outdir); 2487 CmtSystem::name (out, name); 2488 } 2489 } 2490 2491 cmt_string tag; 2492 { 2493 Symbol* macro = Symbol::find ("tag"); 2494 if (macro != 0) 2495 { 2496 tag = macro->build_macro_value (); 2497 Symbol::expand (tag); 2498 } 2499 } 2500 cmt_string file (tag + "_" + name); 2501 // cmt_string file (tag + "_uses"); 2502 if (Cmt::build_nmake ()) 2503 file += ".nmake"; 2504 else 2505 file += ".make"; 2506 if (outdir != "") 2507 { 2508 if (outdir [outdir.size () - 1] != CmtSystem::file_separator ()) 2509 outdir += CmtSystem::file_separator (); 2510 file = outdir + file; 2511 } 2512 2513 ofstream t (file); 2514 if (!t) 2515 { 2516 CmtError::set (CmtError::file_access_error, file); 2517 return; 2518 } 2519 t.exceptions (ios::failbit | ios::badbit); 2520 try 2521 { 2522 // Symbol* symbol = Symbol::find ("use_requirements"); 2523 // if (symbol != 0) 2524 // symbol->show_macro (Make, t); 2525 const cmt_string pattern = "^use_requirements$|.*_root$"; 2526 print_macros (Make, pattern, t); 2527 t.close (); // ios_base::failbit 2528 } 2529 catch (const ios::failure& e) 2530 { 2531 CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ())); 2532 } 2533 2534 Generator::build_packages_makefile (Me.m_current_package, out); 2535 // Generator::build_uses_makefile (Me.m_current_package, out); 2428 2536 } 2429 2537 … … 2468 2576 { 2469 2577 Symbol* macro = Symbol::find ("shlibsuffix"); 2470 if (macro == 0) return; 2578 if (macro == 0) 2579 { 2580 if (strlen (ap.extra_file.c_str ()) == 0) 2581 { 2582 CmtError::set(CmtError::configuration_error, "shlibsuffix undefined"); 2583 } 2584 else 2585 { // we are most likely reading empty library_links.in without CMT 2586 if (CmtMessage::active (Verbose)) 2587 CmtMessage::warning 2588 (CmtError::get_error_name (CmtError::configuration_error) 2589 + ": shlibsuffix undefined"); 2590 } 2591 return; 2592 } 2471 2593 shlibsuffix = macro->build_macro_value (); 2472 2594 Symbol::expand (shlibsuffix); … … 2716 2838 if (action_setup != get_action () && 2717 2839 none_style != use.style && 2718 0 == Project::find_in_cmt_paths (use.real_path).size ()) 2840 0 == Project::get_current ()) 2841 // 0 == Project::find_in_cmt_paths (use.real_path).size ()) 2719 2842 { 2720 if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () && 2721 0 == CmtSystem::getenv ("PEDANTIC").size ()) 2722 CmtMessage::warning 2723 (CmtError::get_error_name (CmtError::configuration_error) 2724 + ": Current use outside CMTPATH: " + use.get_info ()); 2725 else 2726 CmtError::set(CmtError::configuration_error, 2727 "Current use outside CMTPATH: " + use.get_info ()); 2843 bool use_cmtpath_pattern (false); 2844 static CmtPathPattern::CmtPathPatternVector& CmtPathPatterns = CmtPathPattern::patterns (); 2845 for (int i = 0; i < CmtPathPatterns.size (); i++) 2846 { 2847 CmtPathPattern& p = CmtPathPatterns[i]; 2848 if (p.use->get_package ()->is_cmt () || p.is_constant ()) continue; 2849 use_cmtpath_pattern = true; 2850 break; 2851 } 2852 if (use_cmtpath_pattern) 2853 // non-constant cmtpath_pattern found that 2854 // cannot be applied for package outside CMTPATH 2855 { 2856 if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () && 2857 0 == CmtSystem::getenv ("PEDANTIC").size ()) 2858 CmtMessage::warning 2859 (CmtError::get_error_name (CmtError::configuration_error) 2860 + ": Package outside CMTPATH: " + use.get_info ()); 2861 else 2862 CmtError::set(CmtError::configuration_error, 2863 "Package outside CMTPATH: " + use.get_info ()); 2864 } 2728 2865 } 2729 2866 } … … 2737 2874 static CmtSystem::cmt_string_vector tags; 2738 2875 2739 CmtSystem::split (Me.m_extra_tags, " \t,", tags); 2876 if (action_build_constituents_config != get_action ()) 2877 CmtSystem::split (Me.m_extra_tags, " \t,", tags); 2740 2878 2741 2879 for (int i = 0; i < tags.size (); i++) … … 3848 3986 uses.push_back (&Use::current ()); 3849 3987 int i; 3988 cmt_string cmtinstallarea = ""; 3989 cmt_string tag = ""; 3850 3990 cmt_string shlibsuffix; 3851 cmt_string symunlink ;3991 cmt_string symunlinkcmd; 3852 3992 3853 3993 { 3854 3994 Symbol* macro = Symbol::find ("shlibsuffix"); 3855 if (macro == 0) return; 3995 if (macro == 0) 3996 { 3997 if (strlen (ap.extra_file.c_str ()) == 0) 3998 { 3999 CmtError::set(CmtError::configuration_error, "shlibsuffix undefined"); 4000 } 4001 else 4002 { // we are most likely reading empty library_links.in without CMT 4003 if (CmtMessage::active (Verbose)) 4004 CmtMessage::warning 4005 (CmtError::get_error_name (CmtError::configuration_error) 4006 + ": shlibsuffix undefined"); 4007 } 4008 return; 4009 } 3856 4010 shlibsuffix = macro->build_macro_value (); 3857 4011 Symbol::expand (shlibsuffix); … … 3860 4014 { 3861 4015 Symbol* macro = Symbol::find ("symunlink"); 3862 if (macro == 0) return; 3863 symunlink = macro->build_macro_value (); 3864 Symbol::expand (symunlink); 4016 if (macro != 0) 4017 { 4018 symunlinkcmd = macro->build_macro_value (); 4019 Symbol::expand (symunlinkcmd); 4020 } 3865 4021 } 3866 4022 3867 // for (i = 0; i < Uses.size (); i++) 3868 // { 3869 // Use* use = Uses[i]; 4023 if (current_use.get_strategy ("InstallArea")) 4024 { 4025 const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); 4026 4027 cmt_string s1 = ia_mgr.get_installarea (); 4028 4029 { 4030 Symbol* symbol = Symbol::find ("CMTINSTALLAREA"); 4031 if (symbol != 0) 4032 { 4033 s1 = symbol->build_macro_value (); 4034 Symbol::expand (s1); 4035 } 4036 } 4037 4038 cmtinstallarea = s1; 4039 4040 cmt_string s2; 4041 4042 { 4043 Symbol* macro = Symbol::find ("tag"); 4044 if (macro != 0) 4045 { 4046 s2 = macro->build_macro_value (); 4047 Symbol::expand (s2); 4048 } 4049 } 4050 4051 tag = s2; 4052 } 4053 3870 4054 for (i = 0; i < uses.size (); i++) 3871 4055 { 3872 4056 Use* use = uses[i]; 3873 4057 4058 if (use == 0) continue; 3874 4059 if (use->discarded) continue; 3875 4060 if (use->m_hidden) continue; 3876 4061 4062 if (use->get_package_name () == "CMT") continue; 3877 4063 if (!use->located ()) 3878 4064 { … … 3880 4066 + " " + use->version + " " + use->path 3881 4067 + " not found"); 3882 /* 3883 if (!Me.m_quiet) 3884 { 3885 cerr << "#CMT> package " << use->get_package_name () << 3886 " " << use->version << " " << use->path << 3887 " not found" << 3888 endl; 3889 } 3890 */ 3891 } 3892 else 3893 { 3894 if (use->get_package_name () == "CMT") continue; 3895 // if (use->get_package_name () == current_use.get_package_name ()) continue; 3896 3897 cmt_string s; 3898 3899 s = use->get_package_name (); 3900 s += "_libraries"; 3901 3902 Symbol* libraries_macro = Symbol::find (s); 3903 3904 if (libraries_macro == 0) continue; 3905 3906 cmt_string libraries = libraries_macro->build_macro_value (); 3907 Symbol::expand (libraries); 3908 3909 static CmtSystem::cmt_string_vector values; 3910 3911 CmtSystem::split (libraries, " \t", values); 3912 3913 for (int j = 0; j < values.size (); j++) 3914 { 3915 const cmt_string& library = values[j]; 3916 3917 static cmt_string libname; 3918 static cmt_string name; 3919 3920 // Is it a simple name or a complete path? 3921 3922 libname = library; 3923 Symbol::expand (libname); 3924 3925 if (CmtSystem::absolute_path (libname)) 3926 { 3927 /** 3928 * We assume here that "library" contains a complete path. 3929 * (including the complete syntax libxxx.so) 3930 */ 3931 3932 cmt_string suffix; 3933 CmtSystem::basename (library, name); 3934 } 3935 else 3936 { 3937 /** 3938 * Here we expect that only the base name of the library 3939 * is given : ie it should not contain the "lib" prefix, 3940 * nor the suffix .so, nor any path prefix. 3941 * This of course should generally correspond to a constituent name. 3942 */ 3943 3944 name = "lib"; 3945 name += libname; 3946 name += "."; 3947 name += shlibsuffix; 3948 } 3949 3950 Symbol::expand (libname); 3951 3952 if (current_use.get_strategy ("InstallArea")) 3953 { 3954 const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); 3955 3956 cmt_string s1 = ia_mgr.get_installarea (); 3957 3958 { 3959 Symbol* symbol = Symbol::find ("CMTINSTALLAREA"); 3960 if (symbol != 0) 3961 { 3962 s1 = symbol->build_macro_value (); 3963 Symbol::expand (s1); 3964 } 3965 } 3966 3967 cmt_string s2; 3968 3969 { 3970 Symbol* macro = Symbol::find ("tag"); 3971 if (macro != 0) 3972 { 3973 s2 = macro->build_macro_value (); 3974 Symbol::expand (s2); 3975 } 3976 } 3977 3978 // Now deleting the reference file 3979 3980 s = symunlink; 3981 s += " "; 3982 s += s1; 3983 s += CmtSystem::file_separator (); 3984 s += s2; 3985 s += CmtSystem::file_separator (); 3986 s += "lib"; 3987 s += CmtSystem::file_separator (); 3988 s += name; 3989 s += ".cmtref"; 3990 s += " "; 3991 s += s1; 3992 s += CmtSystem::file_separator (); 3993 s += s2; 3994 s += CmtSystem::file_separator (); 3995 s += "lib"; 3996 s += CmtSystem::file_separator (); 3997 s += name; 3998 } 3999 else 4000 { 4001 s = symunlink; 4002 s += " ../$("; 4003 s += current_use.get_package_name (); 4004 s += "_tag)/"; 4005 s += name; 4006 } 4007 4008 Symbol::expand (s); 4009 4010 if (!Me.m_quiet) cerr << s << endl; 4011 4012 int status = CmtSystem::execute (s); 4013 4014 if (status != 0) 4015 { 4016 // if (status != 2) CmtError::set (CmtError::execution_error, s); 4017 CmtError::set (CmtError::execution_error, s); 4018 4019 CmtMessage::warning ("Cannot remove the symbolic link " + s); 4020 // cerr << "#CMT> Cannot remove the symbolic link " << s << endl; 4021 4022 break; 4023 } 4024 } 4025 } 4068 continue; 4069 } 4070 4071 use->remove_library_links (cmtinstallarea, tag, shlibsuffix, symunlinkcmd); 4026 4072 } 4027 4073 } … … 6417 6463 case action_build_constituents_makefile : 6418 6464 case action_build_constituents_config : 6465 case action_build_broadcast_config : 6419 6466 case action_build_dependencies : 6420 6467 case action_build_library_links : … … 6535 6582 case action_build_constituents_makefile : 6536 6583 case action_build_constituents_config : 6584 case action_build_broadcast_config : 6537 6585 case action_build_dependencies : 6538 6586 case action_build_library_links : … … 6642 6690 case action_build_constituents_makefile : 6643 6691 case action_build_constituents_config : 6692 case action_build_broadcast_config : 6644 6693 case action_build_dependencies : 6645 6694 case action_build_library_links : … … 6789 6838 case action_build_constituents_makefile : 6790 6839 case action_build_constituents_config : 6840 case action_build_broadcast_config : 6791 6841 case action_build_dependencies : 6792 6842 case action_build_library_links : … … 6911 6961 case action_build_constituents_config : 6912 6962 do_build_constituents_config (ap); 6963 break; 6964 case action_build_broadcast_config : 6965 do_build_broadcast_config (ap); 6913 6966 break; 6914 6967 case action_build_dependencies : … … 9042 9095 else 9043 9096 { 9044 if (Me.m_action == action_build_constituents_makefile || 9045 Me.m_action == action_build_constituents_config) 9046 CmtMessage::warning ("package " + import + 9047 " cannot be imported (requested for " + 9048 constituent.name +")"); 9097 if ((!constituent.has_target_tag && 9098 Me.m_action == action_build_constituents_config) 9099 || 9100 (constituent.has_target_tag && 9101 Me.m_action == action_build_constituent_config)) 9102 CmtMessage::warning 9103 (CmtError::get_error_name (CmtError::configuration_error) 9104 + ": package " + import 9105 + " cannot be imported (requested for " 9106 + (constituent.type == Application ? 9107 "application " : "library ") 9108 + constituent.name +")"); 9109 9049 9110 if (Cmt::get_debug ()) 9050 9111 { … … 9052 9113 << ("package " + import + 9053 9114 " cannot be imported (requested for " + 9115 (constituent.type == Application ? 9116 "application " : "library ") + 9054 9117 constituent.name +")") << endl; 9055 9118 } -
CMT/HEAD/source/cmt_parser.h
r550 r588 228 228 action_build_constituents_makefile, 229 229 action_build_constituents_config, 230 action_build_broadcast_config, 230 231 action_build_dependencies, 231 232 action_build_library_links, -
CMT/HEAD/source/cmt_symbol.cxx
r565 r588 1907 1907 1908 1908 */ 1909 cmt_string Symbol::resolve_macro_value (const cmt_string& tag_name) 1909 cmt_string Symbol::resolve_macro_value (const cmt_string& tag_name) const 1910 1910 { 1911 1911 cmt_string temp = builder->build (*this, tag_name); … … 1933 1933 (action != action_build_constituents_config) && 1934 1934 (action != action_build_constituent_config) && 1935 (action != action_build_broadcast_config) && 1935 1936 (action != action_show_macros) && 1936 1937 (action != action_show_actions) && … … 1952 1953 (action == action_build_constituents_config) || 1953 1954 (action == action_build_constituent_config) || 1955 (action == action_build_broadcast_config) || 1954 1956 (action == action_load) || 1955 1957 (!Cmt::get_quiet ())) … … 1973 1975 else if (action == action_build_tag_makefile || 1974 1976 action == action_build_constituents_config || 1975 action == action_build_constituent_config) 1977 action == action_build_constituent_config || 1978 action == action_build_broadcast_config) 1976 1979 { 1977 1980 /* … … 1997 2000 (action == action_build_constituents_config) || 1998 2001 (action == action_build_constituent_config) || 2002 (action == action_build_broadcast_config) || 1999 2003 (action == action_load) || 2000 2004 (!Cmt::get_quiet ())) … … 3287 3291 3288 3292 //------------------------------------------------------------- 3289 bool Symbol::check_tag_used ( Tag* tag)3293 bool Symbol::check_tag_used (const Tag* tag) 3290 3294 { 3291 3295 if (tag == 0) return (false); -
CMT/HEAD/source/cmt_symbol.h
r549 r588 102 102 static void filter_path_value (const cmt_string& name, cmt_string& text); 103 103 104 static bool check_tag_used ( Tag* tag);104 static bool check_tag_used (const Tag* tag); 105 105 106 106 static cmt_string get_env_value (const cmt_string& name); … … 122 122 int print_macro (PrintMode mode, ostream& out = cout) const; 123 123 cmt_string clean_macro_value () const; 124 cmt_string resolve_macro_value (const cmt_string& tag_name = "") ;124 cmt_string resolve_macro_value (const cmt_string& tag_name = "") const; 125 125 void show_macro (PrintMode mode, ostream& out = cout); 126 126 // void show_macro (PrintMode mode); -
CMT/HEAD/source/cmt_system.cxx
r576 r588 674 674 if (::unlink (name) != 0) 675 675 { 676 CmtMessage::error ("Cannot remove file " + name);676 // CmtMessage::error ("Cannot remove file " + name); 677 677 // cerr << "#CMT> Cannot remove file " << name << endl; 678 678 return (false); -
CMT/HEAD/source/cmt_use.cxx
r582 r588 1624 1624 // On deplace tous les pointeurs d'une case en arriere 1625 1625 // 1626 //cerr << "move-0> " << use->get_package_name () << "[" << use->m_index << "]" << endl; 1626 1627 for (use_index++; use_index < size; use_index++) 1627 1628 { … … 1629 1630 u->m_index--; 1630 1631 1632 //cerr << "move-1> " << u->get_package_name () << "[" << u->m_index << "]" << endl; 1631 1633 uses[use_index - 1] = uses[use_index]; 1632 1634 } … … 1638 1640 use->m_index = size - 1; 1639 1641 uses[size - 1] = use; 1642 //cerr << "move-2> " << use->get_package_name () << "[" << use->m_index << "]" << endl; 1640 1643 } 1641 1644 … … 3815 3818 3816 3819 if (CmtMessage::active (Info)) 3817 cerr << " Creating thereference file " << ref_file << endl;3820 cerr << " Creating reference file " << ref_file << endl; 3818 3821 // if (!Cmt::get_quiet ()) cerr << " Creating the reference file " << ref_file << endl; 3819 text.write (ref_file); 3822 if (!text.write (ref_file)) 3823 { 3824 CmtError::set (CmtError::file_access_error, ref_file); 3825 return false; 3826 } 3820 3827 } 3821 3828 else … … 3844 3851 if (same_dirs (source, dest)) 3845 3852 { 3846 return (false); 3853 cmt_string lname; 3854 CmtSystem::basename (libname, lname); 3855 if (lname == name) 3856 return true; 3847 3857 } 3848 3858 … … 3855 3865 if (!CmtSystem::create_symlink (libname, s)) 3856 3866 { 3857 CmtMessage::error ("Cannot create a symbolic link to " + libname); 3867 CmtError::set (CmtError::file_access_error, "Cannot create symbolic link to " + libname); 3868 //CmtMessage::error ("Cannot create a symbolic link to " + libname); 3858 3869 // cerr << "#CMT> Cannot create a symbolic link to " << libname << endl; 3859 3870 return (false); … … 3867 3878 cmd += " "; 3868 3879 cmd += s; 3869 3870 3880 int status = CmtSystem::execute (cmd); 3871 3872 3881 if (status != 0) 3873 3882 { 3874 CmtMessage::error ("Cannot create a symbolic link to " + libname); 3883 CmtError::set (CmtError::execution_error, "Cannot create symbolic link to " + libname); 3884 //CmtMessage::error ("Cannot create a symbolic link to " + libname); 3875 3885 // cerr << "#CMT> Cannot create a symbolic link to " << libname << endl; 3876 3886 return (false); … … 3881 3891 } 3882 3892 3883 3893 //---------------------------------------------------------- 3894 static bool uninstall_library (const cmt_string& source_library_name, 3895 const cmt_string& dest_library_name, 3896 const cmt_string& cmtinstallarea, 3897 const cmt_string& tag, 3898 const cmt_string& symunlinkcmd) 3899 { 3900 cmt_string libname = source_library_name; 3901 cmt_string name = dest_library_name; 3902 cmt_string s; 3903 Use& current_use = Use::current (); 3904 3905 Symbol::expand (name); 3906 Symbol::expand (libname); 3907 3908 if (cmtinstallarea != "") 3909 { 3910 s = cmtinstallarea; 3911 s += CmtSystem::file_separator (); 3912 s += tag; 3913 s += CmtSystem::file_separator (); 3914 s += "lib"; 3915 s += CmtSystem::file_separator (); 3916 s += name; 3917 3918 // Now removing the reference file 3919 3920 cmt_string r = s; 3921 r += ".cmtref"; 3922 3923 if (CmtMessage::active (Info)) 3924 cerr << " Removing reference file " << r << endl; 3925 if (symunlinkcmd == "") 3926 { 3927 if (!CmtSystem::remove_file (r) && CmtSystem::test_file(r)) 3928 { 3929 CmtError::set (CmtError::file_access_error, r); 3930 return false; 3931 } 3932 } 3933 else 3934 { 3935 cmt_string cmd (symunlinkcmd); 3936 cmd += " "; 3937 cmd += r; 3938 int status = CmtSystem::execute (cmd); 3939 if (status != 0) 3940 { 3941 // if (status != 2) CmtError::set (CmtError::execution_error, s); 3942 CmtError::set (CmtError::execution_error, cmd); 3943 } 3944 } 3945 } 3946 else 3947 { 3948 if (current_use.style != none_style) 3949 { 3950 s = "../$("; 3951 s += current_use.get_package_name (); 3952 s += "_tag)/"; 3953 } 3954 else 3955 { 3956 s = "./"; 3957 } 3958 s += name; 3959 } 3960 3961 Symbol::expand (s); 3962 3963 cmt_string source; 3964 cmt_string dest; 3965 3966 CmtSystem::dirname (libname, source); 3967 CmtSystem::dirname (s, dest); 3968 3969 if (same_dirs (source, dest)) 3970 { 3971 cmt_string lname; 3972 CmtSystem::basename (libname, lname); 3973 if (lname == name) 3974 return true; 3975 } 3976 3977 //if (!Cmt::get_quiet ()) 3978 if (CmtMessage::active (Info)) 3979 cerr << " Removing symlink " << s << " to " << libname << endl; 3980 3981 if (symunlinkcmd == "") 3982 { 3983 if (!CmtSystem::remove_file (s) && CmtSystem::test_file(s)) 3984 { 3985 CmtError::set (CmtError::file_access_error, "Cannot remove symbolic link to " + libname); 3986 return (false); 3987 } 3988 } 3989 else 3990 { 3991 cmt_string cmd = symunlinkcmd; 3992 cmd += " "; 3993 cmd += s; 3994 int status = CmtSystem::execute (cmd); 3995 if (status != 0) 3996 { 3997 CmtError::set (CmtError::execution_error, "Cannot remove symbolic link to " + libname); 3998 //CmtMessage::error ("Cannot create a symbolic link to " + libname); 3999 // cerr << "#CMT> Cannot create a symbolic link to " << libname << endl; 4000 return (false); 4001 } 4002 } 4003 4004 return (true); 4005 } 4006 4007 //---------------------------------------------------------- 3884 4008 /** 3885 Centralize the construction of library links for this Use. 3886 */ 4009 * This function construct absolute library path 4010 * for libraries specified via <package>_libraries macros 4011 * to be used by build[remove]_library_links functions, 4012 * and class Generator build_library_links_infile function, in particular. 4013 */ 4014 void Use::absolute_library_path (const cmt_string& libname, 4015 const cmt_string& shlibsuffix, 4016 CmtSystem::cmt_string_vector& paths) const 4017 { 4018 if (CmtSystem::absolute_path (libname)) 4019 { 4020 paths.push_back (libname); 4021 return; 4022 } 4023 4024 /** 4025 * Here we expect that only the base name of the library 4026 * is given : ie it should not contain the "lib" prefix, 4027 * nor the suffix .so, nor any path prefix. 4028 * This of course should generally correspond to a constituent name. 4029 */ 4030 cmt_string libpath; 4031 if (style != none_style) 4032 { 4033 libpath = "${"; 4034 libpath += prefix; 4035 libpath += "ROOT}/${"; 4036 libpath += get_package_name (); 4037 libpath += "_tag}/"; 4038 } 4039 else 4040 { 4041 libpath = "${"; 4042 libpath += prefix; 4043 libpath += "ROOT}/"; 4044 } 4045 libpath += "$(library_prefix)"; 4046 libpath += libname; 4047 libpath += "$(library_suffix)"; 4048 libpath += "."; 4049 libpath += shlibsuffix; 4050 paths.push_back (libpath); 4051 4052 #ifdef __APPLE__ 4053 if (style != none_style) 4054 { 4055 libpath = "${"; 4056 libpath += prefix; 4057 libpath += "ROOT}/${"; 4058 libpath += get_package_name (); 4059 libpath += "_tag}/"; 4060 } 4061 else 4062 { 4063 libpath = "${"; 4064 libpath += prefix; 4065 libpath += "ROOT}/"; 4066 } 4067 libpath += libname; 4068 libpath += ".bundle"; 4069 paths.push_back (libpath); 4070 #endif 4071 } 4072 4073 //---------------------------------------------------------- 4074 /** 4075 * Centralize the construction of library links for this Use. 4076 */ 3887 4077 void Use::build_library_links (const cmt_string& cmtinstallarea, 3888 4078 const cmt_string& tag, … … 3933 4123 libname = library; 3934 4124 Symbol::expand (libname); 3935 3936 bool is_absolute = false; 3937 3938 is_absolute = CmtSystem::absolute_path (libname); 3939 3940 if (is_absolute) 3941 { 3942 /** 3943 * We assume here that "library" contains a complete path. 3944 * (including the complete syntax libxxx.so) 3945 */ 3946 3947 cmt_string suffix; 3948 CmtSystem::basename (library, name); 3949 } 3950 else 3951 { 3952 /** 3953 * Here we expect that only the base name of the library 3954 * is given : ie it should not contain the "lib" prefix, 3955 * nor the suffix .so, nor any path prefix. 3956 * This of course should generally correspond to a constituent name. 3957 */ 3958 3959 if (style != none_style) 3960 { 3961 libname = "${"; 3962 libname += prefix; 3963 libname += "ROOT}/${"; 3964 libname += get_package_name (); 3965 libname += "_tag}/"; 3966 } 3967 else 3968 { 3969 libname = "${"; 3970 libname += prefix; 3971 libname += "ROOT}/"; 3972 } 3973 libname += "$(library_prefix)"; 3974 libname += library; 3975 libname += "$(library_suffix)"; 3976 libname += "."; 3977 libname += shlibsuffix; 3978 3979 name = "$(library_prefix)"; 3980 name += library; 3981 name += "$(library_suffix)"; 3982 name += "."; 3983 name += shlibsuffix; 3984 } 3985 3986 if (!install_library (libname, name, cmtinstallarea, tag, symlinkcmd)) 3987 { 3988 continue; 3989 } 3990 3991 #ifdef __APPLE__ 3992 if (!is_absolute) 3993 { 3994 if (style != none_style) 3995 { 3996 libname = "${"; 3997 libname += prefix; 3998 libname += "ROOT}/${"; 3999 libname += get_package_name (); 4000 libname += "_tag}/"; 4001 } 4002 else 4003 { 4004 libname = "${"; 4005 libname += prefix; 4006 libname += "ROOT}/"; 4007 } 4008 libname += library; 4009 libname += ".bundle"; 4010 4011 name = library; 4012 name += ".bundle"; 4013 4014 if (!install_library (libname, name, cmtinstallarea, tag, symlinkcmd)) 4015 { 4016 continue; 4017 } 4018 } 4019 #endif 4125 if (0 == libname.size ()) continue; 4126 4127 CmtSystem::cmt_string_vector paths; 4128 absolute_library_path (libname, 4129 shlibsuffix, 4130 paths); 4131 4132 for (int k = 0; k < paths.size (); k++) 4133 { 4134 CmtSystem::basename (paths[k], name); 4135 if (!install_library (paths[k], name, cmtinstallarea, tag, symlinkcmd)) 4136 { 4137 CmtError::print (); 4138 } 4139 } 4140 } 4141 } 4142 //---------------------------------------------------------- 4143 /** 4144 * Centralize the removal of library links for this Use. 4145 */ 4146 void Use::remove_library_links (const cmt_string& cmtinstallarea, 4147 const cmt_string& tag, 4148 const cmt_string& shlibsuffix, 4149 const cmt_string& symunlinkcmd) const 4150 { 4151 if (!located ()) 4152 { 4153 CmtMessage::warning ("package " + get_package_name () 4154 + " " + version + " " + path 4155 + " not found"); 4156 return; 4157 } 4158 4159 cmt_string s; 4160 4161 s = get_package_name (); 4162 s += "_libraries"; 4163 4164 Symbol* libraries_macro = Symbol::find (s); 4165 4166 if (libraries_macro == 0) return; 4167 4168 cmt_string libraries = libraries_macro->build_macro_value (); 4169 Symbol::expand (libraries); 4170 static CmtSystem::cmt_string_vector values; 4171 4172 CmtSystem::split (libraries, " \t", values); 4173 4174 for (int j = 0; j < values.size (); j++) 4175 { 4176 const cmt_string& library = values[j]; 4177 4178 static cmt_string libname; 4179 static cmt_string name; 4180 4181 // Is it a simple name or a complete path? 4182 4183 libname = library; 4184 Symbol::expand (libname); 4185 if (0 == libname.size ()) continue; 4186 4187 CmtSystem::cmt_string_vector paths; 4188 absolute_library_path (libname, 4189 shlibsuffix, 4190 paths); 4191 4192 for (int k = 0; k < paths.size (); k++) 4193 { 4194 CmtSystem::basename (paths[k], name); 4195 if (!uninstall_library (paths[k], name, cmtinstallarea, tag, symunlinkcmd)) 4196 { 4197 CmtError::print (); 4198 } 4199 } 4020 4200 } 4021 4201 } -
CMT/HEAD/source/cmt_use.h
r582 r588 118 118 const cmt_string& shlibsuffix, 119 119 const cmt_string& symlinkcmd) const; 120 120 void remove_library_links (const cmt_string& cmtinstallarea, 121 const cmt_string& tag, 122 const cmt_string& shlibsuffix, 123 const cmt_string& symunlinkcmd) const; 124 121 125 bool get_all_clients (const cmt_string& to_name); 122 126 … … 152 156 bool is_head_version (const cmt_string& version); 153 157 void clear (); 158 void absolute_library_path (const cmt_string& libname, 159 const cmt_string& shlibsuffix, 160 CmtSystem::cmt_string_vector& paths) const; 154 161 // Public attributes 155 162 public: -
CMT/HEAD/src/Makefile.core
r556 r588 135 135 # add to the list of valid suffixes 136 136 # so that nonterminal match-anything rules will not be considered 137 .SUFFIXES: .make . stamp .cxx137 .SUFFIXES: .make .in .stamp .cxx -
CMT/HEAD/src/Makefile.header
r547 r588 19 19 20 20 cmt_local_tagfile = $(bin)$(tag).make 21 cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make 21 22 22 23 cmt_constituents_makefile = $(bin)constituents.make 23 24 cmt_local_setup = $(bin)setup$$$$.make 25 #cmt_local_setup = $(bin)$(package)setup$$$$.make 26 #cmt_final_setup = $(bin)${PACKAGE}setup.make 24 cmt_broadcast_makefile = $(bin)broadcast.make 25 27 26 cmt_final_setup = $(bin)setup.make 28 #cmt_final_setup = $(bin)$(package)setup.make 29 30 # 31 # Generic entry points for all targets 32 # 33 #ifndef QUICK 34 #all :: check_config ; 35 #else 36 #all :: no_check_config ; 37 #endif 38 #all :: $(cmt_constituents_makefile) 39 # @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ 40 default :: all ; 27 28 cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp 29 30 ifdef CMTBCAST 31 QUICK = 1 32 endif 33 34 ifdef QUICK 35 ifndef CMTBCAST 36 37 ifneq ($(MAKECMDGOALS),binclean) 38 ifneq ($(MAKECMDGOALS),help) 39 cmt_included = 1 40 -include $(cmt_local_tagfile) 41 endif 42 endif 43 44 else 45 46 ifneq ($(MAKECMDGOALS),help) 47 cmt_included = 1 48 -include $(cmt_broadcast_tagfile) 49 endif 50 51 endif 52 endif 53 54 all :: 55 ifndef CMTBCAST 56 ifndef cmt_included 57 @$(MAKE) $(cmt_constituents_makefile) 58 endif 59 $(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ 60 else 61 ifndef cmt_included 62 @$(MAKE) $(cmt_broadcast_makefile) 63 endif 64 @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ 65 endif 66 67 .DEFAULT : 68 ifndef CMTBCAST 69 ifndef cmt_included 70 @$(MAKE) $(cmt_constituents_makefile) 71 endif 72 @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ 73 else 74 ifndef cmt_included 75 @$(MAKE) $(cmt_broadcast_makefile) 76 endif 77 @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@ 78 endif 41 79 42 80 check_config :: 43 @$(cmtexe) check configuration; retval=$$?; \ 44 if test $${retval} -ne 0; then \ 45 test -z "$(cmtmsg)" || \ 46 echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ 47 fi; exit $${retval} 48 49 # @$(cmtexe) check configuration; retval=$$?; \ 50 # if test $${retval} = 0; then \ 51 # $(MAKE) --no-print-directory target="all" common_target; \ 52 # else \ 53 # test -z "$(cmtmsg)" || \ 54 # echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ 55 # fi 56 57 #no_check_config :: 58 # @$(MAKE) --no-print-directory target="all" common_target 59 60 binclean :: 61 if test ! "$(bin)" = "./"; then \ 62 if test -d $(bin) ; then \ 63 test -z "$(cmtmsg)" || \ 64 echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ 65 \rm -rf $(bin) ; \ 66 fi ; \ 67 fi 68 69 #clean uninstall :: check_config 70 # @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ 71 # @$(cmtexe) check configuration 72 # @$(MAKE) --no-print-directory target="$@" common_target 73 74 .DEFAULT :: 75 @$(MAKE) $(cmt_constituents_makefile) 76 @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@ 77 78 # @$(cmtexe) check configuration 79 # @$(MAKE) --no-print-directory target="$@" common_target 80 # @$(MAKE) --no-print-directory target="config $@" common_target 81 82 # 83 # Capture all possible targets 84 # 85 #common_target : $(cmt_constituents_makefile) 86 # @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $(target) 87 88 #$(cmt_constituents_makefile) : $(cmt_local_tagfile) 81 +@$(cmtexe) check configuration; retval=$$?; \ 82 if test $${retval} -ne 0; then \ 83 test -z "$(cmtmsg)" || \ 84 echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ 85 fi; exit $${retval} 86 87 $(cmt_check_configurationstamp) : $(use_requirements) 88 +@$(cmtexe) check configuration; retval=$$?; \ 89 if test $${retval} -ne 0; then \ 90 test -z "$(cmtmsg)" || \ 91 echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ 92 fi; exit $${retval} 93 +$(silent) if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi && \touch $@ 94 # echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; exit 17 89 95 90 96 ifndef QUICK 91 $(cmt_constituents_makefile) : check_config 92 else 93 $(cmt_constituents_makefile) : 94 endif 95 $(echo) "(Makefile.header) Rebuilding $@"; \ 97 $(cmt_constituents_makefile) :: 98 #$(cmt_constituents_makefile) : check_config 99 else 100 $(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements) 101 #$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp) 102 endif 103 +$(echo) "(Makefile.header) Rebuilding $@"; \ 96 104 if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ 97 $(cmtexe) -tag=$(tags) build constituents_config -out=$ @; \105 $(cmtexe) -tag=$(tags) build constituents_config -out=$(cmt_constituents_makefile); \ 98 106 retval=$$?; \ 99 107 if test $${retval} -ne 0; then \ … … 105 113 106 114 ifndef QUICK 107 $(cmt_ local_tagfile) ::108 else 109 $(cmt_local_tagfile) : 110 endif 111 $(echo) "(Makefile.header) Rebuilding $@"; \ 112 if test -f $@; then rm -f $@; fi; \ 113 if test ! -d $(@D); then $(mkdir) -p $(@D); fi; \114 $(cmtexe) -tag=$(tags) build tag_makefile >$@115 $(echo) "(Makefile.header) Rebuilding $(cmt_final_setup)"; \116 test ! -f $(cmt_local_setup) || \rm -f $(cmt_local_setup); \117 trap '\rm -f $(cmt_local_setup)' 0 1 2 15;\118 $(cmtexe) -tag=$(tags) show setup >$(cmt_local_setup) &&\119 if [ -f $(cmt_final_setup) ] &&\120 \ cmp -s $(cmt_final_setup) $(cmt_local_setup); then\121 \rm $(cmt_local_setup); else\122 \mv -f $(cmt_local_setup) $(cmt_final_setup); fi115 $(cmt_broadcast_makefile) :: 116 #$(cmt_broadcast_makefile) : check_config 117 else 118 $(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements) 119 #$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp) 120 endif 121 +$(echo) "(Makefile.header) Rebuilding $@"; \ 122 if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ 123 $(cmtexe) -tag=$(tags) build broadcast_config -out=$(cmt_broadcast_makefile); \ 124 retval=$$?; \ 125 if test $${retval} -ne 0; then \ 126 test -z "$(cmtmsg)" || \ 127 echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot generate $@" >&2; \ 128 \rm -f $@; \ 129 fi; \ 130 exit $${retval} 123 131 124 132 # … … 134 142 everywhere :: $(everywhere) 135 143 144 ifndef CMTBCAST 145 binclean :: 146 if _bin=`cd $(bin) 2>/dev/null&&pwd -P`&&_cur=`pwd -P`&&[ -n "$${_bin}" ]&&[ "$${_cur#$${_bin}}" = "$${_cur}" ] ; then \ 147 test -z "$(cmtmsg)" || \ 148 echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ 149 \rm -rf $(bin) ; \ 150 fi 151 endif 152 136 153 # 137 154 # Display all targets 138 155 # 139 156 help :: 157 ifndef CMTBCAST 140 158 @echo '--------------------------------------------------------------------------' 141 159 @echo 'You may select one of the following make targets :' … … 160 178 @echo ' run all applications defined with the -check option' 161 179 @echo ' ' 162 163 164 # explicit rule not to remake 180 @echo 'To switch to BCAST mode, set CMTBCAST to non-empty string.' 181 else 182 @echo 'Targets for BCAST mode:' 183 @echo 184 @echo 'help : this help' 185 ifndef BCAST_ONLY 186 ifndef BCAST_GLOBAL 187 @echo 'all : (re)build all used packages in current project (this is default target)' 188 else 189 @echo 'all : (re)build all used packages in all projects (this is default target)' 190 endif 191 else 192 @echo 'all : (re)build current package (this is default target)' 193 endif 194 @echo 'clean : remove everything that can be rebuilt' 195 @echo 'binclean : fast erase of binary directories (and installation area)' 196 @echo 'uninstall : remove everything installed in the installation area' 197 @echo 198 ifndef BCAST_GLOBAL 199 @uses=`$(cmtexe) -private show macros '_project$$|package$$' -tag=$(tags)| \ 200 awk -F = '{if ($$1 ~ /_project$$/) {uses[substr($$1,1,length($$1)-8)]=$$2}else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}}END{for (u in uses){if (uses[u]==uses[cur]) print u}}'`; \ 201 for u in $${uses}; do \ 202 echo "$${u} : (re)build package $${u} ($(_groups))"; \ 203 echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ 204 echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ 205 echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ 206 done 207 else 208 @uses=`$(cmtexe) -private show macros '_root$$' -tag=$(tags)| \ 209 awk -F = '{u=substr($$1,1,length($$1)-5);if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}'`; \ 210 for u in $${uses}; do \ 211 echo "$${u} : (re)build package $${u} ($(_groups))"; \ 212 echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \ 213 echo "$${u}binclean : fast erase of binary directory in package $${u}"; \ 214 echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \ 215 done 216 endif 217 @echo 218 ifndef BCAST_ONLY 219 @echo ' ... with dependencies packages (may be ignored by setting BCAST_ONLY).' 220 else 221 @echo ' ... without dependencies packages (may be included by unsetting BCAST_ONLY).' 222 endif 223 @echo 224 ifndef BCAST_GLOBAL 225 @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.' 226 else 227 @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.' 228 endif 229 ifndef NO_ALL_GROUPS 230 @echo 'To (re)build default group only, set NO_ALL_GROUPS.' 231 ifndef CMTACTIONS 232 @echo 'To also (re)build cmt_actions group, set CMTACTIONS.' 233 endif 234 else 235 @echo 'To (re)build all groups, unset NO_ALL_GROUPS.' 236 endif 237 @echo 238 @echo 'To switch to PACKAGE mode, unset CMTBCAST.' 239 endif 240 241 ifndef NO_ALL_GROUPS 242 ifndef CMTACTIONS 243 _groups = all groups except cmt_actions 244 else 245 _groups = all groups 246 endif 247 else 248 _groups = default group 249 endif 250 251 # explicit rule to avoid implicit rule search 252 # and not to remake 165 253 ${CMTROOT}/src/Makefile.header : ; 254 ${CMTROOT}/src/Makefile.core : ; 255 ifdef use_requirements 256 $(use_requirements) : ; 257 endif 166 258 167 259 # for multiple command line goals, -
CMT/HEAD/src/setup.csh
r584 r588 54 54 55 55 alias jcmt '(java cmt_parser)' 56 57 # Set MAKEFLAGS, if unset (similar to NPROC with Plan 9 mk utility) 58 if ( $?MAKEFLAGS == 0 ) then 59 setenv MAKEFLAGS -j`getconf _NPROCESSORS_ONLN` || unsetenv MAKEFLAGS 60 if ( $?MAKEFLAGS == 1 ) then 61 setenv MAKEFLAGS "${MAKEFLAGS} QUICK=1" 62 else 63 setenv MAKEFLAGS "QUICK=1" 64 endif 65 endif -
CMT/HEAD/src/setup.sh
r585 r588 11 11 fi 12 12 13 if [ `expr $- : '.*i'` -ne 0]; then13 if [ -n "$-" ] && [ "${-#*i}" != "$-" ]; then 14 14 if [ -n "${ZSH_NAME-}" ]; then 15 15 . ${CMTROOT}/src/setup.zsh … … 47 47 48 48 alias jcmt='(java cmt_parser)'; export jcmt 49 50 # Set MAKEFLAGS, if unset (similar to NPROC with Plan 9 mk utility) 51 if [ -z ${MAKEFLAGS+CMT} ]; then 52 MAKEFLAGS=-j`getconf _NPROCESSORS_ONLN 2>/dev/null` && export MAKEFLAGS || unset MAKEFLAGS 53 if [ -n "${MAKEFLAGS:-}" ]; then 54 MAKEFLAGS="${MAKEFLAGS} QUICK=1" 55 else 56 MAKEFLAGS="QUICK=1" 57 fi 58 export MAKEFLAGS 59 fi
Note: See TracChangeset
for help on using the changeset viewer.