Bug 4366 - Several variables' assignments are hard to understand
Summary: Several variables' assignments are hard to understand
Status: VERIFIED WONTFIX
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: configuration (show other bugs)
Version: 1.5
Hardware: x86 Multiple
: Low enhancement
Target Milestone: 1.5 M3
Assignee: Chen Qi
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2013-04-22 05:59 UTC by Robert Yang
Modified: 2013-10-02 09:59 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Yang 2013-04-22 05:59:28 UTC
Several variables' assignments are hard to understand, e.g., in bitbake.conf:

TARGET_SYS = "${TARGET_ARCH}${TARGET_VENDOR}${@['-' + d.getVar('TARGET_OS', True), ''][d.getVar('TARGET_OS', True) == ('' or 'custom')]}"

MACHINE_ARCH = "${@[d.getVar('TUNE_PKGARCH', True), d.getVar('MACHINE', True)][bool(d.getVar('MACHINE', True))].replace('-', '_')}"

Can we find a new way for the assignments ? For example, put the expression in the function or create a new syntax.
Comment 1 Chen Qi 2013-07-09 08:48:59 UTC
Hi All,

I've extracted those seemingly hard-to-understand lines from bitbake.conf.

TARGET_SYS = "${TARGET_ARCH}${TARGET_VENDOR}${@['-' + d.getVar('TARGET_OS', True), ''][d.getVar('TARGET_OS', True) == ('' or 'custom')]}"

SDK_SYS = "${SDK_ARCH}${SDK_VENDOR}${@['-' + d.getVar('SDK_OS', True), ''][d.getVar('SDK_OS', True) == ('' or 'custom')]}"

MACHINE_ARCH = "${@[d.getVar('TUNE_PKGARCH', True), d.getVar('MACHINE', True)][bool(d.getVar('MACHINE', True))].replace('-', '_')}"

EXTENDPE = "${@['','${PE\x7d_'][int(d.getVar('PE',1) or 0) > 0]}"

EXTENDPRAUTO = "${@['.${PRAUTO\x7d',''][d.getVar('PRAUTO',1) is None]}"

EXTENDPKGEVER = "${@['','${PKGE\x7d:'][d.getVar('PKGE',1).strip() != '']}"

FILES_${PN}-dbg = "${@d.getVar(['DOTDEBUG-dbg', 'DEBUGFILEDIRECTORY-dbg'][d.getVar('PACKAGE_DEBUG_SPLIT_STYLE', True) == 'debug-file-directory'], True)}"

export CCACHE_DISABLE ??= "${@[0,1][d.getVar('CCACHE', True) == '']}"

SELECTED_OPTIMIZATION = "${@d.getVar(['FULL_OPTIMIZATION', 'DEBUG_OPTIMIZATION'][d.getVar('DEBUG_BUILD', True) == '1'], True)}"

These lines have one thing in common, that is, they choose between value1 and value2 according to condition. I don't see an easier way to do this than [value1,value2][condition].

The true problem here, from my point of view, is lack of documentation of these variables. For example, I can't find MACHINE_ARCH, TARGET_SYS and SDK_SYS in the glossary section of the reference manual.

P.S.
The assignment is kind of weird for TARGET_SYS and SDK_SYS, as ('' or 'custom') equals to 'custom'.

I think what is expected is:
TARGET_SYS = "${TARGET_ARCH}${TARGET_VENDOR}${@['-' + d.getVar('TARGET_OS', True), ''][d.getVar('TARGET_OS', True) == '' or d.getVar('TARGET_OS', True) == 'custom']}"
Comment 2 Chen Qi 2013-07-09 09:09:27 UTC
Close this bug.
Reason detailed in the last comment.

//Chen Qi
Comment 3 Stoicescu Cornel 2013-10-02 09:59:39 UTC
There have been no modification done to bitbake.conf on behalf of this bug.

Verified in:
poky master:4d8ab87d25ea6e59dc88375813ef88ee0ac813d0