mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-14 15:41:25 +00:00
fixes for progs.src
This commit is contained in:
parent
c74fabffda
commit
0904a1ceb7
2 changed files with 42 additions and 23 deletions
2
Makefile
2
Makefile
|
@ -14,6 +14,8 @@ CXXFLAGS = \
|
||||||
-std=c++11 \
|
-std=c++11 \
|
||||||
-Wall \
|
-Wall \
|
||||||
-Wextra \
|
-Wextra \
|
||||||
|
-Wno-parentheses \
|
||||||
|
-Wno-class-memaccess \
|
||||||
-fno-exceptions \
|
-fno-exceptions \
|
||||||
-fno-rtti \
|
-fno-rtti \
|
||||||
-MD \
|
-MD \
|
||||||
|
|
63
main.cpp
63
main.cpp
|
@ -117,7 +117,7 @@ static bool options_long_gcc(const char *optname, int *argc_, char ***argv_, cha
|
||||||
return options_long_witharg_all(optname, argc_, argv_, out, 1, false);
|
return options_long_witharg_all(optname, argc_, argv_, out, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool options_parse(int argc, char **argv) {
|
static bool options_parse(int argc, char **argv, bool *has_progs_src) {
|
||||||
bool argend = false;
|
bool argend = false;
|
||||||
size_t itr;
|
size_t itr;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
@ -202,6 +202,7 @@ static bool options_parse(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (options_long_gcc("progsrc", &argc, &argv, &argarg)) {
|
if (options_long_gcc("progsrc", &argc, &argv, &argarg)) {
|
||||||
OPTS_OPTION_STR(OPTION_PROGSRC) = argarg;
|
OPTS_OPTION_STR(OPTION_PROGSRC) = argarg;
|
||||||
|
*has_progs_src = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +435,9 @@ static bool options_parse(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
item.filename = argarg;
|
item.filename = argarg;
|
||||||
vec_push(items, item);
|
vec_push(items, item);
|
||||||
|
if (item.type == TYPE_SRC) {
|
||||||
|
*has_progs_src = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
|
@ -515,13 +519,13 @@ static bool progs_nextline(char **out, size_t *alen, FILE *src) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
size_t itr;
|
size_t itr;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
bool operators_free = false;
|
bool operators_free = false;
|
||||||
bool progs_src = false;
|
bool has_progs_src = false;
|
||||||
FILE *outfile = nullptr;
|
FILE *outfile = nullptr;
|
||||||
parser_t *parser = nullptr;
|
parser_t *parser = nullptr;
|
||||||
ftepp_t *ftepp = nullptr;
|
ftepp_t *ftepp = nullptr;
|
||||||
|
|
||||||
app_name = argv[0];
|
app_name = argv[0];
|
||||||
con_init ();
|
con_init ();
|
||||||
|
@ -529,7 +533,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
util_seed(time(0));
|
util_seed(time(0));
|
||||||
|
|
||||||
if (!options_parse(argc, argv)) {
|
if (!options_parse(argc, argv, &has_progs_src)) {
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,13 +627,19 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vec_size(items)) {
|
if (!vec_size(items) && !has_progs_src) {
|
||||||
FILE *src;
|
FILE *fp = fopen(OPTS_OPTION_STR(OPTION_PROGSRC), "rb");
|
||||||
char *line = nullptr;
|
if (fp) {
|
||||||
size_t linelen = 0;
|
has_progs_src = true;
|
||||||
bool hasline = false;
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
progs_src = true;
|
if (has_progs_src) {
|
||||||
|
FILE *src;
|
||||||
|
char *line = nullptr;
|
||||||
|
size_t linelen = 0;
|
||||||
|
bool has_first_line = false;
|
||||||
|
|
||||||
src = fopen(OPTS_OPTION_STR(OPTION_PROGSRC), "rb");
|
src = fopen(OPTS_OPTION_STR(OPTION_PROGSRC), "rb");
|
||||||
if (!src) {
|
if (!src) {
|
||||||
|
@ -641,16 +651,19 @@ int main(int argc, char **argv) {
|
||||||
while (progs_nextline(&line, &linelen, src)) {
|
while (progs_nextline(&line, &linelen, src)) {
|
||||||
argitem item;
|
argitem item;
|
||||||
|
|
||||||
if (!line[0] || (line[0] == '/' && line[1] == '/'))
|
if (!line[0] || (line[0] == '/' && line[1] == '/')) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasline) {
|
if (has_first_line) {
|
||||||
item.filename = util_strdup(line);
|
item.filename = util_strdup(line);
|
||||||
item.type = TYPE_QC;
|
item.type = TYPE_QC;
|
||||||
vec_push(items, item);
|
vec_push(items, item);
|
||||||
} else if (!opts_output_wasset) {
|
} else {
|
||||||
OPTS_OPTION_DUP(OPTION_OUTPUT) = util_strdup(line);
|
if (!opts_output_wasset) {
|
||||||
hasline = true;
|
OPTS_OPTION_DUP(OPTION_OUTPUT) = util_strdup(line);
|
||||||
|
}
|
||||||
|
has_first_line = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,7 +675,7 @@ int main(int argc, char **argv) {
|
||||||
if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
|
if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
|
||||||
!OPTS_OPTION_BOOL(OPTION_PP_ONLY))
|
!OPTS_OPTION_BOOL(OPTION_PP_ONLY))
|
||||||
{
|
{
|
||||||
con_out("Mode: %s\n", (progs_src ? "progs.src" : "manual"));
|
con_out("Mode: %s\n", (has_progs_src ? "progs.src" : "manual"));
|
||||||
con_out("There are %lu items to compile:\n", (unsigned long)vec_size(items));
|
con_out("There are %lu items to compile:\n", (unsigned long)vec_size(items));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,6 +691,10 @@ int main(int argc, char **argv) {
|
||||||
("unknown"))))));
|
("unknown"))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (items[itr].type == TYPE_SRC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
|
if (OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
|
||||||
const char *out;
|
const char *out;
|
||||||
if (!ftepp_preprocess_file(ftepp, items[itr].filename)) {
|
if (!ftepp_preprocess_file(ftepp, items[itr].filename)) {
|
||||||
|
@ -713,7 +730,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progs_src) {
|
if (has_progs_src) {
|
||||||
mem_d(items[itr].filename);
|
mem_d(items[itr].filename);
|
||||||
items[itr].filename = nullptr;
|
items[itr].filename = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue