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 | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 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..f97057a --- /dev/null +++ b/meta/classes/fix_buildpaths.bbclass @@ -0,0 +1,56 @@ +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=${B}=/usr/src/${BPN}::g' \ + -e 's:-fdebug-prefix-map=${S}=/usr/src/${BPN}::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 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core