Skip to content

Commit 503bb0f

Browse files
Moving local functions to cpp, adding TODOs
1 parent e9ab86c commit 503bb0f

File tree

8 files changed

+236
-171
lines changed

8 files changed

+236
-171
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/filesystem")
2121
# =========================================================================
2222
# Generate yaml files as c
2323
# =========================================================================
24+
# TODO(NOW): Use target instead
2425
if(RUNCPP2_UPDATE_DEFAULT_YAMLS)
2526
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C")
2627
include("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C/embedFile.cmake")

DefaultYAMLs/DefaultCompilerProfiles.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ CompilerProfiles:
7979
# {LinkFlags}, {OutputFile}, {ObjectFile} will be replaced accordingly
8080
OutputPart: "{LinkFlags} -o {OutputFile} {ObjectFile}"
8181

82+
# TODO(NOW): If the thing we want to link is libabc.a (or .so)
83+
# -l either accepts -labc or -l:abc.a
84+
8285
# Syntax for linking each dependency.
86+
# TODO(NOW): Rename to {DependencyFile}
8387
# {DependencyName} will be replaced accordingly
84-
DependenciesPart: "-l{DependencyName}"
88+
DependenciesPart: "-l:{DependencyName}"

Include/runcpp2/runcpp2.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace runcpp2
1616
COUNT
1717
};
1818

19-
bool CreateRuncpp2ScriptDirectory(const std::string& scriptPath);
20-
2119
//--------------------------------------------
2220
//Running
2321
//--------------------------------------------
@@ -26,9 +24,6 @@ namespace runcpp2
2624
const std::string& configPreferredProfile,
2725
const std::unordered_map<CmdOptions, std::string> currentOptions,
2826
const std::vector<std::string>& runArgs);
29-
30-
31-
3227
}
3328

3429

Src/runcpp2/CompilerProfileHelper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ namespace
6363
const std::string& scriptPath)
6464
{
6565
std::string scriptExtension = ghc::filesystem::path(scriptPath).extension().string();
66+
if(!scriptExtension.empty())
67+
scriptExtension.erase(0, 1);
6668

67-
if(profile.FileExtensions.find(scriptExtension.substr(1)) == profile.FileExtensions.end())
69+
if(profile.FileExtensions.find(scriptExtension) == profile.FileExtensions.end())
6870
return false;
6971

7072
if(!scriptInfo.Language.empty())

Src/runcpp2/CompilingLinking.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ namespace
172172
if(statusCode != 0)
173173
{
174174
ssLOG_ERROR("Compile command returned with non-zero status code: " << statusCode);
175+
ssLOG_BASE(output.data());
175176
return false;
176177
}
177178

@@ -328,6 +329,7 @@ namespace
328329
if(statusCode != 0)
329330
{
330331
ssLOG_ERROR("Link command returned with non-zero status code: " << statusCode);
332+
ssLOG_BASE(output.data());
331333
return false;
332334
}
333335

Src/runcpp2/DependenciesSetupHelper.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ namespace
265265
System2CommandInfo setupCommandInfo;
266266
SYSTEM2_RESULT result = System2Run(setupCommand.c_str(), &setupCommandInfo);
267267

268+
ssLOG_INFO("Running setup command: " << setupCommand);
269+
268270
if(result != SYSTEM2_RESULT_SUCCESS)
269271
{
270272
ssLOG_ERROR("Failed to run setup command with result: " << result);
@@ -302,6 +304,8 @@ namespace
302304
ssLOG_ERROR("Output: " << output);
303305
return false;
304306
}
307+
308+
ssLOG_INFO("Output: " << output);
305309
}
306310
}
307311

@@ -560,14 +564,14 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
560564
if(scriptInfo.Dependencies.at(i).LibraryType == DependencyLibraryType::HEADER)
561565
return true;
562566

563-
const DependencySearchProperty& searchProperty = scriptInfo .Dependencies
567+
const DependencyLinkProperty& searchProperty = scriptInfo .Dependencies
564568
.at(i)
565-
.SearchProperties
569+
.LinkProperties
566570
.at(profile.Name);
567571

568572
//Get the Search path and search library name
569-
if( scriptInfo.Dependencies.at(i).SearchProperties.find(profile.Name) ==
570-
scriptInfo.Dependencies.at(i).SearchProperties.end())
573+
if( scriptInfo.Dependencies.at(i).LinkProperties.find(profile.Name) ==
574+
scriptInfo.Dependencies.at(i).LinkProperties.end())
571575
{
572576
ssLOG_ERROR("Search properties for dependency " << scriptInfo.Dependencies.at(i).Name <<
573577
" is missing profile " << profile.Name);
@@ -583,8 +587,11 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
583587
std::string currentSearchLibraryName = searchProperty.SearchLibraryNames.at(j);
584588
std::string currentSearchDirectory = searchProperty.SearchDirectories.at(k);
585589

590+
ssLOG_DEBUG("currentSearchDirectory: " << currentSearchDirectory);
591+
ssLOG_DEBUG("currentSearchLibraryName: " << currentSearchLibraryName);
592+
586593
if(!ghc::filesystem::path(currentSearchDirectory).is_absolute())
587-
currentSearchDirectory = scriptDirectory + "/" + currentSearchDirectory;
594+
currentSearchDirectory = dependenciesCopiesPaths[i] + "/" + currentSearchDirectory;
588595

589596
std::error_code _;
590597
if( !ghc::filesystem::exists(currentSearchDirectory, _) ||
@@ -601,6 +608,10 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
601608

602609
std::string currentFileName = it.path().stem().string();
603610
std::string currentExtension = it.path().extension().string();
611+
if(!currentExtension.empty())
612+
currentExtension.erase(0, 1);
613+
614+
ssLOG_DEBUG("currentFileName: " << currentFileName);
604615

605616
//TODO: Make it not case sensitive?
606617
bool nameMatched = false;
@@ -624,14 +635,18 @@ bool runcpp2::CopyDependenciesBinaries( const std::string& scriptPath,
624635
if(!extensionMatched)
625636
continue;
626637

627-
if(!ghc::filesystem::copy_file( it.path(),
628-
runcpp2ScriptDir,
629-
ghc::filesystem::copy_options::overwrite_existing,
630-
_))
638+
std::error_code copyErrorCode;
639+
ghc::filesystem::copy( it.path(),
640+
runcpp2ScriptDir,
641+
ghc::filesystem::copy_options::overwrite_existing,
642+
copyErrorCode);
643+
644+
if(copyErrorCode)
631645
{
632646
ssLOG_ERROR("Failed to copy file from " << it.path().string() <<
633647
" to " << runcpp2ScriptDir);
634648

649+
ssLOG_ERROR("Error: " << copyErrorCode.message());
635650
return false;
636651
}
637652

Src/runcpp2/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ int main(int argc, char* argv[])
2626
return 1;
2727
}
2828

29+
30+
2931
std::unordered_map<std::string, runcpp2::CmdOptions> optionsMap =
3032
{
3133
{"--setup", runcpp2::CmdOptions::SETUP}

0 commit comments

Comments
 (0)