AOSC Wiki / Developer / Packaging / Autobuild4 / .

Autobuild4 - API

Autobuild4 API Documentation

This page describes the convenience functions provided by Autobuild4. These functions are implemented as Bash builtins, so they are not unsettable via unset -f.

bool

Truthy value includes:

Falsy value includes:

When used in a conditional expression:

if bool "$VAR"; then
  echo "true"
else
  echo "false"
fi

abisarray

When used in a conditional expression:

if abisarray ARRAY_NAME; then
  echo "is normal array"
else
  echo "is something else"
fi

abisdefined

When used in a conditional expression:

EMPTY=
if abisdefined EMPTY; then
  echo "is defined"
else
  echo "is undefined"
fi
# expected result: is defined

load_strict

diag_print_backtrace

abinfo abwarn aberr abdbg

abdie

arch_loadvar

arch_loaddefines

arch_loadfile

arch_loadfile_strict

arch_findfile

abcopyvar

Original TypeOperation
Normal StringThe duplicated variable will be a reference to the original, meaning if the original variable changes the value, it will change too
Normal ArrayThe duplicated variable will be created by copying all the elements from the original variable. The duplicated variable will be independent from the original variable.
Associated ArrayThe duplicated variable will be created by copying all the key-value pairs from the original variable. The duplicated variable will be independent from the original variable.
IntegerAn error will be thrown
FunctionAn error will be thrown

ab_concatarray

A=(1 2 3)
B=(4 5 6)
ab_concatarray A B
echo "${A[@]}"
echo "${B[@]}"
# expected result:
# 1 2 3 4 5 6
# 4 5 6

elf_install_symfile

elf_copydbg

ab_filter_args

ARGS=(-fno-integrated-as -mcmodel=large -flto -O3 -mxgot -fuse-ld=gold)
ab_filter_args ARGS '-flto' '-O3'
echo "${ARGS[@]}"
# expected result: -fno-integrated-as -mcmodel=large -mxgot -fuse-ld=gold

ab_read_listing_file

Given a file named list.txt:

1
2
3
# 4
5
6

When reading with:

ab_read_listing_file list.txt OUT_VAR
echo "${OUT_VAR[@]}"

The result will be:

# expected result: 1 2 3 5 6

ab_tostringarray

Original TypeOperation
Normal StringThe variable will be splitted using IFS and converted to an array
Normal ArrayNo change
IntegerThe variable will be converted to a string and then converted to an array with only one element
Associated ArrayThe variable will be converted to an array containing all the key names of the original associated array
FunctionAn error will be thrown

ab_typecheck

OptionType
-aNormal Array
-hAssociated Array
-sNormal String
-iInteger
-fFunction

The options can be combined to form an OR-ed type-checking. E.g. ab_typecheck -as will check if the variable is either an array or a string, and will return false if the variable is neither.

VALUE=()
if ab_typecheck -as; then
  echo "is an array or string"
fi
VALUE2=""
if ab_typecheck -as; then
  echo "is also an array or string"
fi
# expected result:
# is an array or string
# is also an array or string

abelf_copy_dbg_parallel

abpm_debver

abpm_dump_builddep_req