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.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 17, 5:18 PM
Unknown Object (File)
Feb 19 2024, 8:31 PM
Unknown Object (File)
Feb 19 2024, 8:31 PM
Unknown Object (File)
Feb 19 2024, 8:31 PM
Unknown Object (File)
Feb 19 2024, 8:31 PM
Unknown Object (File)
Feb 19 2024, 8:31 PM
Unknown Object (File)
Feb 19 2024, 8:31 PM
Unknown Object (File)
Feb 19 2024, 8:31 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 Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 11991
Build 12314: arc lint + arc unit

Event Timeline

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

Mk/bsd.port.mk
5192–5197

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

5193

create-build-links: ?

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)

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 inline comments.
Mk/bsd.port.mk
1610

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

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.

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

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?

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.

Use the syntax with =

BINARY_ALIAS= source=target

for example swig3.0=swig

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

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

Make it work like shell alias: target=source

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

Replace ?= with =
Rename WRKBINDR BINARY_LINKDIR

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.