[qfcc] Remove path stripping

It never really helped sort out the path issues when using build
directories. It worked well enough for single directory projects, but
things got messy very quickly, especially when mixing ruamoko libs with
external progs. A better method based on dwarf is coming.
This commit is contained in:
Bill Currie 2020-04-03 00:45:54 +09:00
parent 5d06596814
commit d69db50cf9
12 changed files with 11 additions and 51 deletions

View file

@ -27,11 +27,10 @@ am__mv = mv -f
GZIP=if echo $@ | grep -q .gz; then gzip -f `basename $@ .gz`; if test -f `basename $@ .dat.gz`.sym; then gzip -f `basename $@ .dat.gz`.sym; fi; fi
# BSD make can't handle $(shell foo) directives, and GNU make can't handle |=
# so we have to bite the bullet and pass this to the shell every time.
STRIP=`echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c`
SUFFIXES=.o .r
.r.o:
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -p $(STRIP) -c -o $@ $<
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -c -o $@ $<
@sed -i -e '1s@:@: $(QFCC_DEP)@' $(DEPDIR)/$*.Tqo
@$(am__mv) $(DEPDIR)/$*.Tqo $(DEPDIR)/$*.Qo
@ -50,7 +49,7 @@ menu_dat_SOURCES=$(menu_src)
menu_obj=$(menu_src:.r=.o)
menu_dep=$(addprefix ./$(DEPDIR)/,$(menu_obj:.o=.Qo))
menu.dat: $(menu_obj) $(QFCC_DEP) ../lib/libcsqc.a ../lib/libr.a ../gui/libgui.a
$(QLINK) -p $(STRIP) -o menu.dat $(menu_obj) ../gui/libgui.a ../lib/libcsqc.a ../lib/libr.a
$(QLINK) -o menu.dat $(menu_obj) ../gui/libgui.a ../lib/libcsqc.a ../lib/libr.a
include $(menu_dep) # am--include-marker
r_depfiles_remade += $(menu_dep)

View file

@ -25,11 +25,10 @@ am__mv = mv -f
GZIP=if echo $@ | grep -q .gz; then gzip -f `basename $@ .gz`; if test -f `basename $@ .dat.gz`.sym; then gzip -f `basename $@ .dat.gz`.sym; fi; fi
# BSD make can't handle $(shell foo) directives, and GNU make can't handle |=
# so we have to bite the bullet and pass this to the shell every time.
STRIP=`echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c`
SUFFIXES=.o .r
.r.o:
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -p $(STRIP) -c -o $@ $<
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -c -o $@ $<
@sed -i -e '1s@:@: $(QFCC_DEP)@' $(DEPDIR)/$*.Tqo
@$(am__mv) $(DEPDIR)/$*.Tqo $(DEPDIR)/$*.Qo
@ -41,7 +40,7 @@ game_dat_SOURCES=$(game_src)
game_obj=$(game_src:.r=.o)
game_dep=$(addprefix ./$(DEPDIR)/,$(game_obj:.o=.Qo))
game.dat: $(game_obj) $(QFCC_DEP) ../lib/libr.a ../lib/libqw.a
$(QLINK) -p $(STRIP) -o game.dat $(game_obj) ../lib/libr.a ../lib/libqw.a ../lib/libr.a
$(QLINK) -o game.dat $(game_obj) ../lib/libr.a ../lib/libqw.a ../lib/libr.a
include $(game_dep) # am--include-marker
r_depfiles_remade += $(game_dep)

View file

@ -26,7 +26,7 @@ RANLIB=touch
SUFFIXES= .o .r
.r.o:
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -p $(STRIP) -c -o $@ $<
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -c -o $@ $<
@sed -i -e '1s@:@: $(QFCC_DEP)@' $(DEPDIR)/$*.Tqo
@$(am__mv) $(DEPDIR)/$*.Tqo $(DEPDIR)/$*.Qo

View file

@ -28,7 +28,7 @@ RANLIB=touch
SUFFIXES= .o .r
.r.o:
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -p $(STRIP) -c -o $@ $<
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -c -o $@ $<
@sed -i -e '1s@:@: $(QFCC_DEP)@' $(DEPDIR)/$*.Tqo
@$(am__mv) $(DEPDIR)/$*.Tqo $(DEPDIR)/$*.Qo

View file

