Bug 177355 - [PATCH] Remove != from bsd.java.mk
Summary: [PATCH] Remove != from bsd.java.mk
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Greg Lewis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-24 20:00 UTC by Chris Rees
Modified: 2013-04-26 03:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Rees freebsd_committer freebsd_triage 2013-03-24 20:00:00 UTC
	bmake complains about != assignments that give no output.

	Rather than simply hack around using echo, this patch uses actual Make
	logic to look inside the variables.

	This should be much faster.

Fix: 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.--JreQeFJvSRabwYelw88KFcu79tYQgcCJIBoiFQhYolchygwI
Content-Type: text/plain; name="bsd-java-mk-remove-bang.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="bsd-java-mk-remove-bang.diff"

Index: bsd.java.mk
===================================================================
--- bsd.java.mk	(revision 312626)
+++ bsd.java.mk	(working copy)
@@ -214,15 +214,27 @@
 
 # Error checking: JAVA_VERSION
 .if !defined(_JAVA_VERSION_LIST_REGEXP)
-_JAVA_VERSION_LIST_REGEXP!=		${ECHO_CMD} "${_JAVA_VERSION_LIST}" | ${SED} "s/ /\\\|/g"
+.	for v in ${_JAVA_VERSION_LIST}
+.		if defined(_JAVA_VERSION_LIST_REGEXP)
+_JAVA_VERSION_LIST_REGEXP:=		${_JAVA_VERSION_LIST_REGEXP}\|
+.		endif
+_JAVA_VERSION_LIST_REGEXP:=		${_JAVA_VERSION_LIST_REGEXP}$v
+.	endfor
 .endif
+
+
 check-makevars::
 	@test ! -z "${JAVA_VERSION}" && ( ${ECHO_CMD} "${JAVA_VERSION}" | ${TR} " " "\n" | ${GREP} -q "${_JAVA_VERSION_LIST_REGEXP}" || \
 	(${ECHO_CMD} "${PKGNAME}: Makefile error: \"${JAVA_VERSION}\" is not a valid value for JAVA_VERSION. It should be one or more of: ${__JAVA_VERSION_LIST} (with an optional \"+\" suffix.)"; ${FALSE})) || true
 
 # Error checking: JAVA_VENDOR
 .if !defined(_JAVA_VENDOR_LIST_REGEXP)
