-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRplTaskMainBuild.cpp
More file actions
47 lines (37 loc) · 1.01 KB
/
RplTaskMainBuild.cpp
File metadata and controls
47 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "PrecompilationCode/PrecompTopSort.h"
using namespace std;
int main(int argc, char** argv){
if(argc <= 1){
cout << "Wrong number of inputs" << endl;
return 1;
}
//Get all task files to sort
vector<string> taskPaths;
for(int i = 1; i < argc; ++i){
taskPaths.push_back(argv[i]);
}
Graph graph;
unordered_map<string, Task> taskMap;
//Construct graph
for(string path : taskPaths){
string contents=getFileContents(path);
string taskName = getTaskName(contents);
bool isStart = isTaskStartOnBoot(contents);
vector<string> dependencies = getDependencies(contents);
Task task;
task.className = taskName;
task.startOnBoot = isStart;
graph[taskName] = dependencies;
taskMap[taskName] = task;
}
//Sort Tasks
vector<string> sorted = topologicalSort(graph);
vector<Task> sortedTasks;
for(string str : sorted){
sortedTasks.push_back(taskMap[str]);
}
//Use output strategy to create code
ArduinoStrategyPattern pattern;
outputWithOutputStrategy(sortedTasks, &pattern);
return 0;
}