@ -30,12 +30,11 @@ PAK=$(top_builddir)/tools/pak/pak$(EXEEXT)
GZIP=if echo $@ | grep -q .gz; then gzip -f `basename $@ .gz`; if test -f `basename $@ .dat.gz`.sym; then gzip -f `basename $@ .dat.gz`.sym; fi; fi
# BSD make can't handle $(shell foo) directives, and GNU make can't handle |=
# so we have to bite the bullet and pass this to the shell every time.
STRIP=`echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c`
RANLIB=touch
SUFFIXES=.o .r
.r.o:
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -p $(STRIP) -c -o $@ $<
$(QCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tqo -c -o $@ $<
@sed -i -e '1s@:@: $(QFCC_DEP)@' $(DEPDIR)/$*.Tqo
@$(am__mv) $(DEPDIR)/$*.Tqo $(DEPDIR)/$*.Qo
@ -59,7 +58,7 @@ main_dat_SOURCES=$(scheme_src)
main_obj=$(scheme_src:.r=.o)
main_dep=$(addprefix ./$(DEPDIR)/,$(main_obj:.o=.Qo))
main.dat: $(main_obj) $(QFCC_DEP) libscheme.a ../lib/libcsqc.a ../lib/libr.a
$(QLINK) -p $(STRIP) -o main.dat $(main_obj) libscheme.a ../lib/libcsqc.a ../lib/libr.a
$(QLINK) -o main.dat $(main_obj) libscheme.a ../lib/libcsqc.a ../lib/libr.a
include $(main_dep) # am--include-marker
r_depfiles_remade += $(main_dep)

View file

@ -168,15 +168,6 @@ No effect in separate compilation mode.
Use QCCX escape sequences instead of standard C/QuakeForge sequences in
strings. See \fBESCAPE SEQUENCES\fP for details.
.TP
.B \-p, \-\-strip\-path NUM
Strip NUM leading path elements from file names.
eg. -p 3 will strip the
.I ../../../
from
.I ../../../src/foo.r
when embedding the source file name in the output code.
.TP
.B \-q, \-\-quiet
Inhibit some of \*[qfcc]'s normal output.

View file

@ -114,8 +114,6 @@ typedef struct {
qboolean partial_link; // partial linking
qboolean preprocess_only;// run only cpp, don't compile
qboolean gzip; // compress qfo files when writing
int strip_path; // number of leading path elements to strip
// from source file names
const char *output_file;
const char *debug_file;
} options_t;

View file

@ -108,7 +108,6 @@ extern pr_info_t pr;
#define POINTER_OFS(s,p) ((pr_type_t *) (p) - (s)->data)
const char *strip_path (const char *filename) __attribute__((pure));
const char *file_basename (const char *filename, int keepdot) __attribute__((pure));
extern FILE *qc_yyin;

View file

@ -111,7 +111,7 @@ line_info (char *text)
while (*p && *p != '\n') // ignore rest
p++;
pr.source_line = line - 1;
pr.source_file = ReuseString (strip_path (str));
pr.source_file = ReuseString (str);
}
pr_lineno_t *

View file

@ -94,7 +94,6 @@ static struct option const long_options[] = {
{"relocatable", no_argument, 0, 'r'},
{"save-temps", no_argument, 0, 'S'},
{"source", required_argument, 0, 's'},
{"strip-path", required_argument, 0, 'p'},
{"traditional", no_argument, 0, OPT_TRADITIONAL},
{"undefine", required_argument, 0, 'U'},
{"verbose", no_argument, 0, 'v'},
@ -120,7 +119,6 @@ static const char *short_options =
"o:" // output file
"O" // optimize
"P:" // progs.src name
"p:" // strip path
"q" // quiet
"r" // partial linking
"S" // save temps
@ -166,8 +164,6 @@ usage (int status)
" -o, --output-file FILE Specify output file name\n"
" --progdefs Genderate progdefs.h\n"
" -P, --progs-src FILE File to use instead of progs.src\n"
" -p, --strip-path NUM Strip NUM leading path elements from file\n"
" names\n"
" --qccx-escapes Use QCCX escape sequences instead of standard\n"
" C/QuakeForge sequences.\n"
" -q, --quiet Inhibit usual output\n"
@ -325,7 +321,6 @@ DecodeArgs (int argc, char **argv)
options.single_cpp = true;
options.save_temps = false;
options.verbosity = 0;
options.strip_path = 0;
sourcedir = "";
progs_src = "progs.src";
@ -364,9 +359,6 @@ DecodeArgs (int argc, char **argv)
case 'P': // progs-src
progs_src = save_string (NORMALIZE (optarg));
break;
case 'p':
options.strip_path = atoi (optarg);
break;
case 'F':
options.files_dat = true;
break;

View file

@ -296,22 +296,6 @@ begin_compilation (void)
pr.error_count = 0;
}
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;
}
const char *
file_basename (const char *filename, int keepdot)
{
@ -385,7 +369,7 @@ compile_to_obj (const char *file, const char *obj, lang_t lang)
InitData ();
chain_initial_types ();
begin_compilation ();
pr.source_file = ReuseString (strip_path (file));
pr.source_file = ReuseString (file);
err = yyparse () || pr.error_count;
fclose (*yyin);
if (cpp_name && !options.save_temps) {
@ -641,7 +625,7 @@ compile_file (const char *filename)
if (!*yyin)
return !options.preprocess_only;
pr.source_file = ReuseString (strip_path (filename));
pr.source_file = ReuseString (filename);
pr.source_line = 1;
clear_frame_macros ();
err = yyparse () || pr.error_count;

View file

@ -54,5 +54,4 @@ void dump_dot (const char *stage, void *data,
void (*dump_func) (void *data, const char *fname)){}
void dump_dot_type (void *_t, const char *filename){}
char *fubar;
const char *strip_path(const char *p) { return fubar;}
const char *file_basename(const char *p, int keepdot) { return fubar;}