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....@windriver.com> --- 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 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core