Bug 4366

Summary: Several variables' assignments are hard to understand
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Robert Yang <liezhi.yang>
Component: configurationAssignee: Chen Qi <Qi.Chen>
Status: VERIFIED WONTFIX QA Contact:
Severity: enhancement    
Priority: Low CC: corneliux.stoicescu, mark.hatle, Qi.Chen, richard.purdie, sgw
Version: 1.5   
Target Milestone: 1.5 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

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