From: Khem Raj <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH V2] multilib_header: Place a #include guard to avoid infinite inclusion of headers
Date: Thu, 31 Jan 2019 20:19:25 -0800 [thread overview]
Message-ID: <20190201041926.19257-1-raj.khem@gmail.com> (raw)
In cases where extra preprocessing tools are used such as clang-tidy
e.g. and these tools are not passed the knowledge about architecture
then a corner case comes where we enter into include loop for
bits/wordsize.h, since this template does explicitly include
bits/wordsize.h
so it synthesized a guard out of file name e.g.
bits/wordsize.h -> __BITS_WORDSIZE_H__
and emits the guard at beginning of file
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Drop space changes, not needed, and fix a typo > to >>
| 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--git a/meta/classes/multilib_header.bbclass b/meta/classes/multilib_header.bbclass
index e03f5b13b2..70b7117da8 100644
--- a/meta/classes/multilib_header.bbclass
+++ b/meta/classes/multilib_header.bbclass
@@ -33,10 +33,13 @@ oe_multilib_header() {
continue
fi
stem=$(echo $each_header | sed 's#\.h$##')
+ include_guard=$(echo $each_header | tr '/.' '_' | tr '[a-z]' '[A-Z]' | sed 's/^/__/' | sed 's/$/__/')
# if mips64/n32 set ident to n32
mv ${D}/${includedir}/$each_header ${D}/${includedir}/${stem}-${ident}.h
-
- sed -e "s#ENTER_HEADER_FILENAME_HERE#${stem}#g" ${COREBASE}/scripts/multilib_header_wrapper.h > ${D}/${includedir}/$each_header
+ echo "#ifndef $include_guard" > ${D}/${includedir}/$each_header
+ echo "#define $include_guard" >> ${D}/${includedir}/$each_header
+ sed -e "s#ENTER_HEADER_FILENAME_HERE#${stem}#g" ${COREBASE}/scripts/multilib_header_wrapper.h >> ${D}/${includedir}/$each_header
+ echo "#endif /* $include_guard */" >> ${D}/${includedir}/$each_header
done
}
--
2.20.1
reply other threads:[~2019-02-01 4:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190201041926.19257-1-raj.khem@gmail.com \
--to=raj.khem@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox