Bug 193931

Summary: [exp-run] always define *_ARGS for USES entries
Product: Ports & Packages Reporter: Tijl Coosemans <tijl>
Component: Ports FrameworkAssignee: Tijl Coosemans <tijl>
Status: Closed FIXED    
Severity: Affects Only Me CC: portmgr
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch
none
patch2
none
patch3
none
patch4 none

Description Tijl Coosemans freebsd_committer 2014-09-25 18:02:44 UTC
Created attachment 147676 [details]
patch

The attached patch is a proposal to change the handling of USES in bsd.port.mk such that for every u in USES u_ARGS is always defined, and, has commas replaced with spaces.  It also loops over USES twice.  Once to define all u_ARGS and once to include Uses/u.mk.  This makes all u_ARGS available to all Uses/u.mk which can be used in autoreconf.mk for instance to examine gettext_ARGS and libtool_ARGS.

The changes for _USES_POST are similar but here u_ARGS is only defined if it isn't defined yet (it wasn't in USES), or if there are new arguments.

The patch then adjust all Uses/*.mk:
- defined(u_ARGS) becomes !empty(u_ARGS)
- eliminate helper variables like _u_ARGS=${u_ARGS:C/,/ /g}
- Some Uses/*.mk used ":" as argument separator instead of ",", but no port uses this at the moment
- Uses/cran.mk: remove unused variable VALID_ARGS and USES+=fortran which has no effect
- Uses/twisted.mk: simplify handling of the case where neither "build" nor "run" arguments have been specified
Comment 1 Antoine Brodin freebsd_committer 2014-09-25 20:32:59 UTC
Take for exp-run
Comment 2 Antoine Brodin freebsd_committer 2014-09-26 06:01:37 UTC
There are lots of make errors

With bmake:

make: "/poudriere/ports/default/Mk/Uses/gmake.mk" line 13: Malformed conditional (${gmake_ARGS} == lite)
make: Fatal errors encountered -- cannot continue

With fmake:

"/usr/ports/Mk/Uses/zip.mk", line 18: Malformed conditional (${zip_ARGS} == infozip)
"/usr/ports/Mk/Uses/zip.mk", line 18: Malformed conditional (${zip_ARGS} == infozip)
"/usr/ports/Mk/bsd.port.mk", line 6122: if-less endif
make: fatal errors encountered -- cannot continue
Comment 3 Tijl Coosemans freebsd_committer 2014-09-26 07:25:12 UTC
Can you give an example of a port that fails?  Because here every port I tried worked.  Did the patch apply cleanly?
Comment 4 Antoine Brodin freebsd_committer 2014-09-26 08:18:44 UTC
with bmake,  audio/pure-audio
with fmake,  java/openjdk7 it seems
Comment 5 Tijl Coosemans freebsd_committer 2014-09-26 09:34:02 UTC
Created attachment 147685 [details]
patch2

- Changed gmake.mk so it can be included again (from pure.mk) without gmake_ARGS defined.
- Put quotes around "infozip" in zip.mk because apparently fmake does not like anything that starts with "info" on the right hand side if the left hand side is empty.
Comment 6 Tijl Coosemans freebsd_committer 2014-09-26 15:42:11 UTC
Created attachment 147699 [details]
patch3

There's a problem with USES=qmake:
http://package23.nyi.freebsd.org/data/91amd64-default-PR193931/2014-09-26_13h05m07s/logs/errors/hupnp-1.0.0_1.log

It's because bsd.qt.mk also adds qmake:_env so USES ends up containing qmake twice and the previous patch then defined qmake_ARGS with the arguments of the second qmake.  This patch now uses the arguments of the first qmake.  All Uses/*.mk have an include guard so only the first occurrence of a USES entry has an effect.
Comment 8 Antoine Brodin freebsd_committer 2014-09-26 20:32:43 UTC
the .if defined(fam_ARGS) should probably be .if !empty(fam_ARGS)
Comment 9 Antoine Brodin freebsd_committer 2014-09-27 08:46:14 UTC
there's a problem with USES=twisted:component too,  as _TWISTED_BUILD_DEP and _TWISTED_RUN_DEP are no longer defined
Comment 10 Tijl Coosemans freebsd_committer 2014-09-27 10:54:47 UTC
Created attachment 147722 [details]
patch4

Fix fam.mk and twisted.mk
Comment 12 commit-hook freebsd_committer 2014-09-28 16:36:59 UTC
A commit references this bug:

Author: tijl
Date: Sun Sep 28 16:36:45 UTC 2014
New revision: 369465
URL: https://svnweb.freebsd.org/changeset/ports/369465

Log:
  Change the way USES is handled:
  - Loop over USES twice, once to define all *_ARGS variables and once to
    include Uses/*.mk.  This allows all Uses/*.mk to examine arguments given
    to other USES entries.
  - Always define *_ARGS (possibly empty) and replace commas with spaces.

  Similar for _USES_POST.

  Adjust all Uses/*.mk:
  - defined(u_ARGS) becomes !empty(u_ARGS)
  - Eliminate helper variables like _*_ARGS=${*_ARGS:C/,/ /g}
  - Some Uses/*.mk used ":" as argument separator instead of ",", but no port
    used this form
  - Uses/cran.mk: remove unused variable VALID_ARGS and USES+=fortran which
    has no effect
  - Uses/twisted.mk: simplify handling of the case where neither "build" nor
    "run" arguments have been specified

  PR:		193931
  Exp-run by:	antoine
  Approved by:	portmgr (antoine)

Changes:
  head/Mk/Uses/ada.mk
  head/Mk/Uses/autoreconf.mk
  head/Mk/Uses/bison.mk
  head/Mk/Uses/charsetfix.mk
  head/Mk/Uses/cmake.mk
  head/Mk/Uses/compiler.mk
  head/Mk/Uses/cran.mk
  head/Mk/Uses/desktop-file-utils.mk
  head/Mk/Uses/desthack.mk
  head/Mk/Uses/display.mk
  head/Mk/Uses/drupal.mk
  head/Mk/Uses/fam.mk
  head/Mk/Uses/fmake.mk
  head/Mk/Uses/fortran.mk
  head/Mk/Uses/fuse.mk
  head/Mk/Uses/gecko.mk
  head/Mk/Uses/gettext.mk
  head/Mk/Uses/gmake.mk
  head/Mk/Uses/gssapi.mk
  head/Mk/Uses/iconv.mk
  head/Mk/Uses/imake.mk
  head/Mk/Uses/kmod.mk
  head/Mk/Uses/lha.mk
  head/Mk/Uses/libtool.mk
  head/Mk/Uses/lua.mk
  head/Mk/Uses/makeinfo.mk
  head/Mk/Uses/makeself.mk
  head/Mk/Uses/mono.mk
  head/Mk/Uses/motif.mk
  head/Mk/Uses/ncurses.mk
  head/Mk/Uses/ninja.mk
  head/Mk/Uses/objc.mk
  head/Mk/Uses/openal.mk
  head/Mk/Uses/pathfix.mk
  head/Mk/Uses/pear.mk
  head/Mk/Uses/perl5.mk
  head/Mk/Uses/pgsql.mk
  head/Mk/Uses/pkgconfig.mk
  head/Mk/Uses/pure.mk
  head/Mk/Uses/python.mk
  head/Mk/Uses/qmail.mk
  head/Mk/Uses/qmake.mk
  head/Mk/Uses/readline.mk
  head/Mk/Uses/scons.mk
  head/Mk/Uses/shared-mime-info.mk
  head/Mk/Uses/tar.mk
  head/Mk/Uses/tcl.mk
  head/Mk/Uses/tk.mk
  head/Mk/Uses/twisted.mk
  head/Mk/Uses/uniquefiles.mk
  head/Mk/Uses/webplugin.mk
  head/Mk/Uses/zip.mk
  head/Mk/bsd.port.mk