From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by mail.openembedded.org (Postfix) with ESMTP id C5DCF6FF5D for ; Mon, 28 Mar 2016 08:19:18 +0000 (UTC) Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id u2S8JIDg007005 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 28 Mar 2016 01:19:18 -0700 (PDT) Received: from pek-lpggp1.wrs.com (128.224.153.74) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.248.2; Mon, 28 Mar 2016 01:19:17 -0700 From: Hongxu Jia To: , , Date: Mon, 28 Mar 2016 04:18:49 -0400 Message-ID: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Cc: openembedded-core@lists.openembedded.org Subject: [PATCH 05/17] fix_buildpaths.bbclass: add bbclass to fix build path X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2016 08:19:19 -0000 Content-Type: text/plain 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 --- meta/classes/fix_buildpaths.bbclass | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 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..7ab7c66 --- /dev/null +++ b/meta/classes/fix_buildpaths.bbclass @@ -0,0 +1,66 @@ +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 ${@get_package_buildpath_text_patterns(d)} ${PKGD}$file + done +} + +def get_package_buildpath_text_patterns(d): + result = d.getVar("PACKAGE_BUILDPATH_TEXT_PATTERNS", True) or "" + + # Add --sysroot as default pattern + toolchain_opt = d.getVar("TOOLCHAIN_OPTIONS", True).split() + for opt in toolchain_opt: + if '--sysroot' in opt: + result += " -e 's:%s::g'" % opt + + # Add -fdebug-prefix-map as default pattern + debug_flags = d.getVar('DEBUG_FLAGS', True).split() + for opt in debug_flags: + if '-fdebug-prefix-map=' in opt: + result += " -e 's:%s::g'" % opt + + return result + +# List build path patterns, which used by sed +PACKAGE_BUILDPATH_TEXT_PATTERNS = "" + +# 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