All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongxu Jia <hongxu.jia@windriver.com>
To: <ross.burton@intel.com>, <richard.purdie@linuxfoundation.org>,
	<raj.khem@gmail.com>, <mark.hatle@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: [PATCH 04/16] fix_buildpaths.bbclass: add bbclass to fix build path
Date: Tue, 22 Mar 2016 08:12:32 -0400	[thread overview]
Message-ID: <b4458bad3dc8814225f8dc3404c97509aed687d8.1458638728.git.hongxu.jia@windriver.com> (raw)
In-Reply-To: <cover.1458638728.git.hongxu.jia@windriver.com>

Define variable PACKAGE_BUILDPATH_TEXT_FILES to list files that have
build paths and remove these paths at do_package time. It supports
package override while files exist in conditionally generated package.
(such as ${PN}-ptest is conditionally generated)

Define variable PACKAGE_BUILDPATH_TEXT_PATTERNS to list build path
patterns, which used by sed, it removes --sysroot and
-fdebug-prefix-map in text files by default.

Define python function to remove build path in variable.

Define python function to remove build path in python compiled
code.

[YOCTO #9169]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes/fix_buildpaths.bbclass | 55 +++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 meta/classes/fix_buildpaths.bbclass

diff --git a/meta/classes/fix_buildpaths.bbclass b/meta/classes/fix_buildpaths.bbclass
new file mode 100644
index 0000000..eff0a30
--- /dev/null
+++ b/meta/classes/fix_buildpaths.bbclass
@@ -0,0 +1,55 @@
+PACKAGE_PREPROCESS_FUNCS += 'remove_buildpath_package_preprocess'
+
+def list_package_buildpath_text_files(d):
+    files = d.getVar('PACKAGE_BUILDPATH_TEXT_FILES', True) or ''
+
+    # Support package override
+    for pn in d.getVar('PACKAGES', True).split():
+        files += d.getVar('PACKAGE_BUILDPATH_TEXT_FILES_%s' % pn, True) or ''
+
+    return files
+
+remove_buildpath_package_preprocess () {
+	buildpath_files="${@list_package_buildpath_text_files(d)}"
+
+	# Remove build paths in text files
+	for file in $buildpath_files;do
+		sed -i ${PACKAGE_BUILDPATH_TEXT_PATTERNS} ${PKGD}$file
+	done
+}
+
+# List build path patterns, which used by sed, it removes
+# --sysroot and -fdebug-prefix-map by default.
+PACKAGE_BUILDPATH_TEXT_PATTERNS = " \
+    -e 's:--sysroot=${STAGING_DIR_TARGET}::g' \
+    -e 's:-fdebug-prefix-map=${WORKDIR}=/usr/src/debug::g' \
+    -e 's:-fdebug-prefix-map=${STAGING_DIR_NATIVE}=::g' \
+    -e 's:-fdebug-prefix-map=${STAGING_DIR_HOST}=::g' \
+"
+
+# List files which have build paths, and remove these paths.
+PACKAGE_BUILDPATH_TEXT_FILES ??= ""
+
+# Remove build path in variable
+def remove_buildpath_variable(d, var):
+    val = d.getVar(var, True) or ''
+
+    toolchain_opts = d.getVar('TOOLCHAIN_OPTIONS', True)
+    val = val.replace(toolchain_opts, '')
+
+    debug_flags = d.getVar('DEBUG_FLAGS', True).split()
+    for opt in debug_flags:
+        if '-fdebug-prefix-map=' in opt:
+            val = val.replace(opt, '')
+
+    return val
+
+# Remove build path in python compiled code which
+# located in root_path
+def remove_buildpath_bytecode(root_path, byte_code):
+    import py_compile
+
+    file = root_path + byte_code[0:-1]
+    dfile = byte_code[0:-1]
+    py_compile.compile(file, dfile=dfile)
+
-- 
1.9.1



  parent reply	other threads:[~2016-03-22 12:13 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 12:12 [PATCH V5 00/16] fix buildpaths QA issue Hongxu Jia
2016-03-22 12:12 ` [PATCH 01/16] conf/bitbake.conf package.bbclass: fix dbg package not contain sources while -fdebug-prefix-map used Hongxu Jia
2016-03-22 17:01   ` Mark Hatle
2016-03-23  1:11     ` Hongxu Jia
2016-03-22 12:12 ` [PATCH 02/16] kernel.bbclass: fix buildpath QA issue Hongxu Jia
2016-03-22 12:21   ` Bruce Ashfield
2016-03-22 16:18     ` Mark Hatle
2016-03-22 16:49       ` Bruce Ashfield
2016-03-22 16:57         ` Mark Hatle
2016-03-23  1:29         ` Hongxu Jia
2016-03-23 14:28           ` Bruce Ashfield
2016-03-23 15:50             ` Hongxu Jia
2016-03-22 12:12 ` [PATCH 03/16] dtc.inc: fix buildpaths " Hongxu Jia
2016-03-22 12:12 ` Hongxu Jia [this message]
2016-03-22 12:12 ` [PATCH 05/16] icu: " Hongxu Jia
2016-03-22 12:12 ` [PATCH 06/16] tcl: fix buildpath " Hongxu Jia
2016-03-22 12:12 ` [PATCH 07/16] python2/3: " Hongxu Jia
2016-03-22 12:12 ` [PATCH 08/16] bbclass distutils/distutils3: fix .pyc/.pyo buildpath Hongxu Jia
2016-03-22 12:12 ` [PATCH 09/16] bbclass distutils/distutils3/setuptools/setuptools3: clean up DISTUTILS_INSTALL_ARGS Hongxu Jia
2016-03-22 12:12 ` [PATCH 10/16] python-setuptools/python3-setuptools: use old-style install Hongxu Jia
2016-03-22 12:12 ` [PATCH 11/16] python3-pip: " Hongxu Jia
2016-03-22 12:12 ` [PATCH 12/16] waf.bbclass: support do patch on extracted files Hongxu Jia
2016-03-22 12:12 ` [PATCH 13/16] python-pycairo: fix buildpath QA issue Hongxu Jia
2016-03-22 12:12 ` [PATCH 14/16] openssl: " Hongxu Jia
2016-03-22 12:12 ` [PATCH 15/16] epiphany: fix buildpaths " Hongxu Jia
2016-03-22 12:12 ` [PATCH 16/16] gconf: " Hongxu Jia
2016-03-23  6:15 ` [PATCH V6 00/15] " Hongxu Jia
2016-03-23  6:15   ` [PATCH V2 01/15] conf/bitbake.conf package.bbclass: fix dbg package not contain sources while -fdebug-prefix-map used Hongxu Jia
2016-03-23 13:40     ` Mark Hatle
2016-03-23 14:15       ` Hongxu Jia
2016-03-23  6:15   ` [PATCH 03/15] fix_buildpaths.bbclass: add bbclass to fix build path Hongxu Jia

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=b4458bad3dc8814225f8dc3404c97509aed687d8.1458638728.git.hongxu.jia@windriver.com \
    --to=hongxu.jia@windriver.com \
    --cc=mark.hatle@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=raj.khem@gmail.com \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=ross.burton@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.