This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

framework annotations for -v


Here is one to allow a target to annotate the -v output for include directories that have different include semantics defined by the target through the cpplib construct callback. With this, the output for:

$ ./xgcc -B./ -v t.c -F.

on darwin looks like:

#include "..." search starts here:
#include <...> search starts here:
 . (framework directory)
 ./include
 ./include-fixed
 /usr/local/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.

This aids in user comprehension of the output.

Tested by building and running a linux cross compiler and a darwin native compiler.

Ok?

mrs2 $ cat ~/diffs/framework-2.diffs
2007-03-06  Mike Stump  <mrs@apple.com>

	* c-incpath.c (merge_include_chains): Allow targets to annnotate
	include directories that use the construct callback.
	* target.h (struct gcc_targetcm): Add include_construct_tag.
	* targhooks.h (default_include_construct_tag): Add.
	* targhooks.c (default_include_construct_tag): Add.
	* target-def.h (TARGET_INCLUDE_CONSTRUCT_TAG): Add.
	(TARGETCM_INITIALIZER): Add TARGET_INCLUDE_CONSTRUCT_TAG.
	* doc/tm.texi (TARGET_INCLUDE_CONSTRUCT_TAG): Add.

	* config/darwin-c.c (include_construct_tag): Add.
	(TARGET_INCLUDE_CONSTRUCT_TAG): Add.
	
Doing diffs in .:
--- ./c-incpath.c.~1~	2006-12-22 21:07:11.000000000 -0800
+++ ./c-incpath.c	2007-03-06 12:42:50.000000000 -0800
@@ -310,7 +310,11 @@ merge_include_chains (cpp_reader *pfile,
 	    fprintf (stderr, _("#include <...> search starts here:\n"));
 	  if (!p)
 	    break;
-	  fprintf (stderr, " %s\n", p->name);
+	  if (p->construct == 0)
+	    fprintf (stderr, " %s\n", p->name);
+	  else
+	    fprintf (stderr, " %s%s\n", p->name,
+		     targetcm.include_construct_tag (p));
 	}
       fprintf (stderr, _("End of search list.\n"));
     }
--- ./config/darwin-c.c.~1~	2007-03-05 16:02:48.000000000 -0800
+++ ./config/darwin-c.c	2007-03-06 13:53:40.000000000 -0800
@@ -641,7 +641,17 @@ handle_c_option (size_t code,
   return true;
 }

+static const char *
+include_construct_tag (struct cpp_dir *p)
+{
+  if (p->construct == framework_construct_pathname)
+    return " (framework directory)";
+  return "";
+}
+
 #undef TARGET_HANDLE_C_OPTION
 #define TARGET_HANDLE_C_OPTION handle_c_option
+#undef TARGET_INCLUDE_CONSTRUCT_TAG
+#define TARGET_INCLUDE_CONSTRUCT_TAG include_construct_tag

struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
--- ./doc/tm.texi.~1~ 2007-03-05 16:02:48.000000000 -0800
+++ ./doc/tm.texi 2007-03-06 14:16:29.000000000 -0800
@@ -10146,3 +10146,9 @@ SUPPORTS_WEAK and TARGET_HAVE_NAMED_SECT
This macro determines the size of the objective C jump buffer for the
NeXT runtime. By default, OBJC_JBLEN is defined to an innocuous value.
@end defmac
+
+@deftypefn {Target Hook} {const char *} TARGET_INCLUDE_CONSTRUCT_TAG (struct cpp_dir *)
+This target hook is a function to output a descriptive tag for the -v
+output for the passed cpp_dir when those directories use the construct
+callback for target defined semantics.
+@end deftypefn
--- ./target-def.h.~1~ 2007-03-05 16:02:48.000000000 -0800
+++ ./target-def.h 2007-03-06 12:29:07.000000000 -0800
@@ -731,7 +731,12 @@ Foundation, 51 Franklin Street, Fifth Fl
}


 #define TARGET_HANDLE_C_OPTION default_handle_c_option
-#define TARGETCM_INITIALIZER { TARGET_HANDLE_C_OPTION }
+#define TARGET_INCLUDE_CONSTRUCT_TAG default_include_construct_tag
+
+#define TARGETCM_INITIALIZER {			\
+  TARGET_HANDLE_C_OPTION,			\
+  TARGET_INCLUDE_CONSTRUCT_TAG			\
+}

 #include "hooks.h"
 #include "targhooks.h"
--- ./target.h.~1~	2007-03-05 16:02:48.000000000 -0800
+++ ./target.h	2007-03-06 13:03:01.000000000 -0800
@@ -892,6 +892,8 @@ struct gcc_target

extern struct gcc_target targetm;

+struct cpp_dir;
+
struct gcc_targetcm {
/* Handle target switch CODE (an OPT_* value). ARG is the argument
passed to the switch; it is NULL if no argument was. VALUE is the
@@ -899,6 +901,11 @@ struct gcc_targetcm {
1 if the positive form of the switch was used and 0 if the negative
form was. Return true if the switch was valid. */
bool (*handle_c_option) (size_t code, const char *arg, int value);
+
+ /* Return an annotation for an include directory for the output of
+ -v for include directories that use the construct callback to
+ construct a filename to include. */
+ const char *(*include_construct_tag) (struct cpp_dir *p);
};


 /* Each target can provide their own.  */
--- ./targhooks.c.~1~	2007-03-05 16:02:48.000000000 -0800
+++ ./targhooks.c	2007-03-06 12:44:43.000000000 -0800
@@ -622,4 +622,10 @@ default_handle_c_option (size_t code ATT
   return false;
 }

+const char *
+default_include_construct_tag (struct cpp_dir* P ATTRIBUTE_UNUSED)
+{
+  return "";
+}
+
 #include "gt-targhooks.h"
--- ./targhooks.h.~1~	2007-03-05 16:02:48.000000000 -0800
+++ ./targhooks.h	2007-03-06 12:44:11.000000000 -0800
@@ -83,3 +83,4 @@ extern enum reg_class default_secondary_
 						secondary_reload_info *);
 extern void hook_void_bitmap (bitmap);
 extern bool default_handle_c_option (size_t, const char *, int);
+extern const char *default_include_construct_tag (struct cpp_dir *);
--------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]