@@ -1175,6 +1175,50 @@ runcpp2::HandleBuildOutput( const ghc::filesystem::path& target,
11751175 return PipelineResult::SUCCESS;
11761176}
11771177
1178+ runcpp2::PipelineResult
1179+ runcpp2::GetTargetPath ( const ghc::filesystem::path& buildDir,
1180+ const std::string& scriptName,
1181+ const Data::Profile& profile,
1182+ const std::unordered_map<CmdOptions, std::string>& currentOptions,
1183+ ghc::filesystem::path& outTarget)
1184+ {
1185+ std::string exeExt = " " ;
1186+ #ifdef _WIN32
1187+ exeExt = " .exe" ;
1188+ #endif
1189+
1190+ std::error_code _;
1191+ outTarget = buildDir;
1192+
1193+ const std::string* targetSharedLibExt =
1194+ runcpp2::GetValueFromPlatformMap (profile.FilesTypes .SharedLibraryFile .Extension );
1195+
1196+ const std::string* targetSharedLibPrefix =
1197+ runcpp2::GetValueFromPlatformMap (profile.FilesTypes .SharedLibraryFile .Prefix );
1198+
1199+ if (currentOptions.find (CmdOptions::EXECUTABLE) != currentOptions.end ())
1200+ outTarget = (outTarget / scriptName).concat (exeExt);
1201+ else
1202+ {
1203+ if (targetSharedLibExt == nullptr || targetSharedLibPrefix == nullptr )
1204+ {
1205+ ssLOG_ERROR (" Shared library extension or prefix not found in compiler profile" );
1206+ return PipelineResult::INVALID_PROFILE;
1207+ }
1208+
1209+ outTarget = (outTarget / *targetSharedLibPrefix).concat (scriptName)
1210+ .concat (*targetSharedLibExt);
1211+ }
1212+
1213+ if (!ghc::filesystem::exists (outTarget, _))
1214+ {
1215+ ssLOG_ERROR (" Failed to find the compiled file: " << outTarget.string ());
1216+ return PipelineResult::COMPILE_LINK_FAILED;
1217+ }
1218+
1219+ return PipelineResult::SUCCESS;
1220+ }
1221+
11781222runcpp2::PipelineResult
11791223runcpp2::StartPipeline ( const std::string& scriptPath,
11801224 const std::vector<Data::Profile>& profiles,
@@ -1418,43 +1462,15 @@ runcpp2::StartPipeline( const std::string& scriptPath,
14181462
14191463 // Run the compiled file at script directory
14201464 {
1421- std::string exeExt = " " ;
1422- #ifdef _WIN32
1423- exeExt = " .exe" ;
1424- #endif
1425-
1426- std::error_code _;
1427- ghc::filesystem::path target = buildDir;
1428-
1429- const std::string* targetSharedLibExt =
1430- runcpp2::GetValueFromPlatformMap (profiles.at (profileIndex) .FilesTypes
1431- .SharedLibraryFile
1432- .Extension );
1433-
1434- const std::string* targetSharedLibPrefix =
1435- runcpp2::GetValueFromPlatformMap (profiles.at (profileIndex) .FilesTypes
1436- .SharedLibraryFile
1437- .Prefix );
1438-
1439- if (currentOptions.find (CmdOptions::EXECUTABLE) != currentOptions.end ())
1440- target = (target / scriptName).concat (exeExt);
1441- else
1442- {
1443- if (targetSharedLibExt == nullptr || targetSharedLibPrefix == nullptr )
1444- {
1445- ssLOG_ERROR (" Shared library extension or prefix not found in compiler profile" );
1446- return PipelineResult::INVALID_PROFILE;
1447- }
1448-
1449- target = (target / *targetSharedLibPrefix) .concat (scriptName)
1450- .concat (*targetSharedLibExt);
1451- }
1452-
1453- if (!ghc::filesystem::exists (target, _))
1454- {
1455- ssLOG_ERROR (" Failed to find the compiled file: " << target.string ());
1456- return PipelineResult::COMPILE_LINK_FAILED;
1457- }
1465+ ghc::filesystem::path target;
1466+ result = GetTargetPath ( buildDir,
1467+ scriptName,
1468+ profiles.at (profileIndex),
1469+ currentOptions,
1470+ target);
1471+
1472+ if (result != PipelineResult::SUCCESS)
1473+ return result;
14581474
14591475 if (currentOptions.count (CmdOptions::BUILD) == 0 )
14601476 {
0 commit comments