Skip to content

Commit

Permalink
llvm.mk: add export/noexport to handle CC/CXX/CPP exports
Browse files Browse the repository at this point in the history
Reviewed by:	bofh
Differential Revision:	https://reviews.freebsd.org/D37747
  • Loading branch information
tcberner committed Sep 13, 2023
1 parent d3f22d3 commit 4df0e66
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ in the release notes and/or placed into UPDATING.

All ports committers are allowed to commit to this file.

20230823:
AUTHOR: tcberner@FreeBSD.org

USES=llvm.mk now supports 'export' (default) and 'noexport' arguments.
When export is set, CC, CXX and CPP will be set to the path corresponding
to the chosen llvm-version.

20230821:
AUTHOR: jhale@FreeBSD.org

Expand Down
26 changes: 26 additions & 0 deletions Mk/Uses/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# min=number: use specified min if ${LLVM_DEFAULT} is lower
# max=number: use specified max if ${LLVM_DEFAULT} is higher
#
# * environment
# export: do export CC, CXX,... variables [default]
# noexport: do not export CC,CXX,... variables
#
# An example usage might be:
# USES= llvm
# or
Expand All @@ -35,6 +39,7 @@ _INCLUDE_USES_LLVM_MK= YES
_LLVM_MK_VALID_VERSIONS= 10 11 12 13 14 15 16
_LLVM_MK_VALID_CONSTRAINTS= min max
_LLVM_MK_VALID_MODES= build run lib
_LLVM_MK_VALID_EXPORTS= export noexport

# === parse mode arguments ===
_LLVM_MK_MODES= # empty
Expand Down Expand Up @@ -66,6 +71,21 @@ _LLVM_MK_VERSION= ${LLVM_DEFAULT}
. endif
. endif

# === parse environment arguments ===
_LLVM_MK_EXPORT= # empty
. for _export in ${_LLVM_MK_VALID_EXPORTS}
. if ${llvm_ARGS:M${_export}}
. if !empty(_LLVM_MK_EXPORT)
BROKEN= USES=llvm:${llvm_ARGS} contains multiple export definitions
. else
_LLVM_MK_EXPORT= ${_export}
. endif
. endif
. endfor
. if empty(_LLVM_MK_EXPORT)
_LLVM_MK_EXPORT= export
. endif

# === handle constraints ===
. for _constraint in ${_LLVM_MK_VALID_CONSTRAINTS}
_version= ${llvm_ARGS:M${_constraint}=[0-9]*:S/${_constraint}=//}
Expand Down Expand Up @@ -115,4 +135,10 @@ LLVM_LIBLLVM= ${_LLVM_MK_LIBLLVM}
LLVM_VERSION= ${_LLVM_MK_VERSION}
LLVM_PREFIX= ${_LLVM_MK_PREFIX}

. if empty(_LLVM_MK_EXPORT:Mnoexport)
CC= ${LLVM_PREFIX}/bin/clang
CXX= ${LLVM_PREFIX}/bin/clang++
CPP= ${LLVM_PREFIX}/bin/clang-cpp
. endif

.endif

0 comments on commit 4df0e66

Please sign in to comment.