c566f5206a
When generating a .pyc file, the original .py source file path is encoded in it. It is used for various purposes: traceback generation, .pyc file comparison with its .py source, and code inspection. By default, the source path used when invoking compileall is encoded in the .pyc file. Since we use paths relative to TARGET_DIR, we end up with paths that are only valid when relative to '/' encoded in the installed .pyc files on the target. This breaks code inspection at runtime since the original source path will be invalid unless the code is executed from '/'. Unfortunately, compileall cannot be forced to use the proper path. It was not written with cross-compilation usage in mind. Rework the script to call py_compile.compile() directly with pertinent options: - The script now has a new --strip-root argument. This argument is optional but will always be specified when compiling py files in buildroot. - All other (non-optional) arguments are folders in which all "importable" .py files will be compiled to .pyc. - Using --strip-root=$(TARGET_DIR), the future runtime path of each .py file is computed and encoded into the compiled .pyc. No need to change directory before running the script anymore. The trickery used to handle error reporting was only applicable with compileall. Since we implement our own "compileall", error reporting becomes trivial. Previously, we had a --force option to tell compileall.compiledir() to forcibly recompile files if they had changed. Now, we would have to handle it ourselves. It turns out to not be easy and would need us to delve into the format of bytecompiled files to extract metadata and compare it with the expected values, that being even dependent on the python version being used (fortunately, only two for us: python 2.7 and the latext 3.x). Still, this is deemed too complex, and byte-compiling is pretty fast, so much so that it should be eclipsed by the build duration anyway. So we just drop support for --force, and instead we always byte-compile. Signed-off-by: Julien Floret <julien.floret@6wind.com> Signed-off-by: Robin Jarry <robin.jarry@6wind.com> [yann.morin.1998@free.fr: - always byte-compile - drop --force - expand commit log to state so and explain why ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> |
||
---|---|---|
.. | ||
apply-patches.sh | ||
boot-qemu-image.py | ||
br2-external | ||
brpkgutil.py | ||
check-bin-arch | ||
check-dotconfig.py | ||
check-host-rpath | ||
check-kernel-headers.sh | ||
check-merged-usr.sh | ||
cve-checker | ||
cve.py | ||
eclipse-register-toolchain | ||
expunge-gconv-modules | ||
fix-configure-powerpc64.sh | ||
fix-rpath | ||
gen-bootlin-toolchains | ||
generate-gitlab-ci-yml | ||
genimage.sh | ||
graph-build-time | ||
graph-depends | ||
hardlink-or-copy | ||
mkmakefile | ||
mkusers | ||
pkg-stats | ||
pycompile.py | ||
setlocalversion | ||
size-stats |