blob: b633bc41bb27b753fe8f82851708ce2e97ecebd8 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Cut and paste the pieces of build-aux/options-parser inline into the main
2ltmain.sh code. This removes a performance degradation caused by the
3repeated calls to func_quote_for_eval, the mechanism funclib uses
4to construct the functions used for option parsing.
5
6Upstream-Status: Submitted [Being discussed on mailing list Feb 2015]
7
8diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
9index d5cf07a..0f54303 100644
10--- a/build-aux/ltmain.in
11+++ b/build-aux/ltmain.in
12@@ -342,11 +342,15 @@ _LT_EOF
13 # libtool_options_prep [ARG]...
14 # -----------------------------
15 # Preparation for options parsed by libtool.
16-libtool_options_prep ()
17-{
18+#libtool_options_prep ()
19+#{
20 $debug_mode
21
22 # Option defaults:
23+ opt_verbose=false
24+ opt_warning_types=
25+
26+ # Option defaults:
27 opt_config=false
28 opt_dlopen=
29 opt_dry_run=false
30@@ -382,19 +386,14 @@ libtool_options_prep ()
31 shift; set dummy --mode uninstall ${1+"$@"}; shift
32 ;;
33 esac
34-
35- # Pass back the list of options.
36- func_quote_for_eval ${1+"$@"}
37- libtool_options_prep_result=$func_quote_for_eval_result
38-}
39-func_add_hook func_options_prep libtool_options_prep
40+#}
41
42
43 # libtool_parse_options [ARG]...
44 # ---------------------------------
45 # Provide handling for libtool specific options.
46-libtool_parse_options ()
47-{
48+#libtool_parse_options ()
49+#{
50 $debug_cmd
51
52 # Perform our own loop to consume as many options as possible in
53@@ -474,29 +473,90 @@ libtool_parse_options ()
54 func_append preserve_args " $_G_opt"
55 ;;
56
57- # An option not handled by this hook function:
58- *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
59- esac
60- done
61+ --debug|-x) debug_cmd='set -x'
62+ func_echo "enabling shell trace mode"
63+ $debug_cmd
64+ ;;
65
66+ --no-warnings|--no-warning|--no-warn)
67+ set dummy --warnings none ${1+"$@"}
68+ shift
69+ ;;
70
71- # save modified positional parameters for caller
72- func_quote_for_eval ${1+"$@"}
73- libtool_parse_options_result=$func_quote_for_eval_result
74-}
75-func_add_hook func_parse_options libtool_parse_options
76+ --warnings|--warning|-W)
77+ test $# = 0 && func_missing_arg $_G_opt && break
78+ case " $warning_categories $1" in
79+ *" $1 "*)
80+ # trailing space prevents matching last $1 above
81+ func_append_uniq opt_warning_types " $1"
82+ ;;
83+ *all)
84+ opt_warning_types=$warning_categories
85+ ;;
86+ *none)
87+ opt_warning_types=none
88+ warning_func=:
89+ ;;
90+ *error)
91+ opt_warning_types=$warning_categories
92+ warning_func=func_fatal_error
93+ ;;
94+ *)
95+ func_fatal_error \
96+ "unsupported warning category: '$1'"
97+ ;;
98+ esac
99+ shift
100+ ;;
101+
102+ --verbose|-v) opt_verbose=: ;;
103+ --version) func_version ;;
104+ -\?|-h) func_usage ;;
105+ --help) func_help ;;
106+
107+ # Separate optargs to long options (plugins may need this):
108+ --*=*) func_split_equals "$_G_opt"
109+ set dummy "$func_split_equals_lhs" \
110+ "$func_split_equals_rhs" ${1+"$@"}
111+ shift
112+ ;;
113+
114+ # Separate optargs to short options:
115+ -W*)
116+ func_split_short_opt "$_G_opt"
117+ set dummy "$func_split_short_opt_name" \
118+ "$func_split_short_opt_arg" ${1+"$@"}
119+ shift
120+ ;;
121+
122+ # Separate non-argument short options:
123+ -\?*|-h*|-v*|-x*)
124+ func_split_short_opt "$_G_opt"
125+ set dummy "$func_split_short_opt_name" \
126+ "-$func_split_short_opt_arg" ${1+"$@"}
127+ shift
128+ ;;
129+
130+ --) break ;;
131+ -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
132+ *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
133+ esac
134+ done
135+#}
136
137+# Display all warnings if -W was not given.
138+test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
139
140
141 # libtool_validate_options [ARG]...
142 # ---------------------------------
143 # Perform any sanity checks on option settings and/or unconsumed
144 # arguments.
145-libtool_validate_options ()
146-{
147+#libtool_validate_options ()
148+#{
149 # save first non-option argument
150 if test 0 -lt $#; then
151- nonopt=$1
152+ nonopt=$_G_opt
153 shift
154 fi
155
156@@ -537,20 +597,10 @@ libtool_validate_options ()
157 generic_help=$help
158 help="Try '$progname --help --mode=$opt_mode' for more information."
159 }
160+#}
161
162- # Pass back the unparsed argument list
163- func_quote_for_eval ${1+"$@"}
164- libtool_validate_options_result=$func_quote_for_eval_result
165-}
166-func_add_hook func_validate_options libtool_validate_options
167-
168-
169-# Process options as early as possible so that --help and --version
170-# can return quickly.
171-func_options ${1+"$@"}
172-eval set dummy "$func_options_result"; shift
173-
174-
175+# Bail if the options were screwed!
176+$exit_cmd $EXIT_FAILURE
177
178 ## ----------- ##
179 ## Main. ##