-_JAVA_VENDOR_LIST_REGEXP!=		${ECHO_CMD} "${_JAVA_VENDOR_LIST}" | ${SED} "s/ /\\\|/g"
+.	for v in ${_JAVA_VENDOR_LIST}
+.		if defined(_JAVA_VENDOR_LIST_REGEXP)
+_JAVA_VENDOR_LIST_REGEXP:=		${_JAVA_VENDOR_LIST_REGEXP}\|
+.		endif
+_JAVA_VENDOR_LIST_REGEXP:=		${_JAVA_VENDOR_LIST_REGEXP}$v
+.	endfor
 .endif
 check-makevars::
 	@test ! -z "${JAVA_VENDOR}" && ( ${ECHO_CMD} "${JAVA_VENDOR}" | ${TR} " " "\n" | ${GREP} -q "${_JAVA_VENDOR_LIST_REGEXP}" || \
@@ -231,7 +243,12 @@
 
 # Error checking: JAVA_OS
 .if !defined(_JAVA_OS_LIST_REGEXP)
-_JAVA_OS_LIST_REGEXP!=		${ECHO_CMD} "${_JAVA_OS_LIST}" | ${SED} "s/ /\\\|/g"
+.	for v in ${_JAVA_OS_LIST}
+.		if defined(_JAVA_OS_LIST_REGEXP)
+_JAVA_OS_LIST_REGEXP:=		${_JAVA_OS_LIST_REGEXP}\|
+.		endif
+_JAVA_OS_LIST_REGEXP:=		${_JAVA_OS_LIST_REGEXP}$v
+.	endfor
 .endif
 check-makevars::
 	@test ! -z "${JAVA_OS}" && ( ${ECHO_CMD} "${JAVA_OS}" | ${TR} " " "\n" | ${GREP} -q "${_JAVA_OS_LIST_REGEXP}" || \
@@ -273,26 +290,23 @@
 A_JAVA_PORT_VERSION=		${A_JAVA_PORT_INFO:MVERSION=*:C/VERSION=([0-9])\.([0-9])(.*)/\1.\2/}
 A_JAVA_PORT_OS=				${A_JAVA_PORT_INFO:MOS=*:S,OS=,,}
 A_JAVA_PORT_VENDOR=			${A_JAVA_PORT_INFO:MVENDOR=*:S,VENDOR=,,}
-.if !defined(_JAVA_PORTS_INSTALLED)
-A_JAVA_PORT_INSTALLED!=		${TEST} -x "${A_JAVA_PORT_HOME}/${_JDK_FILE}" \
-							&& ${ECHO_CMD} "${A_JAVA_PORT}" \
-							|| ${TRUE}
-__JAVA_PORTS_INSTALLED!=	${ECHO_CMD} "${__JAVA_PORTS_INSTALLED} ${A_JAVA_PORT_INSTALLED}"
+.if !defined(_JAVA_PORTS_INSTALLED) && exists(${A_JAVA_PORT_HOME}/${_JDK_FILE})
+__JAVA_PORTS_INSTALLED+=	${A_JAVA_PORT}
 .endif
 
-# The magic here is that we want to test for a substring using only shell builtins (to avoid forking)
-# Our shell does not have an explicit substring operator, but we can build one by using the '#'
-# deletion operator ('%' would also work).  We try to delete the pattern "*${substr}*" and compare it
-# to the original string.  If they differ, the substring matched.
-# 
-# We can't do this in make because it doesn't allow nested modifiers ${foo:${bar}}
+# Because variables inside for loops are special (directly replaced as strings), we are allowed
+# to use them inside modifiers, where normally ${FOO:M${BAR}} is not allowed.
 #
-A_JAVA_PORT_POSSIBLE!=		ver="${_JAVA_VERSION}"; os="${_JAVA_OS}"; vendor="${_JAVA_VENDOR}"; \
-				${TEST} "$${ver\#*${A_JAVA_PORT_VERSION}*}" != "${_JAVA_VERSION}" -a \
-				"$${os\#*${A_JAVA_PORT_OS}*}" != "${_JAVA_OS}" -a \
-				"$${vendor\#*${A_JAVA_PORT_VENDOR}*}" != "${_JAVA_VENDOR}" && \
-				${ECHO_CMD} "${A_JAVA_PORT}" || ${TRUE}
-__JAVA_PORTS_POSSIBLE:=		${__JAVA_PORTS_POSSIBLE} ${A_JAVA_PORT_POSSIBLE}
+.for ver in ${A_JAVA_PORT_VERSION}
+.for os in ${A_JAVA_PORT_OS}
+.for vendor in ${A_JAVA_PORT_VENDOR}
+.if ${_JAVA_VERSION:M${ver}} && ${_JAVA_OS:M${os}} && ${_JAVA_VENDOR:M${vendor}}
+__JAVA_PORTS_POSSIBLE+=		${A_JAVA_PORT}
+.endif
+.endfor
+.endfor
+.endfor
+
 .		endfor
 .if !defined(_JAVA_PORTS_INSTALLED)
 _JAVA_PORTS_INSTALLED=		${__JAVA_PORTS_INSTALLED:C/ [ ]+/ /g}
@@ -309,10 +323,7 @@
 .		undef _JAVA_PORTS_INSTALLED_POSSIBLE
 
 .		for A_JAVA_PORT in ${_JAVA_PORTS_POSSIBLE}
-A_JAVA_PORT_INSTALLED_POSSIBLE!=	inst="${_JAVA_PORTS_INSTALLED}"; \
-					${TEST} "$${inst\#*${A_JAVA_PORT}*}" != "${_JAVA_PORTS_INSTALLED}" && \
-					${ECHO_CMD} "${A_JAVA_PORT}" || ${TRUE}
-__JAVA_PORTS_INSTALLED_POSSIBLE:=	${__JAVA_PORTS_INSTALLED_POSSIBLE} ${A_JAVA_PORT_INSTALLED_POSSIBLE}
+__JAVA_PORTS_INSTALLED_POSSIBLE+=	${_JAVA_PORTS_INSTALLED:M${A_JAVA_PORT}}
 .		endfor
 _JAVA_PORTS_INSTALLED_POSSIBLE=		${__JAVA_PORTS_INSTALLED_POSSIBLE:C/[ ]+//g}
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-03-24 20:00:13 UTC
Responsible Changed
From-To: freebsd-ports-bugs->glewis

bsd.java.mk is glewis territory (via the GNATS Auto Assign Tool)
Comment 2 Greg Lewis freebsd_committer freebsd_triage 2013-03-30 04:46:04 UTC
State Changed
From-To: open->feedback

Thanks Chris.  What level of testing have you done on the changes?
Comment 3 Chris Rees freebsd_committer freebsd_triage 2013-04-01 17:45:39 UTC
Well, I did some basic testing, such as ensuring that both versions
give the same output on my computer.

I couldn't do anything more advanced than that, since most tests
appear to require different Java ports installing.

Is there anything specific I could test that would help you?

Chris
Comment 4 dfilter service freebsd_committer freebsd_triage 2013-04-26 03:37:32 UTC
Author: glewis
Date: Fri Apr 26 02:37:19 2013
New Revision: 316543
URL: http://svnweb.freebsd.org/changeset/ports/316543

Log:
  . Replace the use of != and shell utilities with actual make logic.  This
    should be much faster and avoid some complaints from make.
  
  PR:		177355
  Submitted by:	crees@

Modified:
  head/Mk/bsd.java.mk

Modified: head/Mk/bsd.java.mk
==============================================================================
--- head/Mk/bsd.java.mk	Fri Apr 26 02:35:58 2013	(r316542)
+++ head/Mk/bsd.java.mk	Fri Apr 26 02:37:19 2013	(r316543)
@@ -214,15 +214,27 @@ check-makevars::
 
 # Error checking: JAVA_VERSION
 .if !defined(_JAVA_VERSION_LIST_REGEXP)
-_JAVA_VERSION_LIST_REGEXP!=		${ECHO_CMD} "${_JAVA_VERSION_LIST}" | ${SED} "s/ /\\\|/g"
+.	for v in ${_JAVA_VERSION_LIST}
+.		if defined(_JAVA_VERSION_LIST_REGEXP)
+_JAVA_VERSION_LIST_REGEXP:=		${_JAVA_VERSION_LIST_REGEXP}\|
+.		endif
+_JAVA_VERSION_LIST_REGEXP:=		${_JAVA_VERSION_LIST_REGEXP}$v
+.	endfor
 .endif
+
+
 check-makevars::
 	@test ! -z "${JAVA_VERSION}" && ( ${ECHO_CMD} "${JAVA_VERSION}" | ${TR} " " "\n" | ${GREP} -q "${_JAVA_VERSION_LIST_REGEXP}" || \
 	(${ECHO_CMD} "${PKGNAME}: Makefile error: \"${JAVA_VERSION}\" is not a valid value for JAVA_VERSION. It should be one or more of: ${__JAVA_VERSION_LIST} (with an optional \"+\" suffix.)"; ${FALSE})) || true
 
 # Error checking: JAVA_VENDOR
 .if !defined(_JAVA_VENDOR_LIST_REGEXP)
-_JAVA_VENDOR_LIST_REGEXP!=		${ECHO_CMD} "${_JAVA_VENDOR_LIST}" | ${SED} "s/ /\\\|/g"
+.	for v in ${_JAVA_VENDOR_LIST}
+.		if defined(_JAVA_VENDOR_LIST_REGEXP)
+_JAVA_VENDOR_LIST_REGEXP:=		${_JAVA_VENDOR_LIST_REGEXP}\|
+.		endif
+_JAVA_VENDOR_LIST_REGEXP:=		${_JAVA_VENDOR_LIST_REGEXP}$v
+.	endfor
 .endif
 check-makevars::
 	@test ! -z "${JAVA_VENDOR}" && ( ${ECHO_CMD} "${JAVA_VENDOR}" | ${TR} " " "\n" | ${GREP} -q "${_JAVA_VENDOR_LIST_REGEXP}" || \
@@ -231,7 +243,12 @@ check-makevars::
 
 # Error checking: JAVA_OS
 .if !defined(_JAVA_OS_LIST_REGEXP)
-_JAVA_OS_LIST_REGEXP!=		${ECHO_CMD} "${_JAVA_OS_LIST}" | ${SED} "s/ /\\\|/g"
+.	for v in ${_JAVA_OS_LIST}
+.		if defined(_JAVA_OS_LIST_REGEXP)
+_JAVA_OS_LIST_REGEXP:=		${_JAVA_OS_LIST_REGEXP}\|
+.		endif
+_JAVA_OS_LIST_REGEXP:=		${_JAVA_OS_LIST_REGEXP}$v
+.	endfor
 .endif
 check-makevars::
 	@test ! -z "${JAVA_OS}" && ( ${ECHO_CMD} "${JAVA_OS}" | ${TR} " " "\n" | ${GREP} -q "${_JAVA_OS_LIST_REGEXP}" || \
@@ -273,26 +290,23 @@ A_JAVA_PORT_HOME=			${A_JAVA_PORT_INFO:M
 A_JAVA_PORT_VERSION=		${A_JAVA_PORT_INFO:MVERSION=*:C/VERSION=([0-9])\.([0-9])(.*)/\1.\2/}
 A_JAVA_PORT_OS=				${A_JAVA_PORT_INFO:MOS=*:S,OS=,,}
 A_JAVA_PORT_VENDOR=			${A_JAVA_PORT_INFO:MVENDOR=*:S,VENDOR=,,}
-.if !defined(_JAVA_PORTS_INSTALLED)
-A_JAVA_PORT_INSTALLED!=		${TEST} -x "${A_JAVA_PORT_HOME}/${_JDK_FILE}" \
-							&& ${ECHO_CMD} "${A_JAVA_PORT}" \
-							|| ${TRUE}
-__JAVA_PORTS_INSTALLED!=	${ECHO_CMD} "${__JAVA_PORTS_INSTALLED} ${A_JAVA_PORT_INSTALLED}"
+.if !defined(_JAVA_PORTS_INSTALLED) && exists(${A_JAVA_PORT_HOME}/${_JDK_FILE})
+__JAVA_PORTS_INSTALLED+=	${A_JAVA_PORT}
 .endif
 
-# The magic here is that we want to test for a substring using only shell builtins (to avoid forking)
-# Our shell does not have an explicit substring operator, but we can build one by using the '#'
-# deletion operator ('%' would also work).  We try to delete the pattern "*${substr}*" and compare it
-# to the original string.  If they differ, the substring matched.
-# 
-# We can't do this in make because it doesn't allow nested modifiers ${foo:${bar}}
+# Because variables inside for loops are special (directly replaced as strings), we are allowed
+# to use them inside modifiers, where normally ${FOO:M${BAR}} is not allowed.
 #
-A_JAVA_PORT_POSSIBLE!=		ver="${_JAVA_VERSION}"; os="${_JAVA_OS}"; vendor="${_JAVA_VENDOR}"; \
-				${TEST} "$${ver\#*${A_JAVA_PORT_VERSION}*}" != "${_JAVA_VERSION}" -a \
-				"$${os\#*${A_JAVA_PORT_OS}*}" != "${_JAVA_OS}" -a \
-				"$${vendor\#*${A_JAVA_PORT_VENDOR}*}" != "${_JAVA_VENDOR}" && \
-				${ECHO_CMD} "${A_JAVA_PORT}" || ${TRUE}
-__JAVA_PORTS_POSSIBLE:=		${__JAVA_PORTS_POSSIBLE} ${A_JAVA_PORT_POSSIBLE}
+.for ver in ${A_JAVA_PORT_VERSION}
+.for os in ${A_JAVA_PORT_OS}
+.for vendor in ${A_JAVA_PORT_VENDOR}
+.if ${_JAVA_VERSION:M${ver}} && ${_JAVA_OS:M${os}} && ${_JAVA_VENDOR:M${vendor}}
+__JAVA_PORTS_POSSIBLE+=		${A_JAVA_PORT}
+.endif
+.endfor
+.endfor
+.endfor
+
 .		endfor
 .if !defined(_JAVA_PORTS_INSTALLED)
 _JAVA_PORTS_INSTALLED=		${__JAVA_PORTS_INSTALLED:C/ [ ]+/ /g}
@@ -309,10 +323,7 @@ _JAVA_PORTS_POSSIBLE=		${__JAVA_PORTS_PO
 .		undef _JAVA_PORTS_INSTALLED_POSSIBLE
 
 .		for A_JAVA_PORT in ${_JAVA_PORTS_POSSIBLE}
-A_JAVA_PORT_INSTALLED_POSSIBLE!=	inst="${_JAVA_PORTS_INSTALLED}"; \
-					${TEST} "$${inst\#*${A_JAVA_PORT}*}" != "${_JAVA_PORTS_INSTALLED}" && \
-					${ECHO_CMD} "${A_JAVA_PORT}" || ${TRUE}
-__JAVA_PORTS_INSTALLED_POSSIBLE:=	${__JAVA_PORTS_INSTALLED_POSSIBLE} ${A_JAVA_PORT_INSTALLED_POSSIBLE}
+__JAVA_PORTS_INSTALLED_POSSIBLE+=	${_JAVA_PORTS_INSTALLED:M${A_JAVA_PORT}}
 .		endfor
 _JAVA_PORTS_INSTALLED_POSSIBLE=		${__JAVA_PORTS_INSTALLED_POSSIBLE:C/[ ]+//g}
 
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 5 Greg Lewis freebsd_committer freebsd_triage 2013-04-26 03:39:01 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!