8f403f0137
Until now, micropython-lib was a package that installed v1.9.3, which is more than 6 years old. This was acceptable since micropython never made any other official release of the library until v1.20. Meanwhile, the libraries underwent a reorganization, and they are now available in a directory structure that cannot be copied directly into the target. This might explain why v1.9.3 is still present in the current day buildroot (which comes with micropython v1.22). As part of the changes made by the micropython project, the libraries are now released together with the interpreter. They are cloned as a submodule into the lib/micropython-lib directory, and are present in the release tarball. This commit introduces an auxiliary script to collect those libraries and reorder them into a structure that can then be copied into /usr/lib/micropython. The script utilizes a module from the tools directory of the micropython repo. The helper script is kept as simple as possible, and makes use of existing micropython tools (used to process manifests) to discover the list of packages available in micropython-lib. The hope is that by relying on them, any future changes in directory structure will be covered by the official "manifestfile.py" tool. It is to be noted that, even though the manifestfile.py script/module is part of the micropython package, it is actually written for CPython, and is not expected to even work when using micropython as an interpreter. This we do not need to introduce host-micropython to use that tool, and microython already depends on host-python3 for other parts of the build. With this commit, micropython-lib is installed (optionally) as part of micropython, and thus a separate package is no longer needed. The original config variable name was retained as it fits with the micropython package "namespace", and thus this is backward compatible and no legacy handling is needed. This commit also ensures that the libraries in micropython-lib will be updated together with newer versions of micropython in the future. Signed-off-by: Abilio Marques <abiliojr@gmail.com> [yann.morin.1998@free.fr: - use if-block in Config.in - simplify PYTHONPATH - fix check-package - reword and reorder parts of the commit log ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
77 lines
2.4 KiB
Makefile
77 lines
2.4 KiB
Makefile
################################################################################
|
|
#
|
|
# micropython
|
|
#
|
|
################################################################################
|
|
|
|
MICROPYTHON_VERSION = 1.22.0
|
|
MICROPYTHON_SITE = https://micropython.org/resources/source
|
|
MICROPYTHON_SOURCE = micropython-$(MICROPYTHON_VERSION).tar.xz
|
|
# Micropython has a lot of code copied from other projects, and also a number
|
|
# of submodules for various libs. However, we don't even clone the submodules,
|
|
# and most of the copied code is not used in the unix build.
|
|
MICROPYTHON_LICENSE = MIT, BSD-1-Clause, BSD-3-Clause, Zlib
|
|
MICROPYTHON_LICENSE_FILES = LICENSE
|
|
MICROPYTHON_DEPENDENCIES = host-python3
|
|
MICROPYTHON_CPE_ID_VENDOR = micropython
|
|
|
|
# Use fallback implementation for exception handling on architectures that don't
|
|
# have explicit support.
|
|
ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb),)
|
|
MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
|
|
endif
|
|
|
|
# xtensa has problems with nlr_push, use setjmp based implementation instead
|
|
ifeq ($(BR2_xtensa),y)
|
|
MICROPYTHON_CFLAGS = -DMICROPY_NLR_SETJMP=1
|
|
endif
|
|
|
|
# When building from a tarball we don't have some of the dependencies that are in
|
|
# the git repository as submodules
|
|
MICROPYTHON_MAKE_OPTS += \
|
|
MICROPY_PY_BTREE=0 \
|
|
MICROPY_PY_USSL=0 \
|
|
CROSS_COMPILE=$(TARGET_CROSS) \
|
|
CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
|
|
LDFLAGS_EXTRA="$(TARGET_LDFLAGS)" \
|
|
CWARN=
|
|
|
|
ifeq ($(BR2_PACKAGE_LIBFFI),y)
|
|
MICROPYTHON_DEPENDENCIES += host-pkgconf libffi
|
|
MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=1
|
|
else
|
|
MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=0
|
|
endif
|
|
|
|
define MICROPYTHON_BUILD_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/mpy-cross
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
|
|
$(MICROPYTHON_MAKE_OPTS)
|
|
endef
|
|
|
|
define MICROPYTHON_INSTALL_TARGET_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
|
|
$(MICROPYTHON_MAKE_OPTS) \
|
|
DESTDIR=$(TARGET_DIR) \
|
|
PREFIX=/usr \
|
|
install
|
|
endef
|
|
|
|
ifeq ($(BR2_PACKAGE_MICROPYTHON_LIB),y)
|
|
define MICROPYTHON_COLLECT_LIBS
|
|
$(EXTRA_ENV) PYTHONPATH=$(@D)/tools \
|
|
package/micropython/collect_micropython_lib.py \
|
|
$(@D) $(@D)/.built_pylib
|
|
endef
|
|
|
|
define MICROPYTHON_INSTALL_LIBS
|
|
$(INSTALL) -d -m 0755 $(TARGET_DIR)/usr/lib/micropython
|
|
cp -a $(@D)/.built_pylib/* $(TARGET_DIR)/usr/lib/micropython
|
|
endef
|
|
|
|
MICROPYTHON_POST_BUILD_HOOKS += MICROPYTHON_COLLECT_LIBS
|
|
MICROPYTHON_POST_INSTALL_TARGET_HOOKS += MICROPYTHON_INSTALL_LIBS
|
|
endif
|
|
|
|
$(eval $(generic-package))
|