This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathfrt.cc
76 lines (64 loc) · 1.53 KB
/
frt.cc
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
// frt.cc
/*
FRT - A Godot platform targeting single board computers
Copyright (c) 2017-2023 Emanuele Fornara
SPDX-License-Identifier: MIT
*/
#include "frt.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#define FRT_VERSION "2.1.0"
#define FRT_STATUS "stable"
static void print_msg(const char *format, va_list ap) {
fprintf(stderr, "frt: ");
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
}
namespace frt {
void warn(const char *format, ...) {
va_list ap;
va_start(ap, format);
print_msg(format, ap);
va_end(ap);
}
void fatal(const char *format, ...) {
va_list ap;
va_start(ap, format);
print_msg(format, ap);
va_end(ap);
exit(1);
}
extern const char *commit_id;
extern const char *license;
} // namespace frt
#include "frt_lib.h"
static void usage(const char *program_name, int code) {
printf("\n"
"usage: %s [godot args] [--frt [options]]\n"
"\n"
"options:\n"
" -v show version and exit\n"
" -l show license and exit\n"
" -h show this page and exit\n"
"\n", program_name);
exit(code);
}
extern "C" void frt_parse_frt_args(int argc, char *argv[]) {
const char *program_name = argv[0];
for (int i = 1; i < argc; i++) {
const char *s = argv[i];
if (!strcmp(s, "-v")) {
printf("%s.%s.%s\n", FRT_VERSION, FRT_STATUS, frt::commit_id);
exit(0);
} else if (!strcmp(s, "-l")) {
puts(frt::license);
exit(0);
} else if (!strcmp(s, "-h")) {
usage(program_name, 0);
} else {
usage(program_name, 1);
}
}
}