libtool-patches
[Top][All Lists]
Advanced

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

[PATCH] Add --lt-* options to shell wrapper


From: Charles Wilson
Subject: [PATCH] Add --lt-* options to shell wrapper
Date: Sun, 12 Jul 2009 17:40:26 -0400

* libltdl/config/ltmain.m4sh (func_emit_wrapper)
[func_parse_lt_options]: New function.
[func_opts_contain_lt]: New function.
[func_lt_dump_args]: New function.
[func_exec_program_core]: New function, refactored from [main].
[func_exec_program]: New function.
[main]: Call func_parse_lt_options early. Use func_exec_program.
(func_emit_cwrapperexe_src) [main]: Reword error message to
align with (upcoming) documentation.
---
For symmetry, support --lt-debug and --lt-dump-script in the shell
wrapper, as well as in the cwrapper.

In this patch series, I've kept the --lt-dump-script option
for now, and even added support for that option to the wrapper
script.  I think the option is useful, and I agree that symmetry
between w-script and w-exe is important. However, Ralf said:
> I'd consider documenting --lt-dump-script the cementation of 
> a bad API. 
So, as a compromise we could could modify this documentation patch
to just not /document/ that option, while retaining all the other
documentation/discussion of the w-exe and the --lt-debug option.

There are four patches in this series:

1. Remove unneeded functions and options from cwrapper
committed: 75765d58c38c55ef069ef100732c1e978f4151a6

2. [PATCH] Enable runtime cwrapper debugging; add tests
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00039.html
pending...

3. [PATCH] Add --lt-* options to shell wrapper
(this post. obviously no URL yet, and obviously pending...)

4. [PATCH] Document wrapper changes
(next post. also no URL yet, and also obviously pending...)

Together, these four obsolete and (I hope) address all of the comments
for
[PATCH] Document and test LT_DEBUGWRAPPER cwrapper macro
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00031.html
as well as addressing the comments recieved so far in review of #2.

I'm posting #3 and #4 on the off chance that, for whatever reasons,
approval for #2 has been held up waiting for these two promised patches.
I'm really hoping to get my pending patch set reviewed and merged in the
near future, as the current cygwin patch queue is a bit ridiculous at 72kB...
  8 files changed, 1271 insertions(+), 242 deletions(-)


 libltdl/config/ltmain.m4sh |  150 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 130 insertions(+), 20 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index d8c5749..881aef5 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2401,7 +2401,134 @@ func_fallback_echo ()
 _LTECHO_EOF'
 }
     ECHO=\"$qECHO\"
-  fi\
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all exist in the "--lt-" namespace
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by "$@".
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=\$0
+  shift
+  for lt_opt
+  do
+    case \"\$lt_opt\" in
+    --lt-debug) lt_option_debug=1 ;;
+    --lt-dump-script)
+        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 
's%/[^/]*$%%'\`
+        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
+        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 
's%^.*/%%'\`
+        cat \"\$lt_dump_D/\$lt_dump_F\"
+        exit 0
+      ;;
+    --lt-*)
+        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
+        exit 1
+      ;;
+    esac
+  done
+}
+
+# Sets opts_contain_lt_result to \"yes\" if the
+# supplied arguments contain any elements in the
+# --lt-* namespace. Empty otherwise.
+opts_contain_lt_result=
+func_opts_contain_lt ()
+{
+  opts_contain_lt_result=
+  for lt_option
+  do
+    case \"\$lt_option\" in
+    --lt-*) opts_contain_lt_result=yes
+            break ;;
+    *) ;;
+    esac
+  done
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+    \$ECHO \"(main) newargz[\$lt_dump_args_N]   : \$lt_arg\"
+    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+"
+  case $host in
+  # Backslashes separate directories on plain windows
+  *-*-mingw | *-*-os2* | *-cegcc*)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"(main) lt_argv_zero : \$progdir\\\\\$program\" 1>&2
+        func_lt_dump_args \${1+\"address@hidden"} 1>&2
+      fi
+      exec \"\$progdir\\\\\$program\" \${1+\"address@hidden"}
+"
+    ;;
+
+  *)
+    $ECHO "\
+      if test -n \"\$lt_option_debug\"; then
+        \$ECHO \"(main) lt_argv_zero : \$progdir/\$program\" 1>&2
+        func_lt_dump_args \${1+\"address@hidden"} 1>&2
+      fi
+      exec \"\$progdir/\$program\" \${1+\"address@hidden"}
+"
+    ;;
+  esac
+  $ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from \$@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+  func_opts_contain_lt \${1+\"address@hidden"}
+  if test -n \"\$opts_contain_lt_result\"; then
+    # the following is adapted from _AC_INIT_PREPARE, except
+    # (1) we don't care about duplicates, and
+    # (2) we strip out --lt-*, not --no-create/--no-recursion/--silent
+    lt_wrapper_args=
+    for lt_wr_arg
+    do
+      case \$lt_wr_arg in
+      --lt-*) continue ;;
+      *\\'*)
+        lt_wr_arg=\`\$ECHO \"X\$lt_wr_arg\" |
+          $SED -e \"s/^X//\" -e \"s/'/'\\\\\\\\\\\\\\\\''/g\"\`
+        ;;
+      esac
+      lt_wrapper_args=\"\$lt_wrapper_args '\$lt_wr_arg'\"
+    done
+    eval func_exec_program_core \$lt_wrapper_args
+  else
+    func_exec_program_core \${1+\"address@hidden"}
+  fi
+}
+
+  # Parse options
+  func_parse_lt_options \"\$0\" \${1+\"address@hidden"}
 
   # Find the directory that this script lives in.
   thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
@@ -2514,24 +2641,7 @@ _LTECHO_EOF'
        $ECHO "\
     if test \"\$libtool_execute_magic\" != \"$magic\"; then
       # Run the actual program with our arguments.
-"
-       case $host in
-       # Backslashes separate directories on plain windows
-       *-*-mingw | *-*-os2* | *-cegcc*)
-         $ECHO "\
-      exec \"\$progdir\\\\\$program\" \${1+\"address@hidden"}
-"
-         ;;
-
-       *)
-         $ECHO "\
-      exec \"\$progdir/\$program\" \${1+\"address@hidden"}
-"
-         ;;
-       esac
-       $ECHO "\
-      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
-      exit 1
+      func_exec_program \${1+\"address@hidden"}
     fi
   else
     # The program doesn't exist.
@@ -2984,7 +3094,7 @@ EOF
              need to make LTWRAPPER_OPTION_PREFIX a configure-time option
              or a configure.ac-settable value.
            */
-          lt_fatal ("Unrecognized option in %s namespace: '%s'",
+          lt_fatal ("Unrecognized %s option: '%s'",
                     ltwrapper_option_prefix, argv[i]);
         }
       /* otherwise ... */
-- 
1.6.3.2





reply via email to

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