kumquat-buildroot/support
Robin Jarry a25c190df4 support/scripts/pycompile: fix .pyc original source file paths
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>
(cherry picked from commit c566f5206a)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2020-09-15 20:06:11 +02:00
..
config-fragments support/config-fragments/autobuild: fix riscv toolchains 2020-01-02 09:15:43 +01:00
dependencies Config.in: drop BR2_NEEDS_HOST_{JAVAC,JAR} 2020-03-03 23:55:48 +01:00
docker support/docker: drop Python 2.x modules 2020-08-28 18:38:04 +02:00
download support/download: fix git wrapper with submodules on older git versions 2020-07-15 21:50:38 +02:00
gnuconfig support/gnuconfig: reference the correct sha1 we're using 2020-05-10 21:55:47 +02:00
kconfig support/kconfig/merge_config.sh: avoid false positive matches from comment lines 2018-11-24 10:11:15 +01:00
legal-info core/legal-info: update list of saved material in README 2020-01-18 18:38:42 +01:00
libtool support/libtool: add patch for newer versions 2014-12-21 13:21:56 +01:00
misc Makefile: make-4.3 now longer un-escapes \# in macros 2020-04-08 13:25:28 +02:00
scripts support/scripts/pycompile: fix .pyc original source file paths 2020-09-15 20:06:11 +02:00
testing support/testing/tests/core/test_timezone.py: fix indentation 2020-08-28 18:32:58 +02:00