2
1

micropython.mk 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ################################################################################
  2. #
  3. # micropython
  4. #
  5. ################################################################################
  6. MICROPYTHON_VERSION = 1.22.2
  7. MICROPYTHON_SITE = https://micropython.org/resources/source
  8. MICROPYTHON_SOURCE = micropython-$(MICROPYTHON_VERSION).tar.xz
  9. # Micropython has a lot of code copied from other projects, and also a number
  10. # of submodules for various libs. However, we don't even clone the submodules,
  11. # and most of the copied code is not used in the unix build.
  12. MICROPYTHON_LICENSE = MIT, BSD-1-Clause, BSD-3-Clause, Zlib
  13. MICROPYTHON_LICENSE_FILES = LICENSE
  14. MICROPYTHON_DEPENDENCIES = host-python3
  15. MICROPYTHON_CPE_ID_VENDOR = micropython
  16. # 0004-py-objarray-fix-use-after-free-if-extending-a-bytearray-from-itself.patch
  17. MICROPYTHON_IGNORE_CVES += CVE-2024-8947
  18. # Use fallback implementation for exception handling on architectures that don't
  19. # have explicit support.
  20. ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb),)
  21. MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
  22. endif
  23. # xtensa has problems with nlr_push, use setjmp based implementation instead
  24. ifeq ($(BR2_xtensa),y)
  25. MICROPYTHON_CFLAGS = -DMICROPY_NLR_SETJMP=1
  26. endif
  27. # When building from a tarball we don't have some of the dependencies that are in
  28. # the git repository as submodules
  29. MICROPYTHON_MAKE_OPTS += \
  30. MICROPY_PY_BTREE=0 \
  31. MICROPY_PY_USSL=0 \
  32. CROSS_COMPILE=$(TARGET_CROSS) \
  33. CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
  34. LDFLAGS_EXTRA="$(TARGET_LDFLAGS)" \
  35. CWARN=
  36. ifeq ($(BR2_PACKAGE_LIBFFI),y)
  37. MICROPYTHON_DEPENDENCIES += host-pkgconf libffi
  38. MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=1
  39. else
  40. MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=0
  41. endif
  42. define MICROPYTHON_BUILD_CMDS
  43. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/mpy-cross
  44. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
  45. $(MICROPYTHON_MAKE_OPTS)
  46. endef
  47. define MICROPYTHON_INSTALL_TARGET_CMDS
  48. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
  49. $(MICROPYTHON_MAKE_OPTS) \
  50. DESTDIR=$(TARGET_DIR) \
  51. PREFIX=/usr \
  52. install
  53. endef
  54. ifeq ($(BR2_PACKAGE_MICROPYTHON_LIB),y)
  55. define MICROPYTHON_COLLECT_LIBS
  56. $(EXTRA_ENV) PYTHONPATH=$(@D)/tools \
  57. package/micropython/collect_micropython_lib.py \
  58. $(@D) $(@D)/.built_pylib
  59. endef
  60. define MICROPYTHON_INSTALL_LIBS
  61. $(INSTALL) -d -m 0755 $(TARGET_DIR)/usr/lib/micropython
  62. cp -a $(@D)/.built_pylib/* $(TARGET_DIR)/usr/lib/micropython
  63. endef
  64. MICROPYTHON_POST_BUILD_HOOKS += MICROPYTHON_COLLECT_LIBS
  65. MICROPYTHON_POST_INSTALL_TARGET_HOOKS += MICROPYTHON_INSTALL_LIBS
  66. endif
  67. $(eval $(generic-package))