blob: d49ae1fd524ec9847f3b44ab8e971d4a15c2df72 (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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;
}
|