1
2
3
4
5
6 #ifndef SNGCM_AST_PROJECT_INCLUDED
7 #define SNGCM_AST_PROJECT_INCLUDED
8 #include <sngcm/ast/AstApi.hpp>
9 #include <boost/filesystem.hpp>
10 #include <string>
11 #include <vector>
12 #include <memory>
13
14 namespace sngcm { namespace ast {
15
16 enum class BackEnd
17 {
18 llvm, cmsx
19 };
20
21 class ModuleVersionTagVerifier
22 {
23 public:
24 virtual void VerifyModuleVersionTag(const std::string& moduleFilePath) = 0;
25 };
26
27 void SetModuleVersionTagVerifier(ModuleVersionTagVerifier* verifier);
28
29 std::string CmajorRootDir();
30 std::string CmajorSystemLibDir(const std::string& config, BackEnd backend);
31 std::string CmajorResourceDir();
32 std::string CmajorSystemModuleFilePath(const std::string& config, BackEnd backend);
33 std::string CmajorSystemWindowsModuleFilePath(const std::string& config);
34 void SetOutDir(const std::string& outDir_);
35 const std::string& OutDir();
36
37 enum class ProjectDeclarationType : uint8_t
38 {
39 referenceDeclaration, sourceFileDeclaration, resourceFileDeclaration, textFileDeclaration, targetDeclaration
40 };
41
42 class ProjectDeclaration
43 {
44 public:
45 ProjectDeclaration(ProjectDeclarationType declarationType_);
46 ProjectDeclaration(const ProjectDeclaration&) = delete;
47 ProjectDeclaration& operator=(const ProjectDeclaration&) = delete;
48 virtual ~ProjectDeclaration();
49 ProjectDeclarationType GetDeclarationType() const { return declarationType; }
50 private:
51 ProjectDeclarationType declarationType;
52 };
53
54 class ReferenceDeclaration : public ProjectDeclaration
55 {
56 public:
57 ReferenceDeclaration(const std::string& filePath_);
58 const std::string& FilePath() const { return filePath; }
59 private:
60 std::string filePath;
61 };
62
63 class SourceFileDeclaration : public ProjectDeclaration
64 {
65 public:
66 SourceFileDeclaration(const std::string& filePath_);
67 const std::string& FilePath() const { return filePath; }
68 private:
69 std::string filePath;
70 };
71
72 class ResourceFileDeclaration : public ProjectDeclaration
73 {
74 public:
75 ResourceFileDeclaration(const std::string& filePath_);
76 const std::string& FilePath() const { return filePath; }
77 private:
78 std::string filePath;
79 };
80
81 class TextFileDeclaration : public ProjectDeclaration
82 {
83 public:
84 TextFileDeclaration(const std::string& filePath_);
85 const std::string& FilePath() const { return filePath; }
86 private:
87 std::string filePath;
88 };
89
90 enum class Target
91 {
92 program, winguiapp, winapp, library, winlib, unitTest
93 };
94
95 class TargetDeclaration : public ProjectDeclaration
96 {
97 public:
98 TargetDeclaration(Target target_);
99 Target GetTarget() const { return target; }
100 private:
101 Target target;
102 };
103
104 class Project
105 {
106 public:
107 Project(const std::u32string& name_, const std::string& filePath_, const std::string& config_, BackEnd backend);
108 Project(const Project&) = delete;
109 Project& operator=(const Project&) = delete;
110 const std::u32string& Name() const { return name; }
111 const std::string& FilePath() const { return filePath; }
112 const boost::filesystem::path& SourceBasePath() const { return sourceBasePath; }
113 const boost::filesystem::path& OutdirBasePath() const { return outdirBasePath; }
114 void AddDeclaration(ProjectDeclaration* declaration);
115 void ResolveDeclarations();
116 const std::string& ModuleFilePath() const { return moduleFilePath; }
117 const std::string& LibraryFilePath() const { return libraryFilePath; }
118 const std::string& ExecutableFilePath() const { return executableFilePath; }
119 const std::std::vector<std::string>&References() const{returnreferences;}
120 const std::std::vector<std::string>&ReferencedProjectFilePaths() const{returnreferencedProjectFilePaths;}
121 const std::std::vector<std::string>&RelativeReferencedProjectFilePaths() const{returnrelativeReferencedProjectFilePaths;}
122 const std::std::vector<std::string>&SourceFilePaths() const{returnsourceFilePaths;}
123 const std::std::vector<std::string>&RelativeSourceFilePaths() const{returnrelativeSourceFilePaths;}
124 const std::std::vector<std::string>&ResourceFilePaths() const{returnresourceFilePaths; }
125 const std::std::vector<std::string>&RelativeResourceFilePaths() const{returnrelativeResourceFilePaths;}
126 const std::std::vector<std::string>&RelativeTextFilePaths() const{returnrelativeTextFilePaths;}
127 const std::std::vector<std::string>&TextFilePaths() const{returntextFilePaths;}
128 Target GetTarget() const { return target; }
129 bool DependsOn(Project* that) const;
130 void AddDependsOnProjects(Project* dependsOnProject);
131 bool IsSystemProject() const { return isSystemProject; }
132 void SetSystemProject() { isSystemProject = true; }
133 void SetRelativeFilePath(const std::string& relativeFilePath_) { relativeFilePath = relativeFilePath_; }
134 const std::string& RelativeFilePath() const { return relativeFilePath; }
135 void SetModuleFilePath(const std::string& moduleFilePath_);
136 void SetLibraryFilePath(const std::string& libraryFilePath_);
137 bool IsUpToDate(const std::string& systemModuleFilePath) const;
138 int LogStreamId() const { return logStreamId; }
139 void SetLogStreamId(int logStreamId_) { logStreamId = logStreamId_; }
140 void SetIndex(int index_) { index = index_; }
141 int Index() const { return index; }
142 const std::std::vector<Project*>&DependsOnProjects(){returndependsOn;}
143 bool Built() const { return built; }
144 void SetBuilt() { built = true; }
145 bool Ready() const;
146 void SetExcludeSourceFilePath(const std::string& excludeSourceFilePath_);
147 private:
148 std::u32string name;
149 std::string filePath;
150 std::string config;
151 Target target;
152 boost::filesystem::path sourceBasePath;
153 boost::filesystem::path outdirBasePath;
154 boost::filesystem::path systemLibDir;
155 std::vector<std::std::unique_ptr<ProjectDeclaration>>declarations;
156 std::string relativeFilePath;
157 std::string moduleFilePath;
158 std::string libraryFilePath;
159 std::string executableFilePath;
160 std::string excludeSourceFilePath;
161 std::vector<std::string> references;
162 std::vector<std::string> referencedProjectFilePaths;
163 std::vector<std::string> sourceFilePaths;
164 std::vector<std::string> relativeSourceFilePaths;
165 std::vector<std::string> resourceFilePaths;
166 std::vector<std::string> relativeResourceFilePaths;
167 std::vector<std::string> relativeReferencedProjectFilePaths;
168 std::vector<std::string> relativeTextFilePaths;
169 std::vector<std::string> textFilePaths;
170 std::vector<Project*> dependsOn;
171 bool built;
172 bool isSystemProject;
173 int logStreamId;
174 int index;
175 };
176
177
178 } }
179
180 #endif // SNGCM_AST_PROJECT_INCLUDED