-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from mwasplund/mwasplund/tasks
Mwasplund/tasks
- Loading branch information
Showing
87 changed files
with
4,824 additions
and
3,355 deletions.
There are no files selected for viewing
Submodule SoupBuildEx
updated
from 330f96 to 510f88
Submodule SoupTest
updated
from bc4f59 to 6743a1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
// <copyright file="BuildGraphNode.h" company="Soup"> | ||
// Copyright (c) Soup. All rights reserved. | ||
// </copyright> | ||
|
||
#pragma once | ||
|
||
namespace Soup::Build | ||
{ | ||
/// <summary> | ||
/// A graph node that represents a single operation in the build | ||
/// </summary> | ||
export class BuildGraphNode | ||
{ | ||
private: | ||
inline static std::atomic<int> UniqueId = 0; | ||
|
||
public: | ||
BuildGraphNode( | ||
std::string title, | ||
Path program, | ||
std::string arguments, | ||
Path workingDirectory, | ||
std::vector<Path> inputFiles, | ||
std::vector<Path> outputFiles) : | ||
_id(UniqueId++), | ||
_title(std::move(title)), | ||
_program(std::move(program)), | ||
_arguments(std::move(arguments)), | ||
_workingDirectory(std::move(workingDirectory)), | ||
_inputFiles(std::move(inputFiles)), | ||
_outputFiles(std::move(outputFiles)), | ||
_children() | ||
{ | ||
} | ||
|
||
BuildGraphNode( | ||
std::string title, | ||
Path program, | ||
std::string arguments, | ||
Path workingDirectory, | ||
std::vector<Path> inputFiles, | ||
std::vector<Path> outputFiles, | ||
std::vector<std::shared_ptr<BuildGraphNode>> children) : | ||
_id(UniqueId++), | ||
_title(std::move(title)), | ||
_program(std::move(program)), | ||
_arguments(std::move(arguments)), | ||
_workingDirectory(std::move(workingDirectory)), | ||
_inputFiles(std::move(inputFiles)), | ||
_outputFiles(std::move(outputFiles)), | ||
_children(std::move(children)) | ||
{ | ||
} | ||
|
||
static void AddLeafChild( | ||
std::shared_ptr<BuildGraphNode>& parent, | ||
std::shared_ptr<BuildGraphNode>& child) | ||
{ | ||
if (parent == child) | ||
{ | ||
// TODO: Clean up, the node has been added through a different path | ||
return; | ||
} | ||
|
||
if (parent->_children.empty()) | ||
{ | ||
// Add the new leaf node | ||
parent->_children.push_back(child); | ||
} | ||
else | ||
{ | ||
// Continue on to the current parents children | ||
AddLeafChild(parent->_children, child); | ||
} | ||
} | ||
|
||
static void AddLeafChild( | ||
std::vector<std::shared_ptr<BuildGraphNode>>& parents, | ||
std::shared_ptr<BuildGraphNode>& child) | ||
{ | ||
for (auto& parent : parents) | ||
{ | ||
AddLeafChild(parent, child); | ||
} | ||
} | ||
|
||
static void AddLeafChildren( | ||
std::shared_ptr<BuildGraphNode>& parent, | ||
std::vector<std::shared_ptr<BuildGraphNode>>& children) | ||
{ | ||
if (parent->_children.empty()) | ||
{ | ||
// Add the new leaf node | ||
parent->_children.insert(parent->_children.end(), children.begin(), children.end()); | ||
} | ||
else | ||
{ | ||
// Continue on to the current parents children | ||
AddLeafChildren(parent->_children, children); | ||
} | ||
} | ||
|
||
static void AddLeafChildren( | ||
std::vector<std::shared_ptr<BuildGraphNode>>& parents, | ||
std::vector<std::shared_ptr<BuildGraphNode>>& children) | ||
{ | ||
for (auto& parent : parents) | ||
{ | ||
AddLeafChildren(parent, children); | ||
} | ||
} | ||
|
||
int GetId() const | ||
{ | ||
return _id; | ||
} | ||
|
||
const std::string& GetTitle() const | ||
{ | ||
return _title; | ||
} | ||
|
||
const Path& GetProgram() const | ||
{ | ||
return _program; | ||
} | ||
|
||
const std::string& GetArguments() const | ||
{ | ||
return _arguments; | ||
} | ||
|
||
const Path& GetWorkingDirectory() const | ||
{ | ||
return _workingDirectory; | ||
} | ||
|
||
const std::vector<Path>& GetInputFiles() const | ||
{ | ||
return _inputFiles; | ||
} | ||
|
||
const std::vector<Path>& GetOutputFiles() const | ||
{ | ||
return _outputFiles; | ||
} | ||
|
||
const std::vector<std::shared_ptr<BuildGraphNode>>& GetChildren() const | ||
{ | ||
return _children; | ||
} | ||
|
||
private: | ||
int _id; | ||
std::string _title; | ||
Path _program; | ||
std::string _arguments; | ||
Path _workingDirectory; | ||
std::vector<Path> _inputFiles; | ||
std::vector<Path> _outputFiles; | ||
std::vector<std::shared_ptr<BuildGraphNode>> _children; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// <copyright file="IBuildState.h" company="Soup"> | ||
// Copyright (c) Soup. All rights reserved. | ||
// </copyright> | ||
|
||
#pragma once | ||
|
||
namespace Soup::Build | ||
{ | ||
/// <summary> | ||
/// Build State Extension interface | ||
/// </summary> | ||
class IBuildState | ||
{ | ||
public: | ||
virtual bool HasProperty(const char* name) = 0; | ||
virtual const std::any& GetProperty(const char* name) = 0; | ||
virtual void SetProperty(const char* name, std::any value) = 0; | ||
|
||
virtual void AddBuildNode(std::shared_ptr<BuildGraphNode> node) = 0; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// <copyright file="IBuildSystem.h" company="Soup"> | ||
// Copyright (c) Soup. All rights reserved. | ||
// </copyright> | ||
|
||
#pragma once | ||
|
||
namespace Soup::Build | ||
{ | ||
/// <summary> | ||
/// Build System Extension interface | ||
/// </summary> | ||
export class IBuildSystem | ||
{ | ||
public: | ||
virtual void RegisterTask(std::shared_ptr<IBuildTask> task) = 0; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// <copyright file="IBuildTask.h" company="Soup"> | ||
// Copyright (c) Soup. All rights reserved. | ||
// </copyright> | ||
|
||
#pragma once | ||
#include "IBuildState.h" | ||
|
||
namespace Soup::Build | ||
{ | ||
/// <summary> | ||
/// Build Task Extension interface | ||
/// </summary> | ||
class IBuildTask | ||
{ | ||
public: | ||
virtual const char* GetName() = 0; | ||
virtual void Execute(IBuildState& state) = 0; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module; | ||
|
||
#include <any> | ||
#include <atomic> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
export module SoupBuildExtension; | ||
import Opal; | ||
|
||
using namespace Opal; | ||
|
||
#include "BuildGraphNode.h" | ||
#include "IBuildTask.h" | ||
#include "IBuildSystem.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "Module.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "SoupBuildExtension", | ||
"version": "1.0.0", | ||
"public": "Module.cpp", | ||
"dependencies": [ | ||
"../../Opal/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.