Page MenuHomeFreeBSD

Bring OPTIONS knob back, now with an awesome smart syntax
Needs ReviewPublic

Authored by danfe on Aug 17 2014, 2:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 26, 1:34 AM
Unknown Object (File)
Thu, Jan 23, 8:02 PM
Unknown Object (File)
Nov 30 2024, 12:43 AM
Unknown Object (File)
Nov 25 2024, 3:39 PM
Unknown Object (File)
Nov 22 2024, 5:39 PM
Unknown Object (File)
Oct 13 2024, 12:37 PM
Unknown Object (File)
Sep 13 2024, 10:43 PM
Unknown Object (File)
Sep 13 2024, 10:43 PM

Details

Reviewers
None
Group Reviewers
portmgr
Summary

Since old-school OPTIONS knob support is long removed, I think we can do something about ugliness of the current OPTIONS_DEFINE[_arch]/OPTIONS_DEFAULT[_arch] pair of knobs.

I propose the following syntax (using now free-again OPTIONS knob, instead of several OPTIONS_DEFINE/OPTIONS_DEFAULT definitions). Consider this example:

PORTNAME=       foo
CATEGORIES=     devel
PORTVERSION=    42

# Existing code: look how verbose it is, yuck!
#OPTIONS_DEFINE= DOCS X11
#OPTIONS_DEFINE_i386=    MYSQL PGSQL
#OPTIONS_DEFINE_amd64=   MYSQL PGSQL
#OPTIONS_DEFAULT_i386=   MYSQL
#OPTIONS_DEFAULT_amd64=  PGSQL
#OPTIONS_EXCLUDE_powerpc=        X11

# Equivalent code (plus FOO/BAR): just a single line (yet still being perfectly readable)
OPTIONS=        DOCS FOO:on MYSQL/i386:on,amd64,arm PGSQL/i386,amd64:on X11!powerpc,arm,mips BAR:on!mips

.include <bsd.port.mk>

Let's do some tests (on i386):

$ make -V OPTIONS_DEFINE
DOCS FOO X11 BAR MYSQL PGSQL
$ make -V OPTIONS_DEFAULT
BAR FOO MYSQL
$ make -V OPTIONS_DEFINE ARCH=amd64
DOCS FOO X11 BAR MYSQL PGSQL
$ make -V OPTIONS_DEFAULT ARCH=amd64
BAR FOO PGSQL
$ make -V OPTIONS_DEFINE ARCH=powerpc
DOCS FOO BAR
$ make -V OPTIONS_DEFAULT ARCH=powerpc
 BAR FOO
$ make -V OPTIONS_DEFAULT ARCH=mips
 FOO

Pros: it's built on top of the existing framework; everything keeps working as before the patch applied. No ports need to be converted. If it's not your cup of tea, you can keep using the OPTIONS_DEFINE/OPTIONS_DEFAULT pair. I've been running with this patch for over a year now, and it survived all updates and never caused any conflicts, so I think it's safe enough to commit.
Cons: none! ;-)

We already widely use OPTIONS helpers, and foo:args syntax is quite common as well (e.g. in USES). This patch just takes another step to make our OPTIONS framework more awesome and easy to use.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

danfe retitled this revision from to Bring OPTIONS knob back, now with an awesome smart syntax.
danfe updated this object.
danfe edited the test plan for this revision. (Show Details)
danfe added a reviewer: portmgr.
danfe set the repository for this revision to rP FreeBSD ports repository.
danfe updated this object.

I do like it, it is simple and concise, and it is not really intrusive,
What do others think about this one?

Could you explain what are "/" ":" "," and "!" are used for? this seems a bit obscure
Can they be put in whatever order or some things have to be put first?
( :on!mips versus /i386:on )

Right; I also think I can optimize away some .for loops and provide better documentation of the knob format and parsing logic, standby...

Equivalent code (plus FOO/BAR): just a single line (yet still being perfectly readable)

OPTIONS= DOCS FOO:on MYSQL/i386:on,amd64,arm PGSQL/i386,amd64:on X11!powerpc,arm,mips BAR:on!mips

This really makes my head hurt. I can't tell what it means without careful thought process. Things should be easily grokable without thought.

DOCS
-> DOCS is available, but not default?
FOO:on
-> FOO is available and on by default. OPTIONS_DEFAULT was far more readable to determine what was going to be default. At first glance of this list I have no idea (without several seconds of thinking and parsing) what will be on by default.
MYSQL/i386:on,amd64,arm
-> Uh, it is on i386 but not amd64 and arm? Really I have no clue here. Ambiguity won't help ports. If it is only on i386 why do other archs need to be defined? If it is on all 3 why is on in the middle?
PGSQL/i386,amd64:on
-> Default on i386 and amd64?
X11!powerpc,arm,mips
-> It's not available for those 3 archs or just not on?
BAR:on!mips
-> Default on except mips?

You call the old syntax ugly, but it is very easily readable. Why solve something not needing solving? In fact there are real bugs in the current options framework that need to be fixed instead. Such as check-sanity not picking up some multi select situations, or the arch options not working at all in some cases as jgh has found.

are ":on!mips" and "!mips:on" both supported?
do they mean the same thing or something different?
and what do they mean?

I'll admit is it more concise. I just think it is less clear. I welcome tweaks to my confusing points.

I think it is a very good idea on principle, but it is really confusing, and not straight forward to understand
I tried to use it a bit and always ended it messing up as soon as I entered in complexe situations.