Page MenuHomeFreeBSD

Add a mechanism to allow having binary found first in the path
ClosedPublic

Authored by bapt on Oct 6 2017, 1:04 PM.

Details

Summary

Sometime we need to patch the build system to ensure the build picks the right
version of the tool.
This tool could be the compiler, the linker, gsed or anything.

Add a new directory in the first place in the path, and a variable to define
which binary should be there and which name it should have.

For example if one want to use swig30 but does not want to patch the build
system so that it tries to use swig3.0 instead of swig as a binary, he can
simply specify:
BINARY_RENAME= swig3.0 swig

Now the first swig binary found in the path for the build system will be:
${WRKDIR}/.bin/swig -> /usr/local/bin/swig3.0

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11990
Build 12313: arc lint + arc unit

Event Timeline

bapt created this revision.Oct 6 2017, 1:04 PM
Herald added 1 blocking reviewer(s): portmgr. · View Herald TranscriptOct 6 2017, 1:04 PM
Herald added a subscriber: mat. · View Herald Transcript
bapt added a comment.Oct 6 2017, 1:06 PM

Yes I know BINARY_RENAME sucks :) if one has a better name, I will take it :)

mat added inline comments.Oct 6 2017, 1:17 PM
Mk/bsd.port.mk
5192–5197

guard with a .if !empty(BINARY_RENAME) or something.

5193

create-build-links: ?

bapt updated this revision to Diff 33750.Oct 6 2017, 1:22 PM

Rename create-build-env into create-build-links

bapt marked an inline comment as done.Oct 6 2017, 1:23 PM
bapt added inline comments.
Mk/bsd.port.mk
5192–5197

No need, the target will be defined but not doing anything if BINARY_LINKS is empty (as if it were guarded)

mat added inline comments.Oct 6 2017, 4:01 PM
Mk/bsd.port.mk
5192–5197

Well, might as well not create it if not needed, so that it is not added to the active target list later.

adamw added a subscriber: adamw.Oct 6 2017, 4:17 PM
adamw added inline comments.
Mk/bsd.port.mk
1610

Consider BINARY_LINKDIR. What matters most is what it does, not where it is.

brooks added a subscriber: brooks.Oct 6 2017, 5:43 PM

I like this a lot. It should help users of llvm-config since they can link llvm-config## in as llvm-config. I suspect this will spawn many USES flags.

adamw added a comment.Oct 6 2017, 8:03 PM

So, just repeating a suggestion from IRC:

I'd call it BINARY_ALIAS, and I'd change the syntax slightly. Once you are aliasing two things, it becomes unclear.

BINARY_ALIAS=    swig swig3.0 sed gsed tar rm

I suggest mimicking the alias syntax with:

BINARY_ALIAS=    swig=swig3.0  sed=gsed  tar=rm
bapt updated this revision to Diff 33865.Oct 10 2017, 12:06 PM

Rename to BINARY_ALIAS

bapt added a comment.Oct 10 2017, 12:09 PM

So, just repeating a suggestion from IRC:
I'd call it BINARY_ALIAS, and I'd change the syntax slightly. Once you are aliasing two things, it becomes unclear.

BINARY_ALIAS=    swig swig3.0 sed gsed tar rm

I suggest mimicking the alias syntax with:

BINARY_ALIAS=    swig=swig3.0  sed=gsed  tar=rm

Well it is nice to use the native multi variable for loop rather than having to split imho.
It can be made User friendly if exposed like this:

BINARY_ALIAS=     swig    swig3.0 \
                                     sed      gsed \
                                     tar       rm

This is the syntax used in base build system with noone messing up for symlinks and more :)

What do you think?

adamw added a comment.Oct 10 2017, 3:54 PM
In D12603#262357, @bapt wrote:
BINARY_ALIAS=     swig    swig3.0 \
                                     sed      gsed \
                                     tar       rm

This is the syntax used in base build system with noone messing up for symlinks and more :)
What do you think?

I think the syntax with = looks nicer, but it's probably unlikely that people will be aliasing more than one command at a time anyway.

bapt updated this revision to Diff 33874.Oct 11 2017, 3:26 AM

Use the syntax with =

BINARY_ALIAS= source=target

for example swig3.0=swig

bapt added a comment.Oct 11 2017, 3:27 AM
In D12603#262357, @bapt wrote:
BINARY_ALIAS=     swig    swig3.0 \
                                     sed      gsed \
                                     tar       rm

This is the syntax used in base build system with noone messing up for symlinks and more :)
What do you think?

I think the syntax with = looks nicer, but it's probably unlikely that people will be aliasing more than one command at a time anyway.

done

With BINARY_ALIAS= source=target

adamw added inline comments.Oct 11 2017, 3:37 AM
Mk/bsd.port.mk
5194

Thanks, @bapt!

Is there value to making it behave like the shell alias command, and switching the src target order?

sh: alias sed=gsed
BINARY_ALIAS= sed=gsed

bapt updated this revision to Diff 33878.Oct 11 2017, 7:10 AM

Make it work like shell alias: target=source

bapt updated this revision to Diff 33879.Oct 11 2017, 7:11 AM
bapt marked an inline comment as done.

Guard the new target to only define if needed

bapt marked 3 inline comments as done.Oct 11 2017, 7:12 AM
bapt updated this revision to Diff 33890.Oct 11 2017, 6:55 PM

Replace ?= with =
Rename WRKBINDR BINARY_LINKDIR

swills accepted this revision.Oct 11 2017, 6:56 PM
swills added a subscriber: swills.

LGTM

This revision is now accepted and ready to land.Oct 11 2017, 6:56 PM
This revision was automatically updated to reflect the committed changes.