Page MenuHomeFreeBSD

Fix opt_VARS premature expansion
ClosedPublic

Authored by AMDmi3 on Sep 24 2015, 1:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 4:14 AM
Unknown Object (File)
Mar 9 2024, 10:11 AM
Unknown Object (File)
Feb 22 2024, 1:18 PM
Unknown Object (File)
Feb 9 2024, 8:36 AM
Unknown Object (File)
Jan 18 2024, 1:32 AM
Unknown Object (File)
Dec 28 2023, 4:50 AM
Unknown Object (File)
Dec 28 2023, 4:50 AM
Unknown Object (File)
Dec 28 2023, 4:50 AM
Subscribers

Details

Reviewers
None
Group Reviewers
portmgr
Commits
rP398258: Fix opt_VARS premature expansion.
Summary

Due to .for loop, opt_VARS are expanded early during bsd.options.mk evaluation, which makes it impossible to use some vars which are set/modifies afterwards (such as PREFIX or PKGDIR)

Fix this by changing opt_VARS handling logic:

  • Loop not by words (each word here is single VAR=val / VAR+=val tuple) but by unique left sides of assignments (VAR, VAR+ here)
  • Using the left side, extract all corresponding right sides and append/assign them to a variable

This way right sides are not expanded preliminary and opt_VARS work as expected.

This also allows either logic for duplicated assignments:

opt_VAR= FOO=one FOO=two

currently leads to FOO=two, however if :[-1] is removed from the patch, this will lead to FOO=one two.
The current approach seems more consistent though, and there is still a way to assign multiple values with FOO="one two"

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

AMDmi3 retitled this revision from to Fix opt_VARS premature expansion.
AMDmi3 updated this object.
AMDmi3 edited the test plan for this revision. (Show Details)
antoine added inline comments.
Mk/bsd.options.mk
482 ↗(On Diff #8920)

Does this syntax work with fmake?

AMDmi3 edited edge metadata.

Fix fmake compatibility

  • _u workaround as apparently var can't be used directly
  • no [-1], fmake doesn't support it; FOO=foo FOO=bar now results in FOO="foo bar"
AMDmi3 added inline comments.
Mk/bsd.options.mk
483 ↗(On Diff #8921)

No. Another workaround was also needed.

Also, don't forget the off case.

AMDmi3 marked an inline comment as done.
AMDmi3 edited edge metadata.

Don't forget opt_VARS_OFF

This revision was automatically updated to reflect the committed changes.