mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
-p N or --strip-path N will strip up to N leading path elements for a
source file's path.
This commit is contained in:
parent
32dfbd8c11
commit
03ab75704f
4 changed files with 29 additions and 3 deletions
|
@ -14,6 +14,7 @@ GZ=.gz
|
|||
else
|
||||
GZ=
|
||||
endif
|
||||
STRIP=$(shell echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c)
|
||||
|
||||
pkgdata_DATA= menu.dat$(GZ)
|
||||
|
||||
|
@ -24,7 +25,7 @@ menu_src= \
|
|||
servlist.qc string_def.qc stringh_def.qc
|
||||
|
||||
menu.dat$(GZ): menu.src $(menu_src)
|
||||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -P $<
|
||||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -p $(STRIP) -P $<
|
||||
$(GZIP)
|
||||
|
||||
EXTRA_DIST= $(menu_src)
|
||||
|
|
|
@ -571,6 +571,7 @@ ddef_t *new_local (void);
|
|||
|
||||
int CopyString (const char *str);
|
||||
int ReuseString (const char *str);
|
||||
const char *strip_path (const char *filename);
|
||||
|
||||
typedef struct {
|
||||
qboolean cow; // Turn constants into variables if written to
|
||||
|
@ -595,6 +596,8 @@ typedef struct {
|
|||
qboolean save_temps; // save temporary files
|
||||
qboolean files_dat; // generate files.dat
|
||||
qboolean traditional; // behave more like qcc
|
||||
int strip_path; // number of leading path elements to strip
|
||||
// from source file names
|
||||
} options_t;
|
||||
|
||||
extern options_t options;
|
||||
|
|
|
@ -138,7 +138,7 @@ m ([\-+]?)
|
|||
while (*p && *p != '\n') // ignore flags
|
||||
p++;
|
||||
pr_source_line = line - 1;
|
||||
s_file = ReuseString (s);
|
||||
s_file = ReuseString (strip_path (s));
|
||||
free (s);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ static struct option const long_options[] = {
|
|||
{"version", no_argument, 0, 'V'},
|
||||
{"files", no_argument, 0, 'F'},
|
||||
{"traditional", no_argument, 0, 't'},
|
||||
{"strip-path", required_argument, 0, 'p'},
|
||||
#ifdef USE_CPP
|
||||
{"define", required_argument, 0, 'D'},
|
||||
{"include", required_argument, 0, 'I'},
|
||||
|
@ -813,6 +814,7 @@ DecodeArgs (int argc, char **argv)
|
|||
|
||||
options.save_temps = false;
|
||||
options.verbosity = 0;
|
||||
options.strip_path = 0;
|
||||
|
||||
sourcedir = "";
|
||||
progs_src = "progs.src";
|
||||
|
@ -827,6 +829,7 @@ DecodeArgs (int argc, char **argv)
|
|||
"W:" // warning options
|
||||
"h" // help
|
||||
"V" // version
|
||||
"p:" // strip path
|
||||
#ifdef USE_CPP
|
||||
"S" // save temps
|
||||
"D:" // define
|
||||
|
@ -848,6 +851,9 @@ DecodeArgs (int argc, char **argv)
|
|||
case 'P': // progs-src
|
||||
progs_src = strdup (optarg);
|
||||
break;
|
||||
case 'p':
|
||||
options.strip_path = atoi (optarg);
|
||||
break;
|
||||
case 'F':
|
||||
options.files_dat = true;
|
||||
break;
|
||||
|
@ -1122,6 +1128,22 @@ preprocess_file (const char *filename)
|
|||
return fopen (filename, "rt");
|
||||
}
|
||||
|
||||
const char *
|
||||
strip_path (const char *filename)
|
||||
{
|
||||
const char *p = filename;
|
||||
int i = options.strip_path;
|
||||
|
||||
while (i-- > 0) {
|
||||
while (*p && *p != '/')
|
||||
p++;
|
||||
if (!*p)
|
||||
break;
|
||||
filename = ++p;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
/*
|
||||
main
|
||||
|
||||
|
@ -1212,7 +1234,7 @@ main (int argc, char **argv)
|
|||
|
||||
yyin = preprocess_file (filename);
|
||||
|
||||
s_file = ReuseString (filename);
|
||||
s_file = ReuseString (strip_path (filename));
|
||||
pr_source_line = 1;
|
||||
clear_frame_macros ();
|
||||
error = yyparse () || pr_error_count;
|
||||
|
|
Loading…
Reference in a new issue