Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions DefaultYAMLs/DefaultScriptInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,18 @@ Dependencies:

# The source of getting the dependency (Git, Local)
Source:
# Git: Dependency exists in a git server, and needs to be cloned
# (Optional) Import dependency configuration from a YAML file
# For Git source: Path is relative to the git repository root
# For Local source: Path is relative to the script directory.
# If neither source exists, local source with root script directory is assumed.
# ImportPath: "config/dependency.yaml"

# Git: Dependency or import YAML file exists in a git server, and needs to be cloned.
Git:
# Git repository URL
URL: "https://github.com/MyUser/MyLibrary.git"

# Local: Dependency exists in local filesystem
# Local: Dependency or import YAML file exists in local filesystem
# Local:
# # Path to the library directory
# Path: "./libs/LocalLibrary"
Expand Down
11 changes: 11 additions & 0 deletions Examples/TestImport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Name: "System2.cpp"
Platforms: [DefaultPlatform]
Source:
Git:
URL: "https://github.com/Neko-Box-Coder/System2.cpp.git"
LibraryType: Header
IncludePaths: [".", "./External/System2"]
Setup:
DefaultPlatform:
DefaultProfile:
- "git submodule update --init --recursive"
22 changes: 13 additions & 9 deletions Examples/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,20 @@ PassScriptPath: true
- "./Include/ssLogger/ssLog.hpp"

- Name: System2.cpp
Platforms: [DefaultPlatform]
Source:
Git:
URL: "https://github.com/Neko-Box-Coder/System2.cpp.git"
LibraryType: Header
IncludePaths: [".", "./External/System2"]
Setup:
DefaultPlatform:
DefaultProfile:
- "git submodule update --init --recursive"
ImportPath: "./TestImport.yaml"

# - Name: System2.cpp
# Platforms: [DefaultPlatform]
# Source:
# Git:
# URL: "https://github.com/Neko-Box-Coder/System2.cpp.git"
# LibraryType: Header
# IncludePaths: [".", "./External/System2"]
# Setup:
# DefaultPlatform:
# DefaultProfile:
# - "git submodule update --init --recursive"
*/


Expand Down
6 changes: 6 additions & 0 deletions Include/runcpp2/Data/DependencySource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#include "runcpp2/Data/GitSource.hpp"
#include "runcpp2/Data/LocalSource.hpp"
#include "runcpp2/YamlLib.hpp"
#include "ghc/filesystem.hpp"
#include "mpark/variant.hpp"

#include <memory>
#include <vector>

namespace runcpp2
{
namespace Data
Expand All @@ -14,6 +18,8 @@ namespace runcpp2
{
public:
mpark::variant<GitSource, LocalSource> Source;
ghc::filesystem::path ImportPath;
std::vector<std::shared_ptr<DependencySource>> ImportedSources;

bool ParseYAML_Node(ryml::ConstNodeRef& node);
std::string ToString(std::string indentation) const;
Expand Down
7 changes: 7 additions & 0 deletions Include/runcpp2/DependenciesHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ namespace runcpp2
const std::vector<std::string>& dependenciesCopiesPaths,
const Data::Profile& profile,
std::vector<std::string>& outBinariesPaths);

bool HandleImport( Data::DependencyInfo& dependency,
const ghc::filesystem::path& basePath);

bool ResolveImports(Data::ScriptInfo& scriptInfo,
const ghc::filesystem::path& scriptPath,
const ghc::filesystem::path& buildDir);
}

#endif
4 changes: 4 additions & 0 deletions Include/runcpp2/PipelineSteps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ namespace runcpp2
BuildsManager& outBuildsManager,
ghc::filesystem::path& outBuildDir,
IncludeManager& outIncludeManager);

PipelineResult ResolveScriptImports(Data::ScriptInfo& scriptInfo,
const ghc::filesystem::path& scriptPath,
const ghc::filesystem::path& buildDir);

