bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 6/6] * main.c: add --dep parameter for print variable dependen


From: Macpaul Lin
Subject: [PATCH v2 6/6] * main.c: add --dep parameter for print variable dependency
Date: Mon, 18 Aug 2014 21:27:15 +0800

(print_dependency): print each value_record and parent_record of a variable.

Signed-off-by: Macpaul Lin <address@hidden>
---
Changes for v2:
  - no changes.

 main.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 0508ae1..abbcb28 100644
--- a/main.c
+++ b/main.c
@@ -53,6 +53,7 @@ void remote_setup (void);
 void remote_cleanup (void);
 RETSIGTYPE fatal_error_signal (int sig);
 
+void print_variable_dependency (void);
 void print_variable_data_base (void);
 void print_dir_data_base (void);
 void print_rule_data_base (void);
@@ -180,6 +181,11 @@ int ignore_errors_flag = 0;
 
 int print_data_base_flag = 0;
 
+/* Nonzero means don't remake anything, just print the dependency
+   of variables reading from the makefile (-dep).  */
+
+int print_dependency_flag = 0;
+
 /* Nonzero means don't remake anything; just return a nonzero status
    if the specified targets are not up to date (-q).  */
 
@@ -321,6 +327,8 @@ static const char *const usage[] =
     N_("\
   -d                          Print lots of debugging information.\n"),
     N_("\
+  --dep                        Print dependency of variables extracted from 
Makefile.\n"),
+    N_("\
   --debug[=FLAGS]             Print various types of debugging 
information.\n"),
     N_("\
   -e, --environment-overrides\n\
@@ -407,6 +415,7 @@ static const struct command_switch switches[] =
     { 'm', ignore, 0, 0, 0, 0, 0, 0, 0 },
     { 'n', flag, &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
     { 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" },
+    { 'P', flag, &print_dependency_flag, 1, 1, 0, 0, 0, "print-dependency" },
     { 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" },
     { 'r', flag, &no_builtin_rules_flag, 1, 1, 0, 0, 0, "no-builtin-rules" },
     { 'R', flag, &no_builtin_variables_flag, 1, 1, 0, 0, 0,
@@ -462,6 +471,7 @@ static struct option long_option_aliases[] =
     { "dry-run",        no_argument,            0, 'n' },
     { "recon",          no_argument,            0, 'n' },
     { "makefile",       required_argument,      0, 'f' },
+    { "dep",            no_argument,            0, 'P' },
   };
 
 /* List of goal targets.  */
@@ -2610,7 +2620,7 @@ handle_non_switch_argument (const char *arg, int env)
     /* Ignore plain '-' for compatibility.  */
     return;
 
-  v = try_variable_definition (0, arg, o_command, 0);
+  v = try_variable_definition (0, arg, o_command, 0, NULL);
   if (v != 0)
     {
       /* It is indeed a variable definition.  If we don't already have this
@@ -3275,6 +3285,24 @@ print_version (void)
   fflush (stdout);
 }
 
+/* Print a bunch of information about dependency between variables.  */
+
+static void
+print_dependency ()
+{
+  time_t when = time ((time_t *) 0);
+
+  print_version ();
+
+  printf (_("\n# Make dependency from data base, printed on %s"), ctime 
(&when));
+
+  print_variable_dependency ();
+  strcache_print_stats ("#");
+
+  when = time ((time_t *) 0);
+  printf (_("\n# Finished Make dependency from data base on %s\n"), ctime 
(&when));
+}
+
 /* Print a bunch of information about this and that.  */
 
 static void
@@ -3403,6 +3431,9 @@ die (int status)
       if (print_data_base_flag)
         print_data_base ();
 
+      if (print_dependency_flag)
+        print_dependency ();
+
       if (verify_flag)
         verify_file_data_base ();
 
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]