@@ -30,29 +30,17 @@ namespace
3030 const runcpp2::Data::ProfilesFlagsOverride& currentFlagsOverride =
3131 *runcpp2::GetValueFromPlatformMap (overrideFlags);
3232
33- std::string foundProfileName;
34- std::vector<std::string> currentProfileNames;
35- profile.GetNames (currentProfileNames);
33+ const runcpp2::Data::FlagsOverrideInfo* profileFlagsOverride =
34+ runcpp2::GetValueFromProfileMap (profile, currentFlagsOverride.FlagsOverrides );
3635
37- for (int i = 0 ; i < currentProfileNames.size (); ++i)
38- {
39- if (currentFlagsOverride.FlagsOverrides .count (currentProfileNames.at (i)) > 0 )
40- {
41- foundProfileName = currentProfileNames.at (i);
42- break ;
43- }
44- }
45-
46- if (foundProfileName.empty ())
36+ if (!profileFlagsOverride)
4737 {
4838 ssLOG_INFO (" No override flags found for current profile" );
4939 return ;
5040 }
5141
5242 std::vector<std::string> flagsToRemove;
53- runcpp2::SplitString ( currentFlagsOverride.FlagsOverrides .at (foundProfileName).Remove ,
54- " " ,
55- flagsToRemove);
43+ runcpp2::SplitString (profileFlagsOverride->Remove , " " , flagsToRemove);
5644
5745 for (int i = 0 ; i < flagsToRemove.size (); ++i)
5846 {
@@ -74,7 +62,7 @@ namespace
7462 }
7563
7664 runcpp2::TrimRight (inOutFlags);
77- inOutFlags += " " + currentFlagsOverride. FlagsOverrides . at (foundProfileName). Append ;
65+ inOutFlags += " " + profileFlagsOverride-> Append ;
7866 runcpp2::TrimRight (inOutFlags);
7967 }
8068
@@ -132,27 +120,14 @@ namespace
132120 const runcpp2::Data::ProfilesDefines& platformDefines =
133121 *runcpp2::GetValueFromPlatformMap (scriptInfo.Defines );
134122
135- std::vector<std::string> profileNames;
136- profile. GetNames (profileNames );
123+ const std::vector<runcpp2::Data::Define>* profileDefines =
124+ runcpp2::GetValueFromProfileMap ( profile, platformDefines. Defines );
137125
138- std::string validProfileName;
139- for (int i = 0 ; i < profileNames.size (); ++i)
126+ if (profileDefines)
140127 {
141- if (platformDefines.Defines .count (profileNames[i]) > 0 )
142- {
143- validProfileName = profileNames.at (i);
144- break ;
145- }
146- }
147-
148- if (!validProfileName.empty ())
149- {
150- const std::vector<runcpp2::Data::Define>& profileDefines =
151- platformDefines.Defines .at (validProfileName);
152-
153- for (int i = 0 ; i < profileDefines.size (); ++i)
128+ for (int i = 0 ; i < profileDefines->size (); ++i)
154129 {
155- const runcpp2::Data::Define& define = profileDefines. at (i);
130+ const runcpp2::Data::Define& define = profileDefines-> at (i);
156131 if (define.HasValue )
157132 {
158133 substitutionMapTemplate[" {DefineName}" ].push_back (define.Name );
@@ -755,34 +730,20 @@ bool runcpp2::CompileAndLinkScript( const ghc::filesystem::path& buildDir,
755730 // Add link flags for the dependencies
756731 for (int i = 0 ; i < availableDependencies.size (); ++i)
757732 {
758- std::string targetProfileName;
759- std::vector<std::string> currentProfileNames;
760- profile.GetNames (currentProfileNames);
761-
762- for (int j = 0 ; j < currentProfileNames.size (); ++j)
763- {
764- if ( availableDependencies.at (i)->LinkProperties .find (currentProfileNames.at (j)) !=
765- availableDependencies.at (i)->LinkProperties .end ())
766- {
767- targetProfileName = currentProfileNames.at (j);
768- break ;
769- }
770- }
771-
772- if (targetProfileName.empty ())
733+ if (!runcpp2::HasValueFromPlatformMap (availableDependencies.at (i)->LinkProperties ))
773734 continue ;
774735
775- const runcpp2::Data::DependencyLinkProperty& currentLinkProperty =
776- availableDependencies.at (i)->LinkProperties . at (targetProfileName );
736+ const runcpp2::Data::DependencyLinkProperty& linkProperty =
737+ * runcpp2::GetValueFromPlatformMap ( availableDependencies.at (i)->LinkProperties );
777738
778- if (runcpp2::HasValueFromPlatformMap (currentLinkProperty.AdditionalLinkOptions ))
779- {
780- const std::vector<std::string> additionalLinkOptions =
781- *runcpp2::GetValueFromPlatformMap (currentLinkProperty.AdditionalLinkOptions );
739+ const runcpp2::Data::ProfileLinkProperty* profileLinkProperty =
740+ runcpp2::GetValueFromProfileMap (profile, linkProperty.ProfileProperties );
782741
783- for (int k = 0 ; k < additionalLinkOptions.size (); ++k)
784- dependenciesLinkFlags += additionalLinkOptions.at (k) + " " ;
785- }
742+ if (!profileLinkProperty)
743+ continue ;
744+
745+ for (const std::string& option : profileLinkProperty->AdditionalLinkOptions )
746+ dependenciesLinkFlags += option + " " ;
786747 }
787748
788749 runcpp2::TrimRight (dependenciesLinkFlags);
0 commit comments