Bug 12380 - Variable definition: leading spaces stripping behavior is not consistent
Summary: Variable definition: leading spaces stripping behavior is not consistent
Status: RESOLVED FIXED
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: 2.5
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.7 M2
Assignee: Robert Yang
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-11-24 03:29 UTC by Jackie Huang
Modified: 2019-02-13 09:06 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jackie Huang 2017-11-24 03:29:29 UTC
When I define variable over multiple lines with backslash character ("\"), I found that the leading spaces stripping behavior is not consistent:

The leading spaces will be stripped when definition is in .conf file, but they will be preserved when the definition is in .inc, .bb, .bbclass.

e.g.

I added the following definitions in different files:
1) meta/conf/bitbake.conf
+ARF = "bitbake1"
+
+ARF_append = "\
+    bitbake2 \
+"

2) meta/classes/autotools.bbclass
+ARF_append = "\
+    class1 \
+"

3) meta/conf/distro/include/default-versions.inc
+ARF_append = "\
+    inc1 \
+"

4) meta/recipes-core/ncurses/ncurses.inc
+ARF_append = "\
+    inc2 \
+"

5) meta/recipes-core/ncurses/ncurses_6.0+20170715.bb
+ARF_append = "\
+    bb1 \
+"


Then run "bitbake -e" to see the result:
$ bitbake -e ncurses

# $ARF [7 operations]
#   _append /ala-lpggp51/jhuang0/builds/yp/y_all_171124/conf/local.conf:241
#     "local1 "
#   _append /ala-lpggp51/jhuang0/builds/yp/poky/meta/conf/distro/include/default-versions.inc:11
#     "    inc1 "
#   set /ala-lpggp51/jhuang0/builds/yp/poky/meta/conf/bitbake.conf:879
#     "bitbake1"
#   _append /ala-lpggp51/jhuang0/builds/yp/poky/meta/conf/bitbake.conf:883
#     "bitbake2 "
#   _append /ala-lpggp51/jhuang0/builds/yp/poky/meta/classes/autotools.bbclass:260
#     "    class1 "
#   _append /ala-lpggp51/jhuang0/builds/yp/poky/meta/recipes-core/ncurses/ncurses.inc:318
#     "    inc2 "
#   _append /ala-lpggp51/jhuang0/builds/yp/poky/meta/recipes-core/ncurses/ncurses_6.0+20170715.bb:16
#     "    bb1 "
# pre-expansion value:
#   "bitbake1local1     inc1 bitbake2     class1     inc2     bb1 "
ARF="bitbake1local1     inc1 bitbake2     class1     inc2     bb1 "

According to the doc:
http://www.yoctoproject.org/docs/2.4/bitbake-user-manual/bitbake-user-manual.html#line-joining

"""
Both the "\" character and the newline character that follow it are removed when joining lines.
"""

leading spaces stripping/removing is not mentioned in the bitbake user manual, so
I don't know which behavior is expected, but I think at least they should have the same behavior.
Comment 1 Richard Purdie 2017-11-30 16:05:19 UTC
There are two different parsers for the two difference sets of filetypes. I suspect this is some inconsistency between ConfHandler.py and BBHandler.py