PipelineResult CheckScriptInfoChanges( const ghc::filesystem::path& buildDir,
const Data::ScriptInfo& scriptInfo,
Expand Down
2 changes: 1 addition & 1 deletion Src/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target_compile_definitions(IncludeManagerTest PRIVATE INTERNAL_RUNCPP2_UNIT_TEST
function(create_data_test TEST_NAME)
add_executable("${TEST_NAME}" "${CMAKE_CURRENT_LIST_DIR}/Data/${TEST_NAME}.cpp")
target_compile_options("${TEST_NAME}" PRIVATE "${STANDARD_COMPILE_FLAGS}")
target_compile_definitions("${TEST_NAME}" PRIVATE INTERNAL_RUNCPP2_UNIT_TESTS=1)
target_compile_definitions("${TEST_NAME}" PRIVATE INTERNAL_RUNCPP2_UNIT_TESTS=1 TERMCOLOR_USE_ANSI_ESCAPE_SEQUENCES=1)
target_link_libraries("${TEST_NAME}" PUBLIC runcpp2 ssTest)

endfunction()
Expand Down
28 changes: 27 additions & 1 deletion Src/runcpp2/Data/DependencyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,33 @@
bool runcpp2::Data::DependencyInfo::ParseYAML_Node(ryml::ConstNodeRef& node)
{
INTERNAL_RUNCPP2_SAFE_START();


//If import is needed, we only need to parse the Source section
do
{
if(!ExistAndHasChild(node, "Source"))
{
ssLOG_ERROR("DependencyInfo: Missing Source");
return false;
}

ryml::ConstNodeRef sourceNode = node["Source"];

if(!ExistAndHasChild(sourceNode, "ImportPath"))
break;

if(!Source.ParseYAML_Node(sourceNode))
{
ssLOG_ERROR("DependencyInfo: Failed to parse Source");
return false;
}

ssLOG_DEBUG("DependencyInfo: Importing from " << Source.ImportPath.string());
ssLOG_DEBUG("Skipping the rest of the DependencyInfo");
return true;
}
while(false);

std::vector<NodeRequirement> requirements =
{
NodeRequirement("Name", ryml::NodeType_e::KEYVAL, true, false),
Expand Down
42 changes: 37 additions & 5 deletions Src/runcpp2/Data/DependencySource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ bool runcpp2::Data::DependencySource::ParseYAML_Node(ryml::ConstNodeRef& node)
{
INTERNAL_RUNCPP2_SAFE_START();

if(ExistAndHasChild(node, "ImportPath"))
{
std::string importPathStr;
node["ImportPath"] >> importPathStr;
ImportPath = importPathStr;

if(ImportPath.is_absolute())
{
ssLOG_ERROR("DependencySource: ImportPath must be relative: " << ImportPath.string());
return false;
}
}

if(ExistAndHasChild(node, "Git"))
{
if(ExistAndHasChild(node, "Local"))
Expand Down Expand Up @@ -37,6 +50,15 @@ bool runcpp2::Data::DependencySource::ParseYAML_Node(ryml::ConstNodeRef& node)
Source = localSource;
return true;
}
//If no source is found, we need to check if it's an imported source.
//If so, we assume it's a local source with path "./"
else if(!ImportPath.empty())
{
LocalSource localSource;
localSource.Path = "./";
Source = localSource;
return true;
}

ssLOG_ERROR("DependencySource: Neither Git nor Local source found");
return false;
Expand All @@ -46,23 +68,33 @@ bool runcpp2::Data::DependencySource::ParseYAML_Node(ryml::ConstNodeRef& node)

std::string runcpp2::Data::DependencySource::ToString(std::string indentation) const
{
std::string out;
if(!ImportPath.empty())
out += indentation + "ImportPath: " + GetEscapedYAMLString(ImportPath.string()) + "\n";

if(mpark::get_if<GitSource>(&Source))
{
const GitSource* git = mpark::get_if<GitSource>(&Source);
return git->ToString(indentation);
out += git->ToString(indentation);
}
else if(mpark::get_if<LocalSource>(&Source))
{
const LocalSource* local = mpark::get_if<LocalSource>(&Source);
return local->ToString(indentation);
out += local->ToString(indentation);
}

ssLOG_ERROR("Invalid DependencySource type");
return "";
else
{
ssLOG_ERROR("Invalid DependencySource type");
return "";
}
return out;
}

bool runcpp2::Data::DependencySource::Equals(const DependencySource& other) const
{
if(ImportPath != other.ImportPath)
return false;

if(mpark::get_if<GitSource>(&Source))
{
if(mpark::get_if<GitSource>(&other.Source))
Expand Down
Loading