Просмотр исходного кода

* Add wrapper cc1plus (preprocessor) around compilation for stringfix; avoids need for _*.c temporary files

1. http://stackoverflow.com/questions/3545875/custom-gcc-preprocessor
Bryan Drewery 14 лет назад
Родитель
Сommit
9522b8c30b
5 измененных файлов с 49 добавлено и 7 удалено
  1. 0 1
      build/autotools/includes/depend.m4
  2. 3 5
      build/build.mk.in
  3. 45 0
      build/cc1plus
  4. 0 1
      configure
  5. 1 0
      src/.gitignore

+ 0 - 1
build/autotools/includes/depend.m4

@@ -57,7 +57,6 @@ for mf in $files; do
       fi
     fi
     echo "include .deps/$base.Po" >> "$dirpart/.deps/includes"
-    echo "_$base.c:" >> "$dirpart/.deps/includes"
   done
 done
 ])

+ 3 - 5
build/build.mk.in

@@ -1,9 +1,7 @@
 depcomp = /bin/sh $(top_srcdir)/build/autotools/depcomp
 
-%.o: %.c stringfix
+%.o: %.c stringfix@EXEEXT@ $(top_srcdir)/build/cc1plus
 	@echo -e "Compiling: \033[1m`basename $< .c`\033[0m"
-	@./stringfix@EXEEXT@ $< _$< || cp -f $< _$<
-	source='$<' object='$@' depfile='.deps/$*.Po' tmpdepfile='.deps/$*.TPo' depmode=$(CCDEPMODE) $(depcomp) \
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c _$<  -o `basename $< .c`.o 2> >(sed -e "s:_$<:$<:")
-	@rm -f _$<
+	stringfix="./stringfix@EXEEXT@" source='$<' object='$@' depfile='.deps/$*.Po' tmpdepfile='.deps/$*.TPo' depmode=$(CCDEPMODE) $(depcomp) \
+	$(CXX) -no-integrated-cpp -B$(top_srcdir)/build $(CXXFLAGS) $(CPPFLAGS) -c $<  -o `basename $< .c`.o
 

+ 45 - 0
build/cc1plus

@@ -0,0 +1,45 @@
+#! /bin/sh
+
+# This file intercepts the pre-processor and runs 'stringfix' on the source file before it is processed.
+# This avoids the need for the old _*.c temp files.
+
+# Only capture pre-processing
+if [ $1 != "-E" -o -z "$stringfix" ]; then
+  exec $(${COLLECT_GCC} --print-prog-name=cc1plus) $@
+fi
+
+
+# Check for '-MD' as this may be the 'depcomp' call
+depcomp=0
+for arg; do
+  case "$arg" in
+    -MD)
+      depcomp=1
+      ;;
+    *)
+      ;;
+  esac
+done
+
+# Running in depcomp, bail out
+if [ $depcomp -eq 1 ]; then
+  exec $(${COLLECT_GCC} --print-prog-name=cc1plus) $@
+fi
+
+
+# Save the original
+cp -fp $source $source.real
+
+# Trap exit signals to restore the original source file
+trap restore_source EXIT TERM HUP INT QUIT ABRT KILL
+restore_source() {
+  # Restore the original file
+  cp -fp $source.real $source
+  rm -f $source.real
+}
+
+# 'stringfix' the source file into a temporary
+$stringfix $source.real $source
+
+$(${COLLECT_GCC} --print-prog-name=cc1plus) $@
+exit $?

+ 0 - 1
configure

@@ -8607,7 +8607,6 @@ $as_echo X"$mf" |
       fi
     fi
     echo "include .deps/$base.Po" >> "$dirpart/.deps/includes"
-    echo "_$base.c:" >> "$dirpart/.deps/includes"
   done
 done
 

+ 1 - 0
src/.gitignore

@@ -1,5 +1,6 @@
 /Makefile
 /buildinfo.h
+/*.c.real
 /_*.c
 /*~
 /help.h