-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
63 lines (47 loc) · 1.41 KB
/
Copy pathmain.cpp
File metadata and controls
63 lines (47 loc) · 1.41 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "core/core.hpp"
#include "diag/diag.hpp"
#include "infra/print/print.hpp"
#include "infra/toml/toml.hpp"
#include <cstdlib>
#include <cstring>
s32 main(s32 argc, const char8** argv)
{
if (argc == 0)
{
print(minos::standard_file_handle(minos::StdFileName::StdErr), "No arguments provided (not even invocation)\n");
return EXIT_FAILURE;
}
else if (argc == 2 && strcmp(argv[1], "-help") == 0)
{
print_config_help(minos::standard_file_handle(minos::StdFileName::StdOut));
return EXIT_SUCCESS;
}
else if (argc == 3 && strcmp(argv[1] , "-config") == 0)
{
Config config;
TreeSchemaAllocator ts_alloc;
if (!config_from_toml_file(range::from_cstring(argv[2]), print_make_sink(minos::standard_file_handle(minos::StdFileName::StdErr)), &config, &ts_alloc))
return EXIT_FAILURE;
CoreData* const core = create_core_data(&config);
if (run_compilation(core, false))
{
print(minos::standard_file_handle(minos::StdFileName::StdErr), "Success\n");
release_core_data(core);
ts_allocator_release(ts_alloc);
return EXIT_SUCCESS;
}
else
{
print_errors(core);
print(minos::standard_file_handle(minos::StdFileName::StdErr), "\nFailure\n");
release_core_data(core);
ts_allocator_release(ts_alloc);
return EXIT_FAILURE;
}
}
else
{
print(minos::standard_file_handle(minos::StdFileName::StdErr), "Usage: % ( -help | -config <filepath> )\n", argv[0]);
return EXIT_FAILURE;
}
}