Skip to content

Commit

Permalink
flag-o-matic.eclass: add assertions around argument counts
Browse files Browse the repository at this point in the history
Signed-off-by: Sergei Trofimovich <[email protected]>
  • Loading branch information
Sergei Trofimovich committed Mar 14, 2020
1 parent bcf1fe4 commit f8669c1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eclass/flag-o-matic.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ filter-mfpmath() {
# Strip *FLAGS of everything except known good/safe flags. This runs over all
# flags returned by all_flag_vars().
strip-flags() {
[[ $# -ne 0 ]] && die "strip-flags takes no arguments"
local x y var

local ALLOWED_FLAGS
Expand Down Expand Up @@ -618,6 +619,7 @@ test_version_info() {
# @DESCRIPTION:
# Strip {C,CXX,F,FC}FLAGS of any flags not supported by the active toolchain.
strip-unsupported-flags() {
[[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments"
export CFLAGS=$(test-flags-CC ${CFLAGS})
export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
export FFLAGS=$(test-flags-F77 ${FFLAGS})
Expand All @@ -630,6 +632,7 @@ strip-unsupported-flags() {
# @DESCRIPTION:
# Find and echo the value for a particular flag. Accepts shell globs.
get-flag() {
[[ $# -ne 1 ]] && die "usage: <flag>"
local f var findflag="$1"

# this code looks a little flaky but seems to work for
Expand All @@ -652,6 +655,7 @@ get-flag() {
# @DESCRIPTION:
# Sets mcpu to v8 and uses the original value as mtune if none specified.
replace-sparc64-flags() {
[[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments"
local SPARC64_CPUS="ultrasparc3 ultrasparc v9"

if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
Expand Down Expand Up @@ -735,6 +739,7 @@ raw-ldflags() {
# @FUNCTION: no-as-needed
# @RETURN: Flag to disable asneeded behavior for use with append-ldflags.
no-as-needed() {
[[ $# -ne 0 ]] && die "no-as-needed takes no arguments"
case $($(tc-getLD) -v 2>&1 </dev/null) in
*GNU*) # GNU ld
echo "-Wl,--no-as-needed" ;;
Expand Down

0 comments on commit f8669c1

Please sign in to comment.