Changeset 15 for CMT/v1r19/source
- Timestamp:
- Mar 14, 2005, 8:42:34 AM (19 years ago)
- Location:
- CMT/v1r19/source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/v1r19/source/cmt.h
r11 r15 32 32 cmt_string m_cmt_site; 33 33 cmt_string m_cmt_version; 34 35 int m_current_build_strategy;36 int m_current_setup_strategy;37 34 38 35 cmt_string m_current_dir; … … 204 201 static const cmt_string& get_current_offset (); 205 202 static AccessMode get_current_access (); 206 static int get_current_build_strategy ();207 static int get_current_setup_strategy ();208 203 static CmtStructuringStyle get_current_structuring_style (); 209 204 static CmtDirStyle get_current_style (); … … 240 235 static void restore_all_tags (Use* use); 241 236 static void set_current_access (AccessMode mode); 242 static void set_current_build_strategy (int strategy);243 static void set_current_setup_strategy (int strategy);244 237 static void set_scope_filtering_mode (CmtScopeFilteringMode mode); 245 238 static void set_standard_macros (); -
CMT/v1r19/source/cmt_commands.cxx
r11 r15 1897 1897 void ArgParser::option_no_cleanup () 1898 1898 { 1899 cmt.m_current_setup_strategy |= SetupNoCleanup;1899 //cmt.m_current_setup_strategy |= SetupNoCleanup; 1900 1900 } 1901 1901 -
CMT/v1r19/source/cmt_parser.cxx
r11 r15 62 62 m_cmt_root = ""; 63 63 m_cmt_version = ""; 64 m_current_build_strategy = DefaultBuildStrategy;65 m_current_setup_strategy = DefaultSetupStrategy;66 64 m_current_dir = ""; 67 65 m_current_package = ""; … … 155 153 156 154 //---------------------------------------------------------- 157 static int get_build_strategy (Use& use = Use::current())155 static bool get_strategy (const cmt_string& name, Use& use = Use::current()) 158 156 { 159 157 static cmt_string cmtpath; … … 164 162 Project* p = Project::find_by_cmtpath (cmtpath); 165 163 166 int strategy = 0; 167 168 if (p == 0) strategy = Cmt::get_current_build_strategy (); 169 else strategy = p->get_build_strategy (); 170 171 return (strategy); 172 } 173 174 //---------------------------------------------------------- 175 static int get_setup_strategy (Use& use = Use::current()) 176 { 177 static cmt_string cmtpath; 178 static cmt_string offset; 179 180 use.get_cmtpath_and_offset (cmtpath, offset); 181 182 Project* p = Project::find_by_cmtpath (cmtpath); 183 184 int strategy = 0; 185 186 if (p == 0) strategy = Cmt::get_current_setup_strategy (); 187 else strategy = p->get_setup_strategy (); 164 bool strategy; 165 166 if (p == 0) strategy = StrategyMgr::get_default_strategy (name); 167 else strategy = p->get_strategy (name); 188 168 189 169 return (strategy); … … 1737 1717 } 1738 1718 1739 if ( (get_build_strategy () & InstallAreaMask) == WithInstallArea)1719 if (get_strategy ("InstallArea")) 1740 1720 { 1741 1721 const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); … … 2159 2139 // Try a cleanup of the installation area 2160 2140 // 2161 if ( (get_build_strategy () & InstallAreaMask) == WithInstallArea)2141 if (get_strategy ("InstallArea")) 2162 2142 { 2163 2143 CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); … … 2165 2145 //cout << "#IA3>" << endl; 2166 2146 2167 if ( (get_setup_strategy () & SetupCleanupMask) == SetupCleanup)2147 if (get_strategy ("SetupCleanup")) 2168 2148 { 2169 2149 ia_mgr.config (); … … 2833 2813 Symbol::expand (libname); 2834 2814 2835 if ( (get_build_strategy () & InstallAreaMask) == WithInstallArea)2815 if (get_strategy ("InstallArea")) 2836 2816 { 2837 2817 const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); … … 3032 3012 // Try a cleanup of the installation area 3033 3013 // 3034 if ( (get_build_strategy () & InstallAreaMask) == WithInstallArea)3014 if (get_strategy ("InstallArea")) 3035 3015 { 3036 3016 CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); … … 3041 3021 3042 3022 /* 3043 if ( (get_setup_strategy () & SetupCleanupMask) == SetupCleanup)3023 if (get_strategy ("SetupCleanup")) 3044 3024 { 3045 3025 const cmt_string& installarea = ia_mgr.get_installarea (); … … 3581 3561 Project* p = Project::get_current (); 3582 3562 3583 if (p != 0) p->show (); 3584 else cout << "No current project" << endl; 3563 /* 3564 if (p != 0) p->show (); 3565 else cout << "No current project" << endl; 3566 */ 3585 3567 3586 3568 cout << "Structuring style : "; 3587 3588 int strategy = 0;3589 3569 3590 3570 switch (Me.m_current_structuring_style) … … 3602 3582 cout << "Build strategy : "; 3603 3583 3604 if (p == 0) strategy = Me.m_current_build_strategy; 3605 else strategy = p->get_build_strategy (); 3584 if (get_strategy ("BuildPrototypes")) 3585 { 3586 cout << "prototypes"; 3587 } 3588 else 3589 { 3590 cout << "no_prototypes"; 3591 } 3606 3592 3607 if ((strategy & PrototypesMask) == Prototypes) 3608 { 3609 cout << "prototypes"; 3610 } 3611 else 3612 { 3613 cout << "no_prototypes"; 3614 } 3615 3616 if ((strategy & InstallAreaMask) == WithInstallArea) 3593 if (get_strategy ("InstallArea")) 3617 3594 { 3618 3595 cout << " with_installarea"; … … 3627 3604 cout << "Setup strategy : "; 3628 3605 3629 strategy = get_setup_strategy (); 3630 3631 if ((strategy & SetupConfigMask) == SetupConfig) 3606 if (get_strategy ("SetupConfig")) 3632 3607 { 3633 3608 cout << "config"; … … 3638 3613 } 3639 3614 3640 if ( (strategy & SetupRootMask) == SetupRoot)3615 if (get_strategy ("SetupRoot")) 3641 3616 { 3642 3617 cout << " root"; … … 3647 3622 } 3648 3623 3649 if ( (strategy & SetupCleanupMask) == SetupCleanup)3624 if (get_strategy ("SetupCleanup")) 3650 3625 { 3651 3626 cout << " cleanup"; … … 3802 3777 { 3803 3778 return (Me.m_current_access); 3804 }3805 3806 int Cmt::get_current_build_strategy ()3807 {3808 return (Me.m_current_build_strategy);3809 }3810 3811 int Cmt::get_current_setup_strategy ()3812 {3813 return (Me.m_current_setup_strategy);3814 3779 } 3815 3780 … … 4115 4080 cmt_string no_cleanup_opt; 4116 4081 4117 if ( (get_setup_strategy () & SetupCleanupMask) != SetupCleanup)4082 if (get_strategy ("SetupCleanup")) 4118 4083 { 4119 4084 no_cleanup_opt = " -no_cleanup"; … … 4307 4272 cmt_string no_cleanup_opt; 4308 4273 4309 if ( (get_setup_strategy () & SetupCleanupMask) != SetupCleanup)4274 if (get_strategy ("SetupCleanup")) 4310 4275 { 4311 4276 no_cleanup_opt = " -no_cleanup"; … … 4645 4610 bool Cmt::need_prototypes () 4646 4611 { 4647 if ( (get_build_strategy () & PrototypesMask) == Prototypes) return (true);4612 if (get_strategy ("BuildPrototypes")) return (true); 4648 4613 else return (false); 4649 4614 } … … 5680 5645 cmt_string system = CmtSystem::get_cmt_config (); 5681 5646 5682 int strategy = 0; 5683 5684 strategy = get_setup_strategy (use); 5685 5686 bool do_config = ((strategy & SetupConfigMask) == SetupConfig); 5687 bool do_root = ((strategy & SetupRootMask) == SetupRoot); 5647 bool do_config = get_strategy ("SetupConfig"); 5648 bool do_root = get_strategy ("SetupRoot"); 5688 5649 5689 5650 switch (mode) … … 7226 7187 CmtPathPattern::apply_all (); 7227 7188 7228 if ( (get_build_strategy () & InstallAreaMask) == WithInstallArea)7189 if (get_strategy ("InstallArea")) 7229 7190 { 7230 7191 CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); … … 7266 7227 7267 7228 //---------------------------------------------------------- 7268 void Cmt::set_current_build_strategy (int strategy)7269 {7270 Me.m_current_build_strategy = strategy;7271 }7272 7273 //----------------------------------------------------------7274 void Cmt::set_current_setup_strategy (int strategy)7275 {7276 Me.m_current_setup_strategy = strategy;7277 }7278 7279 //----------------------------------------------------------7280 7229 void Cmt::set_scope_filtering_mode (CmtScopeFilteringMode mode) 7281 7230 { … … 7372 7321 // 7373 7322 /* 7374 if ( (get_build_strategy () & InstallAreaMask) == WithInstallArea)7323 if (get_strategy ("InstallArea")) 7375 7324 { 7376 7325 CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance (); -
CMT/v1r19/source/cmt_project.cxx
r11 r15 153 153 Now Figure out the project name from the project file 154 154 Or construct an automatic project name when project file does no exist 155 or does not specify the project name155 or does not specify the project name 156 156 */ 157 157 if (CmtSystem::cd ("cmt") && CmtSystem::test_file (Project::get_project_file_name ())) … … 841 841 m_children.clear (); 842 842 843 m_build_strategy_mask = 0;844 m_build_strategy = DefaultBuildStrategy;845 m_setup_strategy_mask = 0;846 m_setup_strategy = DefaultSetupStrategy;847 848 843 m_configured = false; 849 844 850 m_prototypes_tag = 0; 851 m_no_prototypes_tag = 0; 852 m_with_installarea_tag = 0; 853 m_without_installarea_tag = 0; 854 855 m_setup_config_tag = 0; 856 m_setup_no_config_tag = 0; 857 m_setup_root_tag = 0; 858 m_setup_no_root_tag = 0; 859 m_setup_cleanup_tag = 0; 860 m_setup_no_cleanup_tag = 0; 845 m_strategies.clear (); 861 846 } 862 847 … … 887 872 if (parent->get_name () == p->get_name ()) 888 873 { 889 // Already registered 874 // Already registered as a parent 890 875 return; 891 876 } … … 896 881 // Since p is a new parent, we should propagate the settings UP. 897 882 898 if (m_setup_strategy_mask != 0) 899 { 900 p->set_setup_strategy (m_setup_strategy_mask, m_setup_strategy & PrototypesMask); 901 p->set_setup_strategy (m_setup_strategy_mask, m_setup_strategy & InstallAreaMask); 902 } 903 904 if (m_build_strategy_mask != 0) 905 { 906 p->set_build_strategy (m_build_strategy_mask, m_build_strategy & SetupConfigMask); 907 p->set_build_strategy (m_build_strategy_mask, m_build_strategy & SetupRootMask); 908 p->set_build_strategy (m_build_strategy_mask, m_build_strategy & SetupCleanupMask); 909 } 883 p->update_strategies_from_children (); 910 884 } 911 885 … … 936 910 if (child->get_name () == p->get_name ()) 937 911 { 938 // Already registered 912 // Already registered as a child 939 913 return; 940 914 } … … 947 921 void Project::configure () 948 922 { 949 /*950 951 <project>_prototypes952 <project>_no_prototypes953 <project>_rebuild_makefile954 <project>_keep_makefile955 <project>_with_installarea956 <project>_without_installarea957 958 <project>_setup_config959 <project>_setup_no_config960 <project>_setup_root961 <project>_setup_no_root962 <project>_setup_cleanup963 <project>_setup_no_cleanup964 965 */966 967 923 if (m_configured) return; 968 924 m_configured = true; 969 925 970 cmt_string tag_name; 971 972 tag_name = m_name; 973 tag_name += "_prototypes"; 974 m_prototypes_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 975 976 tag_name = m_name; 977 tag_name += "_no_prototypes"; 978 m_no_prototypes_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 979 980 m_prototypes_tag->add_tag_exclude (m_no_prototypes_tag); 981 m_no_prototypes_tag->add_tag_exclude (m_prototypes_tag); 982 m_prototypes_tag->mark (); 983 984 tag_name = m_name; 985 tag_name += "_with_installarea"; 986 m_with_installarea_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 987 988 tag_name = m_name; 989 tag_name += "_without_installarea"; 990 m_without_installarea_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 991 992 m_with_installarea_tag->add_tag_exclude (m_without_installarea_tag); 993 m_without_installarea_tag->add_tag_exclude (m_with_installarea_tag); 994 m_without_installarea_tag->mark (); 995 996 997 998 tag_name = m_name; 999 tag_name += "_setup_config"; 1000 m_setup_config_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 1001 1002 tag_name = m_name; 1003 tag_name += "_setup_no_config"; 1004 m_setup_no_config_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 1005 1006 m_setup_config_tag->add_tag_exclude (m_setup_no_config_tag); 1007 m_setup_no_config_tag->add_tag_exclude (m_setup_config_tag); 1008 m_setup_config_tag->mark (); 1009 1010 tag_name = m_name; 1011 tag_name += "_setup_root"; 1012 m_setup_root_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 1013 1014 tag_name = m_name; 1015 tag_name += "_setup_no_root"; 1016 m_setup_no_root_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 1017 1018 m_setup_root_tag->add_tag_exclude (m_setup_no_root_tag); 1019 m_setup_no_root_tag->add_tag_exclude (m_setup_root_tag); 1020 m_setup_root_tag->mark (); 1021 1022 tag_name = m_name; 1023 tag_name += "_setup_cleanup"; 1024 m_setup_cleanup_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 1025 1026 tag_name = m_name; 1027 tag_name += "_setup_no_cleanup"; 1028 m_setup_no_cleanup_tag = Tag::add (tag_name, PriorityConfig, "PROJECT", 0); 1029 1030 m_setup_cleanup_tag->add_tag_exclude (m_setup_no_cleanup_tag); 1031 m_setup_no_cleanup_tag->add_tag_exclude (m_setup_cleanup_tag); 1032 m_setup_cleanup_tag->mark (); 1033 1034 if (Cmt::get_debug ()) 1035 { 1036 cout << "Project::configure> " << m_name 1037 << " " << m_prototypes_tag 1038 << " " << m_no_prototypes_tag 1039 << " " << m_with_installarea_tag 1040 << " " << m_without_installarea_tag 1041 << " " << m_setup_config_tag 1042 << " " << m_setup_no_config_tag 1043 << " " << m_setup_root_tag 1044 << " " << m_setup_no_root_tag 1045 << " " << m_setup_cleanup_tag 1046 << " " << m_setup_no_cleanup_tag 1047 << endl; 1048 } 1049 } 1050 1051 //---------------------------------------------------------- 926 set_default_strategy ("SetupConfig"); 927 set_default_strategy ("SetupRoot"); 928 set_default_strategy ("SetupCleanup"); 929 set_default_strategy ("BuildPrototypes"); 930 set_default_strategy ("InstallArea"); 931 } 932 933 /**--------------------------------------------------------- 934 A use statement is met in the project file 935 */ 1052 936 void Project::use_action (const cmt_string& name, const cmt_string& release) 1053 937 { … … 1059 943 // If not: look for it 1060 944 // + get CMTPROJECTPATH 1061 // + search from all entries of CMTPROJECTPATH : p i/<name>/<release>945 // + search from all entries of CMTPROJECTPATH : p(i)/<name>/<release> 1062 946 // + when found, this should become a new CMTPATH entry 1063 947 // + the new project is then parsed ... etc... … … 1065 949 cmt_string cmtprojectpath = CmtSystem::getenv ("CMTPROJECTPATH"); 1066 950 cmt_string sep; 1067 sep += CmtSystem::path_separator ();951 sep = CmtSystem::path_separator (); 1068 952 1069 953 //cerr << "cmtprojectpath = " << cmtprojectpath << endl; … … 1081 965 if (CmtSystem::test_directory (p)) 1082 966 { 1083 //cerr << "Project direct ry " << p << " exists " << endl;967 //cerr << "Project directory " << p << " exists " << endl; 1084 968 1085 969 IProjectFactory& factory = ProjectFactory::instance (); … … 1177 1061 1178 1062 //---------------------------------------------------------- 1179 int Project::get_build_strategy () const 1180 { 1181 int result = 0; 1182 1183 result = Cmt::get_current_build_strategy (); 1184 1063 bool Project::has_strategy (const StrategyDef* definition) const 1064 { 1185 1065 int i; 1186 1066 1187 bool request_non_default_prototypes = false; 1188 bool request_non_default_installarea = false; 1189 1190 int m_prototypes = 0; 1191 int m_installarea = 0; 1067 for (i = 0; i < m_strategies.size (); i++) 1068 { 1069 const Strategy& s = m_strategies[i]; 1070 if (s.m_definition == definition) 1071 { 1072 return (true); 1073 } 1074 } 1075 1076 return (false); 1077 } 1078 1079 //---------------------------------------------------------- 1080 bool Project::get_strategy (const cmt_string& name) const 1081 { 1082 static StrategyMgr& mgr = StrategyMgr::instance (); 1083 1084 StrategyDef* def = mgr.find_strategy (name); 1085 if (def == 0) 1086 { 1087 cerr << "#CMT> strategy " << name << " undefined" << endl; 1088 return (false); 1089 } 1090 1091 return (get_strategy (def)); 1092 } 1093 1094 //---------------------------------------------------------- 1095 bool Project::is_specified (const StrategyDef* definition) const 1096 { 1097 int i; 1098 1099 for (i = 0; i < m_strategies.size (); i++) 1100 { 1101 Strategy& s = m_strategies[i]; 1102 if (s.m_definition == definition) 1103 { 1104 // This strategy is applied in this project 1105 return (s.m_specified); 1106 } 1107 } 1108 1109 // This strategy is not applied in this project 1110 return (false); 1111 } 1112 1113 //---------------------------------------------------------- 1114 bool Project::get_strategy (const StrategyDef* def) const 1115 { 1116 int i; 1117 1118 for (i = 0; i < m_strategies.size (); i++) 1119 { 1120 Strategy& s = m_strategies[i]; 1121 if (s.m_definition == def) 1122 { 1123 // This strategy is applied in this project 1124 if (s.m_specified) 1125 { 1126 return (s.m_specified_value); 1127 } 1128 return (s.m_value); 1129 } 1130 } 1131 1132 // This strategy is not applied in this project 1133 return (def->m_default_value); 1134 } 1135 1136 //---------------------------------------------------------- 1137 void Project::set_default_strategy (const cmt_string& name) 1138 { 1139 static StrategyMgr& mgr = StrategyMgr::instance (); 1140 1141 StrategyDef* def = mgr.find_strategy (name); 1142 if (def == 0) 1143 { 1144 cerr << "#CMT> strategy " << name << " undefined" << endl; 1145 return; 1146 } 1147 1148 update_strategy (def, def->m_default_value); 1149 } 1150 1151 1152 //---------------------------------------------------------- 1153 void Project::set_strategy (const cmt_string& name, const cmt_string& value) 1154 { 1155 static StrategyMgr& mgr = StrategyMgr::instance (); 1156 1157 StrategyDef* def = mgr.find_strategy (name); 1158 if (def == 0) 1159 { 1160 cerr << "#CMT> strategy " << name << " undefined" << endl; 1161 return; 1162 } 1163 1164 bool b_value = false; 1165 1166 if (value == def->m_on_value) 1167 { 1168 b_value = true; 1169 } 1170 else if (value == def->m_off_value) 1171 { 1172 b_value = false; 1173 } 1174 else 1175 { 1176 cerr << "#CMT> requested strategy value " << value << " undefined in strategy " << name << endl; 1177 return; 1178 } 1179 1180 set_strategy (def, b_value); 1181 } 1182 1183 //---------------------------------------------------------- 1184 void Project::set_strategy (StrategyDef* definition, bool b_value) 1185 { 1186 bool need_strategy = true; 1187 1188 int i; 1189 1190 for (i = 0; i < m_strategies.size (); i++) 1191 { 1192 Strategy& s = m_strategies[i]; 1193 if (s.m_definition == definition) 1194 { 1195 // This strategy is already applied in this project. Let's change it's value 1196 s.set (definition, b_value, get_name ()); 1197 need_strategy = false; 1198 break; 1199 } 1200 } 1201 1202 if (need_strategy) 1203 { 1204 // This strategy is not yet applied in this project. 1205 1206 Strategy& s = m_strategies.add (); 1207 s.set (definition, b_value, get_name ()); 1208 } 1209 1210 for (i = 0; i < m_parents.size (); i++) 1211 { 1212 Project* project = m_parents[i]; 1213 1214 project->update_strategy (definition, b_value); 1215 } 1216 } 1217 1218 /**---------------------------------------------------------- 1219 The strategy value is changed because of indirect influences 1220 - default strategy at initialization time 1221 - change in the children 1222 - change in the children list 1223 1224 (This is not a specification : see the set_strategy method) 1225 */ 1226 void Project::update_strategy (StrategyDef* definition, bool b_value) 1227 { 1228 bool need_strategy = true; 1229 1230 int i; 1231 1232 for (i = 0; i < m_strategies.size (); i++) 1233 { 1234 Strategy& s = m_strategies[i]; 1235 if (s.m_definition == definition) 1236 { 1237 // This strategy is already applied in this project. Let's change it's value 1238 s.update (definition, b_value, get_name ()); 1239 need_strategy = false; 1240 break; 1241 } 1242 } 1243 1244 if (need_strategy) 1245 { 1246 // This strategy is not yet applied in this project. 1247 1248 Strategy& s = m_strategies.add (); 1249 s.update (definition, b_value, get_name ()); 1250 } 1251 1252 for (i = 0; i < m_parents.size (); i++) 1253 { 1254 Project* project = m_parents[i]; 1255 1256 if (project->has_strategy (definition)) 1257 { 1258 project->update_strategy (definition, b_value); 1259 } 1260 } 1261 } 1262 1263 /**---------------------------------------------------------- 1264 At least one of the children has changed this strategy 1265 Or the list of children has changed. 1266 We need to update the strategy value accordingly 1267 This will not change the specified value for this strategy 1268 */ 1269 void Project::update_strategy_from_children (StrategyDef* definition) 1270 { 1271 // If this strategy is specified we don't care what happens from the children 1272 1273 cerr << "Updating strategy " << definition->m_name << " from children for project " << m_name << endl; 1274 1275 int i; 1276 1277 for (i = 0; i < m_strategies.size (); i++) 1278 { 1279 Strategy& s = m_strategies[i]; 1280 if (s.m_definition == definition) 1281 { 1282 // This strategy is applied in this project. 1283 1284 if (s.m_specified) 1285 { 1286 // There will be no impact since the strategy is specified 1287 1288 cerr << "This strategy is specified in this project" << endl; 1289 return; 1290 } 1291 1292 break; 1293 } 1294 } 1295 1296 // The strategy is not specified locally so we will now figure out 1297 // which strategy has to be considered from the mixture of specifications 1298 // from all children. 1299 1300 // Algorithm: 1301 // - We consider children by pairs 1302 // - a child that specifies its strategy wins over a child that does not 1303 // - when the two children have the same level of priority we consider the priority value 1304 1305 Project* selected = 0; 1306 bool selected_is_specified = false; 1307 bool selected_value = false; 1192 1308 1193 1309 for (i = 0; i < m_children.size (); i++) 1194 1310 { 1195 const Project* p = m_children[i]; 1196 int s = p->get_build_strategy (); 1197 1198 int s_prototypes = s & ~PrototypesMask; 1199 1200 if (s_prototypes != DefaultPrototypesStrategy) 1201 { 1202 // keep it. At least one of the children has specified a non-default strategy 1203 request_non_default_prototypes = true; 1204 m_prototypes = s_prototypes; 1205 } 1206 1207 int s_installarea = s & ~InstallAreaMask; 1208 1209 if (s_installarea != DefaultInstallAreaStrategy) 1210 { 1211 // keep it. At least one of the children has specified a non-default strategy 1212 request_non_default_installarea = true; 1213 m_installarea = s_installarea; 1214 } 1215 } 1216 1217 if (m_build_strategy_mask != 0) 1218 { 1219 result &= ~m_build_strategy_mask; 1220 result |= m_build_strategy; 1311 Project* p = m_children[i]; 1312 1313 cerr << "Checking strategy for child " << p->get_name () << endl; 1314 1315 bool is_specified = p->is_specified (definition); 1316 bool value = p->get_strategy (definition); 1317 1318 if (selected == 0) 1319 { 1320 selected = p; 1321 selected_is_specified = is_specified; 1322 selected_value = value; 1323 continue; 1324 } 1325 1326 if (is_specified == selected_is_specified) 1327 { 1328 if (selected_value != value) 1329 { 1330 // same level of priority but different values -> we must decide 1331 bool priority_value = definition->m_priority_value; 1332 if (value == priority_value) 1333 { 1334 selected = p; 1335 selected_is_specified = is_specified; 1336 selected_value = value; 1337 } 1338 } 1339 } 1340 else 1341 { 1342 if (is_specified) 1343 { 1344 selected = p; 1345 selected_is_specified = is_specified; 1346 selected_value = value; 1347 } 1348 } 1349 } 1350 1351 update_strategy (definition, selected_value); 1352 } 1353 1354 /**---------------------------------------------------------- 1355 At least one of the children has changed its strategies 1356 Or the list of children has changed. 1357 We need to update the strategy values accordingly 1358 This will not change the specified values 1359 */ 1360 void Project::update_strategies_from_children () 1361 { 1362 StrategyDef::StrategyDefs& defs = StrategyMgr::get_definitions (); 1363 1364 cerr << "Updating strategies from children for project " << m_name << endl; 1365 1366 int i; 1367 1368 for (i = 0; i < defs.size (); i++) 1369 { 1370 StrategyDef* def = defs[i]; 1371 1372 update_strategy_from_children (def); 1373 } 1374 } 1375 1376 /**---------------------------------------------------------- 1377 The StrategyMgr singleton 1378 */ 1379 StrategyMgr& StrategyMgr::instance () 1380 { 1381 static StrategyMgr me; 1382 return (me); 1383 } 1384 1385 /**---------------------------------------------------------- 1386 The StrategyMgr constructor 1387 Here are primarily constructed all strategy definitions 1388 */ 1389 StrategyMgr::StrategyMgr () 1390 { 1391 m_defs.clear (); 1392 1393 StrategyDef* s; 1394 1395 s = new StrategyDef; 1396 s->m_name = "BuildPrototypes"; 1397 s->m_on_value = "prototypes"; 1398 s->m_off_value = "no_prototypes"; 1399 s->m_default_value = true; 1400 s->m_priority_value = false; 1401 1402 m_defs.push_back (s); 1403 1404 s = new StrategyDef; 1405 s->m_name = "InstallArea"; 1406 s->m_on_value = "with_installarea"; 1407 s->m_off_value = "without_installarea"; 1408 s->m_default_value = false; 1409 s->m_priority_value = true; 1410 1411 m_defs.push_back (s); 1412 1413 s = new StrategyDef; 1414 s->m_name = "SetupConfig"; 1415 s->m_on_value = "config"; 1416 s->m_off_value = "no_config"; 1417 s->m_default_value = true; 1418 s->m_priority_value = false; 1419 1420 m_defs.push_back (s); 1421 1422 s = new StrategyDef; 1423 s->m_name = "SetupRoot"; 1424 s->m_on_value = "root"; 1425 s->m_off_value = "no_root"; 1426 s->m_default_value = true; 1427 s->m_priority_value = false; 1428 1429 m_defs.push_back (s); 1430 1431 s = new StrategyDef; 1432 s->m_name = "SetupCleanup"; 1433 s->m_on_value = "cleanup"; 1434 s->m_off_value = "no_cleanup"; 1435 s->m_default_value = true; 1436 s->m_priority_value = false; 1437 1438 m_defs.push_back (s); 1439 } 1440 1441 /**---------------------------------------------------------- 1442 Find a strategy definition by its name 1443 */ 1444 StrategyDef* StrategyMgr::find_strategy (const cmt_string& name) 1445 { 1446 static StrategyMgr& me = instance (); 1447 1448 int i; 1449 1450 for (i = 0; i < me.m_defs.size (); i++) 1451 { 1452 StrategyDef* def = me.m_defs[i]; 1453 if (def->m_name == name) 1454 { 1455 return (def); 1456 } 1457 } 1458 1459 return (0); 1460 } 1461 1462 /**---------------------------------------------------------- 1463 Retreive the default value defined for a given strategy 1464 */ 1465 bool StrategyMgr::get_default_strategy (const cmt_string& name) 1466 { 1467 StrategyDef* def = find_strategy (name); 1468 if (def == 0) return (false); 1469 return (def->m_default_value); 1470 } 1471 1472 /**---------------------------------------------------------- 1473 Retreive the priority value defined for a given strategy 1474 This value is used when two children of a project request two conflicting strategy values 1475 */ 1476 bool StrategyMgr::get_priority_strategy (const cmt_string& name) 1477 { 1478 StrategyDef* def = find_strategy (name); 1479 if (def == 0) return (false); 1480 return (def->m_priority_value); 1481 } 1482 1483 /**---------------------------------------------------------- 1484 Return the vector of all existing strategy definitions 1485 */ 1486 StrategyDef::StrategyDefs& StrategyMgr::get_definitions () 1487 { 1488 static StrategyMgr& me = instance (); 1489 1490 return (me.m_defs); 1491 } 1492 1493 /**---------------------------------------------------------- 1494 Specify a new value for this strategy. 1495 This only happens when a strategy statement is met in a project file or in a requirements file. 1496 */ 1497 void Strategy::set (StrategyDef* definition, bool value, const cmt_string& project_name) 1498 { 1499 m_definition = definition; 1500 m_specified = true; 1501 m_specified_value = value; 1502 1503 update (definition, value, project_name); 1504 } 1505 1506 /**---------------------------------------------------------- 1507 Change the effective value for this strategy. 1508 This has no impact on to the specified value. 1509 This will adapt the tag settings 1510 */ 1511 void Strategy::update (StrategyDef* definition, bool value, const cmt_string& project_name) 1512 { 1513 m_value = value; 1514 1515 cmt_string to_tag_name = project_name; 1516 cmt_string to_untag_name = project_name; 1517 1518 to_tag_name += "_"; 1519 to_untag_name += "_"; 1520 1521 if (m_value) 1522 { 1523 to_tag_name += m_definition->m_on_value; 1524 to_untag_name += m_definition->m_off_value; 1221 1525 } 1222 1526 else 1223 1527 { 1224 if (request_non_default_prototypes) 1225 { 1226 result |= m_prototypes; 1227 } 1228 1229 if (request_non_default_installarea) 1230 { 1231 result |= m_installarea; 1232 } 1233 } 1234 1235 return (result); 1236 } 1237 1238 //---------------------------------------------------------- 1239 int Project::get_setup_strategy () const 1240 { 1241 int result = 0; 1242 1243 /* 1244 if (m_reference != 0) result = m_reference->get_setup_strategy (); 1245 else if (m_predecessor != 0) result = m_predecessor->get_setup_strategy (); 1246 else result = Cmt::get_current_setup_strategy (); 1247 */ 1248 1249 result = Cmt::get_current_setup_strategy (); 1250 1251 if (m_setup_strategy_mask != 0) 1252 { 1253 result &= ~m_setup_strategy_mask; 1254 result |= m_setup_strategy; 1255 } 1256 1257 return (result); 1258 } 1259 1260 //---------------------------------------------------------- 1261 void Project::set_build_strategy (int mask, int strategy) 1262 { 1263 m_build_strategy_mask |= mask; 1264 m_build_strategy &= ~mask; 1265 m_build_strategy |= strategy; 1266 1267 cmt_string to_tag_name = m_name; 1268 cmt_string to_untag_name = m_name; 1269 1270 Tag* to_tag = 0; 1271 Tag* to_untag = 0; 1272 1273 switch (strategy) 1274 { 1275 case Prototypes: 1276 to_tag_name += "_prototypes"; 1277 to_untag_name += "_no_prototypes"; 1278 break; 1279 case NoPrototypes: 1280 to_tag_name += "_no_prototypes"; 1281 to_untag_name += "_prototypes"; 1282 break; 1283 case WithInstallArea: 1284 to_tag_name += "_with_installarea"; 1285 to_untag_name += "_without_installarea"; 1286 break; 1287 case WithoutInstallArea: 1288 to_tag_name += "_without_installarea"; 1289 to_untag_name += "_with_installarea"; 1290 break; 1291 } 1292 1293 to_tag = Tag::find (to_tag_name); 1294 to_untag = Tag::find (to_untag_name); 1295 1296 if (to_untag != 0) 1297 { 1298 to_untag->unmark (); 1299 } 1300 1301 if (to_tag != 0) 1302 { 1303 to_tag->mark (); 1304 } 1305 1306 for (int i = 0; i < m_parents.size (); i++) 1307 { 1308 Project* project = m_parents[i]; 1309 1310 if ((project->m_build_strategy_mask & mask) == 0) 1311 { 1312 project->set_build_strategy (mask, strategy); 1313 } 1314 } 1315 } 1316 1317 //---------------------------------------------------------- 1318 void Project::set_setup_strategy (int mask, int strategy) 1319 { 1320 m_setup_strategy_mask |= mask; 1321 m_setup_strategy &= ~mask; 1322 m_setup_strategy |= strategy; 1323 1324 cmt_string to_tag_name = m_name; 1325 cmt_string to_untag_name = m_name; 1326 1327 Tag* to_tag = 0; 1328 Tag* to_untag = 0; 1329 1330 switch (strategy) 1331 { 1332 case SetupConfig: 1333 to_tag_name += "_setup_config"; 1334 to_untag_name += "_setup_no_config"; 1335 break; 1336 case SetupNoConfig: 1337 to_tag_name += "_setup_no_config"; 1338 to_untag_name += "_setup_config"; 1339 break; 1340 case SetupRoot: 1341 to_tag_name += "_setup_root"; 1342 to_untag_name += "_setup_no_root"; 1343 break; 1344 case SetupNoRoot: 1345 to_tag_name += "_setup_no_root"; 1346 to_untag_name += "_setup_root"; 1347 break; 1348 case SetupCleanup: 1349 to_tag_name += "_setup_cleanup"; 1350 to_untag_name += "_setup_no_cleanup"; 1351 break; 1352 case SetupNoCleanup: 1353 to_tag_name += "_setup_no_cleanup"; 1354 to_untag_name += "_setup_cleanup"; 1355 break; 1356 } 1357 1358 to_tag = Tag::find (to_tag_name); 1359 to_untag = Tag::find (to_untag_name); 1360 1361 if (to_untag != 0) 1362 { 1363 to_untag->unmark (); 1364 } 1365 1366 if (to_tag != 0) 1367 { 1368 to_tag->mark (); 1369 } 1370 1371 for (int i = 0; i < m_parents.size (); i++) 1372 { 1373 Project* project = m_parents[i]; 1374 1375 if ((project->m_setup_strategy_mask & mask) == 0) 1376 { 1377 project->set_setup_strategy (mask, strategy); 1378 } 1379 } 1380 } 1381 1528 to_tag_name += m_definition->m_off_value; 1529 to_untag_name += m_definition->m_on_value; 1530 } 1531 1532 m_on_tag = Tag::find (to_tag_name); 1533 m_off_tag = Tag::find (to_untag_name); 1534 1535 if (m_on_tag == 0) 1536 { 1537 m_on_tag = Tag::add (to_tag_name, PriorityConfig, "PROJECT", 0); 1538 m_off_tag = Tag::add (to_untag_name, PriorityConfig, "PROJECT", 0); 1539 1540 m_on_tag->add_tag_exclude (m_off_tag); 1541 m_off_tag->add_tag_exclude (m_on_tag); 1542 } 1543 1544 m_off_tag->unmark (); 1545 m_on_tag->mark (); 1546 } 1547 1548 const cmt_string& StrategyDef::get_default_value () const 1549 { 1550 if (m_default_value) 1551 { 1552 return (m_on_value); 1553 } 1554 else 1555 { 1556 return (m_off_value); 1557 } 1558 } 1559 -
CMT/v1r19/source/cmt_project.h
r11 r15 13 13 14 14 class Project; 15 16 class StrategyDef 17 { 18 public: 19 typedef cmt_vector <StrategyDef*> StrategyDefs; 20 21 cmt_string m_name; 22 cmt_string m_on_value; 23 cmt_string m_off_value; 24 bool m_default_value; 25 bool m_priority_value; 26 27 const cmt_string& get_default_value () const; 28 }; 29 30 class Strategy 31 { 32 public: 33 StrategyDef* m_definition; 34 bool m_specified; 35 bool m_specified_value; 36 bool m_value; 37 Tag* m_on_tag; 38 Tag* m_off_tag; 39 40 void set (StrategyDef* definition, bool value, const cmt_string& project_name); 41 void update (StrategyDef* definition, bool value, const cmt_string& project_name); 42 }; 43 44 class StrategyMgr 45 { 46 public: 47 static StrategyMgr& instance (); 48 static StrategyDef* find_strategy (const cmt_string& name); 49 static bool get_default_strategy (const cmt_string& name); 50 static bool get_priority_strategy (const cmt_string& name); 51 static StrategyDef::StrategyDefs& get_definitions (); 52 53 private: 54 StrategyMgr (); 55 StrategyDef::StrategyDefs m_defs; 56 }; 15 57 16 58 class ProjectFactory : public IProjectFactory … … 110 152 void show (); 111 153 void show_strategies () const; 112 int get_build_strategy () const; 113 int get_setup_strategy () const; 114 void set_build_strategy (int mask, int strategy); 115 void set_setup_strategy (int mask, int strategy); 154 155 bool has_strategy (const StrategyDef* definition) const; 156 bool is_specified (const StrategyDef* definition) const; 157 bool get_strategy (const StrategyDef* definition) const; 158 bool get_strategy (const cmt_string& name) const; 159 void set_default_strategy (const cmt_string& name); 160 void set_strategy (const cmt_string& name, const cmt_string& value); 161 void set_strategy (StrategyDef* definition, bool b_value); 162 void update_strategy (StrategyDef* definition, bool b_value); 163 void update_strategy_from_children (StrategyDef* definition); 164 void update_strategies_from_children (); 116 165 117 166 void visit (IProjectVisitor& visitor); … … 133 182 cmt_string m_cmtpath_source; 134 183 135 int m_build_strategy_mask;136 int m_build_strategy;137 int m_setup_strategy_mask;138 int m_setup_strategy;139 140 184 bool m_configured; 141 185 142 Tag* m_prototypes_tag; 143 Tag* m_no_prototypes_tag; 144 Tag* m_with_installarea_tag; 145 Tag* m_without_installarea_tag; 146 147 Tag* m_setup_config_tag; 148 Tag* m_setup_no_config_tag; 149 Tag* m_setup_root_tag; 150 Tag* m_setup_no_root_tag; 151 Tag* m_setup_cleanup_tag; 152 Tag* m_setup_no_cleanup_tag; 153 186 cmt_vector <Strategy> m_strategies; 154 187 }; 155 188 -
CMT/v1r19/source/cmt_syntax.cxx
r11 r15 118 118 { 119 119 public: 120 bool decode (const cmt_string& w, 121 int& mask, 122 int& strategy) 120 bool decode (const cmt_string& w, cmt_string& strategy, cmt_string& value) 123 121 { 124 122 bool result = true; 125 123 124 value = w; 125 126 126 if (w == "prototypes") 127 127 { 128 mask = PrototypesMask; 129 strategy = Prototypes; 128 strategy = "BuildPrototypes"; 130 129 } 131 130 else if (w == "no_prototypes") 132 131 { 133 mask = PrototypesMask; 134 strategy = NoPrototypes; 132 strategy = "BuildPrototypes"; 135 133 } 136 134 else if ((w == "with_installarea") || (w == "with_install_area")) 137 135 { 138 mask = InstallAreaMask;139 strategy = WithInstallArea;136 value = "with_installarea"; 137 strategy = "InstallArea"; 140 138 } 141 139 else if ((w == "without_installarea") || (w == "without_install_area")) 142 140 { 143 mask = InstallAreaMask;144 strategy = WithoutInstallArea;141 value = "without_installarea"; 142 strategy = "InstallArea"; 145 143 } 146 144 else … … 168 166 const cmt_string& w = words[i]; 169 167 170 int mask = 0;171 int strategy = 0;168 cmt_string strategy; 169 cmt_string value; 172 170 173 171 bool in_error = false; 174 172 175 if (!decode (w, mask, strategy)) 173 if (decode (w, strategy, value)) 174 { 175 if (p != 0) p->set_strategy (strategy, value); 176 } 177 else 176 178 { 177 179 in_error = true; 178 180 179 181 CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); 180 }181 182 if (mask != 0)183 {184 if (p == 0) Cmt::set_current_build_strategy (strategy);185 else p->set_build_strategy (mask, strategy);186 182 } 187 183 … … 211 207 const cmt_string& w = words[i]; 212 208 213 int mask = 0;214 int strategy = 0;209 cmt_string strategy; 210 cmt_string value; 215 211 216 212 bool in_error = false; 217 213 218 if (!decode (w, mask, strategy)) 214 if (decode (w, strategy, value)) 215 { 216 if (project != 0) project->set_strategy (strategy, value); 217 } 218 else 219 219 { 220 220 in_error = true; 221 221 222 222 CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); 223 }224 225 if (mask != 0)226 {227 if (project == 0) Cmt::set_current_build_strategy (strategy);228 else project->set_build_strategy (mask, strategy);229 223 } 230 224 … … 729 723 { 730 724 public: 731 bool decode (const cmt_string& w, int& mask, int& strategy)725 bool decode (const cmt_string& w, cmt_string& strategy, cmt_string& value) 732 726 { 733 727 bool result = true; 734 728 729 value = w; 730 735 731 if (w == "config") 736 732 { 737 mask = SetupConfigMask; 738 strategy = SetupConfig; 733 strategy = "SetupConfig"; 739 734 } 740 735 else if (w == "no_config") 741 736 { 742 mask = SetupConfigMask; 743 strategy = SetupNoConfig; 737 strategy = "SetupConfig"; 744 738 } 745 739 else if (w == "root") 746 740 { 747 mask = SetupRootMask; 748 strategy = SetupRoot; 741 strategy = "SetupRoot"; 749 742 } 750 743 else if (w == "no_root") 751 744 { 752 mask = SetupRootMask; 753 strategy = SetupNoRoot; 745 strategy = "SetupRoot"; 754 746 } 755 747 else if (w == "cleanup") 756 748 { 757 mask = SetupCleanupMask; 758 strategy = SetupCleanup; 749 strategy = "SetupCleanup"; 759 750 } 760 751 else if (w == "no_cleanup") 761 752 { 762 mask = SetupCleanupMask; 763 strategy = SetupNoCleanup; 753 strategy = "SetupCleanup"; 764 754 } 765 755 else … … 787 777 const cmt_string& w = words[i]; 788 778 789 int mask = 0;790 int strategy = 0;779 cmt_string strategy; 780 cmt_string value; 791 781 792 782 bool in_error = false; 793 783 794 if (!decode (w, mask, strategy)) 784 if (decode (w, strategy, value)) 785 { 786 if (p != 0) p->set_strategy (strategy, value); 787 } 788 else 795 789 { 796 790 in_error = true; 797 791 798 792 CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); 799 }800 801 if (mask != 0)802 {803 if (p == 0) Cmt::set_current_setup_strategy (strategy);804 else p->set_setup_strategy (mask, strategy);805 793 } 806 794 … … 830 818 const cmt_string& w = words[i]; 831 819 832 int mask = 0;833 int strategy = 0;820 cmt_string strategy; 821 cmt_string value; 834 822 835 823 bool in_error = false; 836 824 837 if (!decode (w, mask, strategy)) 825 if (decode (w, strategy, value)) 826 { 827 if (project != 0) project->set_strategy (strategy, value); 828 } 829 else 838 830 { 839 831 in_error = true; 840 832 841 833 CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); 842 }843 844 if (mask != 0)845 {846 if (project == 0) Cmt::set_current_setup_strategy (strategy);847 else project->set_setup_strategy (mask, strategy);848 834 } 849 835
Note: See TracChangeset
for help on using the changeset viewer.