Skip to content

Commit 1bdeaf1

Browse files
Adding support for setup build and cleanup steps for dependency
1 parent 2259738 commit 1bdeaf1

File tree

10 files changed

+425
-277
lines changed

10 files changed

+425
-277
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ add_executable(runcpp2
7979
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/CompilingLinking.cpp"
8080
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ConfigParsing.cpp"
8181
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c"
82-
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DependenciesSetupHelper.cpp"
82+
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DependenciesHelper.cpp"
8383
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/main.cpp"
8484
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ParseUtil.cpp"
8585
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/PlatformUtil.cpp"

DefaultYAMLs/DefaultScriptInfo.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RequiredProfiles:
1919

2020
# (Optional) Override the default compile flags for each platform
2121
OverrideCompileFlags:
22+
# Target Platform
2223
All:
2324
# Profile with the respective flags to override
2425
"g++":
@@ -31,6 +32,7 @@ OverrideCompileFlags:
3132

3233
# (Optional) Override the default link flags for each platform
3334
OverrideLinkFlags:
35+
# Target Platform
3436
All:
3537
# Profile with the respective flags to override
3638
"g++":
@@ -77,19 +79,29 @@ Dependencies:
7779
# (Optional) Additional link options for this dependency for each platform
7880
AdditionalLinkOptions:
7981
All: []
80-
81-
# TODO: Cleanup?
82-
83-
# TODO: Build?
84-
8582

86-
# (Optional) List of setup commands for each platform
83+
# (Optional) Setup commands are run once when the dependency is populated
8784
Setup:
85+
# Target Platform
8886
All:
8987
# Setup shell commands for the specified profile.
9088
# All commands are run in the dependency folder
9189
# You can also use "All" if all the compilers run the same setup commands
9290
"g++":
9391
- "mkdir build"
92+
93+
94+
# (Optional) Build commands are run every time before the script is being built
95+
Build:
96+
# Target Platform
97+
All:
98+
"g++":
9499
- "cd build && cmake .."
95100
- "cd build && cmake --build ."
101+
102+
# (Optional) Cleanup commands are run when the reset option is present. Normally nothing needs
103+
# to be done since the dependency folder will be removed automatically.
104+
# Cleanup:
105+
# Linux:
106+
# "g++":
107+
# - "sudo apt purge MyLibrary"

Examples/test.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@
1818
SearchDirectories: ["./build", "./build/Debug", "./build/Release"]
1919
Setup:
2020
Windows:
21-
"msvc":
21+
"All":
2222
- "if not exist build mkdir build"
23-
- "cd build && cmake .. -DssLOG_BUILD_TYPE=SHARED"
24-
- "cd build && cmake --build . --config Release -j 16"
2523
Unix:
26-
"g++":
24+
"All":
2725
- "mkdir -p build"
26+
Build:
27+
All:
28+
"All":
2829
- "cd build && cmake .. -DssLOG_BUILD_TYPE=SHARED"
2930
- "cd build && cmake --build . --config Release -j 16"
3031
*/
31-
32+
3233

3334
//#include "ssLogger/ssLogInit.hpp"
3435

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef RUNCPP2_DEPENDENCIES_SETUP_HELPER_HPP
2+
#define RUNCPP2_DEPENDENCIES_SETUP_HELPER_HPP
3+
4+
#include "runcpp2/Data/DependencyInfo.hpp"
5+
#include "runcpp2/Data/ScriptInfo.hpp"
6+
#include "runcpp2/Data/Profile.hpp"
7+
#include <vector>
8+
9+
namespace runcpp2
10+
{
11+
bool GetDependenciesPaths( const std::vector<Data::DependencyInfo*>& availableDependencies,
12+
std::vector<std::string>& outCopiesPaths,
13+
std::vector<std::string>& outSourcesPaths,
14+
const std::string& scriptPath);
15+
16+
bool IsDependencyAvailableForThisPlatform(const Data::DependencyInfo& dependency);
17+
18+
bool CleanupDependencies( const runcpp2::Data::Profile& profile,
19+
const std::string& scriptPath,
20+
const Data::ScriptInfo& scriptInfo,
21+
const std::vector<Data::DependencyInfo*>& availableDependencies,
22+
const std::vector<std::string>& dependenciesLocalCopiesPaths);
23+
24+
bool SetupDependencies( const runcpp2::Data::Profile& profile,
25+
const std::string& scriptPath,
26+
const Data::ScriptInfo& scriptInfo,
27+
std::vector<Data::DependencyInfo*>& availableDependencies,
28+
const std::vector<std::string>& dependenciesLocalCopiesPaths,
29+
const std::vector<std::string>& dependenciesSourcePaths);
30+
31+
bool BuildDependencies( const runcpp2::Data::Profile& profile,
32+
const std::string& scriptPath,
33+
const Data::ScriptInfo& scriptInfo,
34+
const std::vector<Data::DependencyInfo*>& availableDependencies,
35+
const std::vector<std::string>& dependenciesLocalCopiesPaths);
36+
37+
bool CopyDependenciesBinaries( const std::string& scriptPath,
38+
const std::vector<Data::DependencyInfo*>& availableDependencies,
39+
const std::vector<std::string>& dependenciesCopiesPaths,
40+
const Data::Profile& profile,
41+
std::vector<std::string>& outCopiedBinariesPaths);
42+
}
43+
44+
#endif

Include/runcpp2/DependenciesSetupHelper.hpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

Include/runcpp2/runcpp2.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace runcpp2
1616
RESET_USER_CONFIG,
1717
EXECUTABLE,
1818
HELP,
19+
REMOVE_DEPENDENCIES,
1920
COUNT
2021
};
2122

Src/runcpp2/CompilingLinking.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "runcpp2/CompilingLinking.hpp"
2-
#include "runcpp2/DependenciesSetupHelper.hpp"
2+
#include "runcpp2/DependenciesHelper.hpp"
33
#include "runcpp2/PlatformUtil.hpp"
44
#include "runcpp2/StringUtil.hpp"
55
#include "runcpp2/Data/ScriptInfo.hpp"
@@ -387,12 +387,12 @@ namespace
387387

388388
for(int i = 0; i < copiedDependenciesBinariesPaths.size(); ++i)
389389
{
390-
size_t extensionFoundIndex = copiedDependenciesBinariesPaths[i].find_last_of(".");
390+
size_t extensionFoundIndex = copiedDependenciesBinariesPaths.at(i).find_last_of(".");
391391

392392
//Check if this is a file we can link
393393
std::string extension;
394394
if(extensionFoundIndex != std::string::npos)
395-
extension = copiedDependenciesBinariesPaths[i].substr(extensionFoundIndex);
395+
extension = copiedDependenciesBinariesPaths.at(i).substr(extensionFoundIndex);
396396

397397
using namespace runcpp2;
398398
Data::DependencyLibraryType currentLinkType = Data::DependencyLibraryType::COUNT;
@@ -409,6 +409,9 @@ namespace
409409
goto processLinkFile;
410410
}
411411

412+
//TODO: Shared and static link file cannot be differentiated with just
413+
// file extension because they are the same. We should pass the dependency in
414+
// instead
412415
if(!HasValueFromPlatformMap(profile.FilesTypes.SharedLinkFile.Extension))
413416
{
414417
ssLOG_WARNING( "profile " << profile.Name << " missing extension for " <<

0 commit comments

Comments
 (0)