diff options
author | dec05eba <dec05eba@protonmail.com> | 2017-12-08 00:49:15 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2017-12-08 00:50:04 +0100 |
commit | bf24f6fc48b4eebb06cdcd7029d1d31d4c6028dd (patch) | |
tree | b9cb68dc44e002586a1e09aeb60bb42f75258758 /src/main.cpp | |
parent | 3fc89b69ff3fc937a0cde32c2fae9ce3b3cf1ebc (diff) |
Added loading of project file and file validations
Next up: parse project.conf file
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..d49ae1f --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,76 @@ +#include <cstdio> +#include "../include/FileUtil.hpp" +#include "../include/Conf.hpp" +#include <string> + +using namespace std; +using namespace sibs; + +void usage() +{ + printf("Simple build system for native languages\n"); + printf("usage:\n"); + printf(" sibs <project path>\n"); + printf("option:\n"); + printf(" project path: Path containing project.conf\n"); + printf("examples:\n"); + printf(" sibs myProject"); + exit(1); +} + +void validateProjectPath(const char *projectPath) +{ + FileType projectPathFileType = getFileType(projectPath); + if(projectPathFileType == FileType::FILE_NOT_FOUND) + { + perror(projectPath); + exit(2); + } + else if(projectPathFileType == FileType::REGULAR) + { + printf("Expected project path (%s) to be a directory, was a file", projectPath); + exit(3); + } +} + +void validateProjectConfPath(const char *projectConfPath) +{ + FileType projectConfFileType = getFileType(projectConfPath); + if(projectConfFileType == FileType::FILE_NOT_FOUND) + { + perror(projectConfPath); + exit(4); + } + else if(projectConfFileType == FileType::DIRECTORY) + { + printf("Expected project conf (%s) to be a directory, was a file", projectConfPath); + exit(5); + } +} + + +int main(int argc, const char **argv) +{ + if(argc != 2) + usage(); + + const char *projectPath = argv[1]; + validateProjectPath(projectPath); + + string projectConfFilePath = projectPath; + projectConfFilePath += "/project.conf"; + validateProjectConfPath(projectConfFilePath.c_str()); + + auto result = readConf(projectConfFilePath.c_str()); + if(result.isOk()) + { + + } + else + { + printf("Failed to read config: %s\n", result.getErrMsg()); + exit(6); + } + + return 0; +}
\ No newline at end of file |