Skip to content

Commit 4994cf8

Browse files
Adding the ability to have standalone yaml file for script
1 parent 117ca2b commit 4994cf8

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

Src/runcpp2/runcpp2.cpp

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -374,36 +374,47 @@ int runcpp2::RunScript( const std::string& scriptPath,
374374
ssLOG_DEBUG("scriptName: " << scriptName);
375375
ssLOG_DEBUG("is_directory: " << ghc::filesystem::is_directory(scriptDirectory));
376376

377-
//Read from a c/cpp file
378-
//TODO: Check is it c or cpp
379-
380377
std::string exeExt = "";
381378
#ifdef _WIN32
382379
exeExt = ".exe";
383380
#endif
384381

385382
//Parsing the script, setting up dependencies, compiling and linking
386383
{
387-
std::ifstream inputFile(absoluteScriptPath);
388-
if (!inputFile)
384+
//Check if there's script info as yaml file instead
385+
std::error_code e;
386+
std::string parsableInfo;
387+
std::ifstream inputFile;
388+
std::string dedicatedYamlLoc = ProcessPath(scriptDirectory + "/" + scriptName + ".yaml");
389+
if(ghc::filesystem::exists(dedicatedYamlLoc, e))
389390
{
390-
ssLOG_ERROR("Failed to open file: " << absoluteScriptPath);
391-
return -1;
391+
inputFile.open(dedicatedYamlLoc);
392+
std::stringstream buffer;
393+
buffer << inputFile.rdbuf();
394+
parsableInfo = buffer.str();
392395
}
393-
394-
std::stringstream buffer;
395-
buffer << inputFile.rdbuf();
396-
std::string source(buffer.str());
397-
398-
std::string parsableInfo;
399-
if(!GetParsableInfo(source, parsableInfo))
396+
else
400397
{
401-
ssLOG_ERROR("An error has been encountered when parsing info: " << absoluteScriptPath);
402-
return -1;
398+
inputFile.open(absoluteScriptPath);
399+
400+
if (!inputFile)
401+
{
402+
ssLOG_ERROR("Failed to open file: " << absoluteScriptPath);
403+
return -1;
404+
}
405+
406+
std::stringstream buffer;
407+
buffer << inputFile.rdbuf();
408+
std::string source(buffer.str());
409+
410+
if(!GetParsableInfo(source, parsableInfo))
411+
{
412+
ssLOG_ERROR("An error has been encountered when parsing info: " <<
413+
absoluteScriptPath);
414+
return -1;
415+
}
403416
}
404417

405-
//TODO: Check if there's script info as yaml file instead
406-
407418
//Try to parse the runcpp2 info
408419
Data::ScriptInfo scriptInfo;
409420
if(!ParseScriptInfo(parsableInfo, scriptInfo))

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
- Add System Source Type for dependencies
55
- Allow cache to be in the config folder
66
- Output compile_command.json
7-
- Allow script info as standalone yaml file
87
- Allow Languages to override FileExtensions in compiler profile (?)

0 commit comments

Comments
 (0)