zephyr/lib/libc/Kconfig
Ulf Magnusson eddd98f811 kconfig: Replace some single-symbol 'if's with 'depends on'
I think people might be reading differences into 'if' and 'depends on'
that aren't there, like maybe 'if' being needed to "hide" a symbol,
while 'depends on' just adds a dependency.

There are no differences between 'if' and 'depends on'. 'if' is just a
shorthand for 'depends on'. They work the same when it comes to creating
implicit menus too.

The way symbols get "hidden" is through their dependencies not being
satisfied ('if'/'depends on' get copied up as a dependency on the
prompt).

Since 'if' and 'depends on' are the same, an 'if' with just a single
symbol in it can be replaced with a 'depends on'. IMO, it's best to
avoid 'if' there as a style choice too, because it confuses people into
thinking there's deep Kconfig magic going on that requires 'if'.

Going for 'depends on' can also remove some nested 'if's, which
generates nicer symbol information and docs, because nested 'if's really
are so simple/dumb that they just add the dependencies from both 'if's
to all symbols within.

Replace a bunch of single-symbol 'if's with 'depends on' to despam the
Kconfig files a bit and make it clearer how things work. Also do some
other minor related dependency refactoring.

The replacement isn't complete. Will fix up the rest later. Splitting it
a bit to make it more manageable.

(Everything above is true for choices, menus, and comments as well.)

Detected by tweaking the Kconfiglib parsing code. It's impossible to
detect after parsing, because 'if' turns into 'depends on'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 08:32:42 -05:00

135 lines
3.6 KiB
Plaintext

# C library
# Copyright (c) 2016 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
menu "C Library"
config REQUIRES_FULL_LIBC
bool
help
Helper symbol to indicate some feature requires a C library implementation
with more functionality than what MINIMAL_LIBC provides
choice LIBC_IMPLEMENTATION
prompt "C Library Implementation"
default EXTERNAL_LIBC if NATIVE_APPLICATION
default NEWLIB_LIBC if REQUIRES_FULL_LIBC
default MINIMAL_LIBC
config MINIMAL_LIBC
bool "Minimal C library"
depends on !NATIVE_APPLICATION
depends on !REQUIRES_FULL_LIBC
help
Build with minimal C library.
config NEWLIB_LIBC
bool "Newlib C library"
depends on !NATIVE_APPLICATION
help
Build with newlib library. The newlib library is expected to be
part of the SDK in this case.
config EXTERNAL_LIBC
bool "External C library"
help
Build with external/user provided C library.
endchoice # LIBC_IMPLEMENTATION
config HAS_NEWLIB_LIBC_NANO
bool
if NEWLIB_LIBC
config NEWLIB_LIBC_NANO
bool "Build with newlib-nano C library"
depends on HAS_NEWLIB_LIBC_NANO
default y
help
Build with newlib-nano library, for small embedded apps.
The newlib-nano library for ARM embedded processors is a part of the
GNU Tools for ARM Embedded Processors.
config NEWLIB_LIBC_ALIGNED_HEAP_SIZE
int "Newlib aligned heap size"
depends on MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT
depends on USERSPACE
default 0
help
If user mode is enabled, and MPU hardware has requirements that
regions be sized to a power of two and aligned to their size,
and user mode threads need to access this heap, then this is necessary
to properly define an MPU region for the heap.
If this is left at 0, then remaining system RAM will be used for this
area and it may not be possible to program it as an MPU region.
config NEWLIB_LIBC_FLOAT_PRINTF
bool "Build with newlib float printf"
help
Build with floating point printf enabled. This will increase the size of
the image.
config NEWLIB_LIBC_FLOAT_SCANF
bool "Build with newlib float scanf"
help
Build with floating point scanf enabled. This will increase the size of
the image.
endif # NEWLIB_LIBC
if MINIMAL_LIBC
config MINIMAL_LIBC_MALLOC
bool "Enable minimal libc malloc implementation"
default y
help
Enable the minimal libc's implementation of malloc, free, and realloc.
Disable if you wish to provide your own implementations of these functions.
config MINIMAL_LIBC_MALLOC_ARENA_SIZE
int "Size of the minimal libc malloc arena"
default 0
depends on MINIMAL_LIBC_MALLOC
help
Indicate the size of the memory arena used for minimal libc's
malloc() implementation. This size value must be compatible with
a sys_mem_pool definition with nmax of 1 and minsz of 16.
config MINIMAL_LIBC_CALLOC
bool "Enable minimal libc trivial calloc implementation"
default y
help
Enable the minimal libc's trivial implementation of calloc, which
forwards to malloc and memset.
config MINIMAL_LIBC_REALLOCARRAY
bool "Enable minimal libc trivial reallocarray implementation"
default y
help
Enable the minimal libc's trivial implementation of reallocarray, which
forwards to realloc.
config MINIMAL_LIBC_LL_PRINTF
bool "Build with minimal libc long long printf" if !64BIT
default y if 64BIT
help
Build with long long printf enabled. This will increase the size of
the image.
endif # MINIMAL_LIBC
config STDOUT_CONSOLE
bool "Send stdout to console"
depends on CONSOLE_HAS_DRIVER
depends on !NATIVE_APPLICATION
default y
help
This option directs standard output (e.g. printf) to the console
device, rather than suppressing it entirely. See also EARLY_CONSOLE
option.
endmenu