* [PATCH] handle variables in make targets
@ 2004-08-18 22:45 Wayne Davison
0 siblings, 0 replies; only message in thread
From: Wayne Davison @ 2004-08-18 22:45 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
Here's a patch that adds simple variable handling to the useperl side of
the _make completer. For instance, I have some targets that look like
this:
rsync$(EXEEXT): $(OBJS)
With the current script, this puts the literal string "rsync$(EXEEXT)"
into the edit buffer, which is not good because EXEEXT isn't defined in
the environment (just in the Makefile). This patch tries to handle both
delayed expansion (=) and immediate expansion (:=) syntax, but does not
deal with variable references that don't use () or {}.
Comments?
..wayne..
[-- Attachment #2: make-var.patch --]
[-- Type: text/plain, Size: 1106 bytes --]
--- _make 18 Aug 2004 20:30:27 -0000 1.7
+++ _make 18 Aug 2004 22:43:50 -0000
@@ -34,12 +34,19 @@ else
tmp=( $(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null | $cmdargs) )
elif [[ -n $useperl ]]; then
tmp=(
- $(perl -ne '@matches = /^(?:([a-zA-Z0-9]+[^\/\t=\s]+)\s*)+:(?:[^=]|$)/ and
- print join(" ", @matches), "\n";
-if (/^\.include\s+\<bsd\.port\.(subdir\.|pre\.)?mk>/ ||
+ $(perl -ne '
+if (($var, $colon, $val) = /^([a-zA-Z0-9]+[^\/\t:=\s]+)\s*(:)?=\s*(.*?)\s*$/) {
+ 1 while ($colon && $val =~ s/\$[({]([^})]+)[})]/$ENV{$1}/);
+ $ENV{$var} = $val;
+} elsif (@matches = /^(?:([a-zA-Z0-9]+[^\/\t=\s]+)\s*)+:(?:[^=]|$)/) {
+ foreach (@matches) {
+ 1 while (s/\$[({]([^})]+)[})]/$ENV{$1}/);
+ print $_, "\n";
+ }
+} elsif (/^\.include\s+\<bsd\.port\.(subdir\.|pre\.)?mk>/ ||
/^\.include\s+\".*mk\/bsd\.pkg\.(subdir\.)?mk\"/) {
print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum\n";
- }
+}
' $file)
)
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-08-18 22:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-18 22:45 [PATCH] handle variables in make targets Wayne Davison
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).