diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 866d691..9f14c67 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include <cstdio> #include "../include/FileUtil.hpp" #include "../include/Conf.hpp" +#include "../include/Dependency.hpp" #include "../backend/ninja/Ninja.hpp" #include <string> #include <cassert> @@ -60,6 +61,11 @@ public: assert(finishedProcessing); return packageName; } + + const std::vector<Dependency>& getDependencies() const + { + return dependencies; + } protected: void processObject(StringView name) override { @@ -96,6 +102,19 @@ protected: else throw ParserException("Expected package.name to be a single value, was a list"); } + else if(currentObject.equals("dependencies")) + { + if(value.isSingle()) + { + // TODO: Validate version is number in correct format + Dependency dependency; + dependency.name = string(name.data, name.size); + dependency.version = string(value.asSingle().data, value.asSingle().size); + dependencies.emplace_back(dependency); + } + else + throw ParserException("Expected field under dependencies to be a single value, was a list"); + } } void finished() override @@ -105,6 +124,7 @@ protected: private: StringView currentObject; string packageName; + std::vector<Dependency> dependencies; bool finishedProcessing; }; @@ -143,11 +163,11 @@ int main(int argc, const char **argv) exit(6); } - string projectSrcPath = projectPath + "/src"; - validateDirectoryPath(projectSrcPath.c_str()); + //string projectSrcPath = projectPath + "/src"; + //validateDirectoryPath(projectSrcPath.c_str()); backend::Ninja ninja; - walkDirFiles(projectSrcPath.c_str(), [&ninja, &projectPath](tinydir_file *file) + walkDirFiles(projectPath.c_str(), [&ninja, &projectPath](tinydir_file *file) { if (isSourceFile(file)) { @@ -163,7 +183,12 @@ int main(int argc, const char **argv) // TODO: Create build path if it doesn't exist string debugBuildPath = projectPath + "/build/debug"; string buildFilePath = debugBuildPath + "/build.ninja"; - ninja.build(sibsConfig.getPackageName(), buildFilePath.c_str()); + Result<bool> buildFileResult = ninja.createBuildFile(sibsConfig.getPackageName(), sibsConfig.getDependencies(), buildFilePath.c_str()); + if(buildFileResult.isErr()) + { + printf("Failed to build ninja file: %s\n", buildFileResult.getErrMsg().c_str()); + exit(7); + } return 0; }
\ No newline at end of file |