From patchwork Mon Feb 12 02:12:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Abilio Marques X-Patchwork-Id: 1897543 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TY7KT5Yxvz23fC for ; Mon, 12 Feb 2024 13:13:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 356E440118; Mon, 12 Feb 2024 02:13:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1FfXFZAy_mDY; Mon, 12 Feb 2024 02:13:13 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CCB0540BDD Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id CCB0540BDD; Mon, 12 Feb 2024 02:13:12 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 04CA31BF420 for ; Mon, 12 Feb 2024 02:13:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E55F7840D2 for ; Mon, 12 Feb 2024 02:13:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yX0H8Y7uAbJC for ; Mon, 12 Feb 2024 02:13:10 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::1130; helo=mail-yw1-x1130.google.com; envelope-from=abiliojr@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org C1A66840D1 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C1A66840D1 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by smtp1.osuosl.org (Postfix) with ESMTPS id C1A66840D1 for ; Mon, 12 Feb 2024 02:13:09 +0000 (UTC) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-604aaf2d047so27858207b3.0 for ; Sun, 11 Feb 2024 18:13:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707703988; x=1708308788; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wiNdBhPmcHGXDhX9/zNsR39SSeoKQJuC0vA3h97ZgCA=; b=P494npLHXdetQk1jAXK74veE/37pboRWkC/uLU1rBGVpdsSaYnBXwU4GxZqAmErsQC LGzBO2Bi0y+HWLoiSrHnvOMUwZ/prV0Mtqe9Xda4Y53EgZ+KIrOwY9B4PRi2Wu0wlEmP Wq6i8qWkXyNPyIJrIdheMfSDRV9sA2t7D4A9bqgeGqbwq7mhQySJL5Q3sSccJjIDDbiX URNtKgXAmSvU9MP8AyV0Nq5pYTwETJPVqTpSHBdMVfad03Oc7Pfiujsu4uguQMhugW5Z g2eilvggOaBnP5mlmzRHpxy2F0eFOqsCjZxnnazZN2+IfaICfCuyhdEMsX05lDi8Wb25 pzBA== X-Gm-Message-State: AOJu0YyG2qtHz1kLDUpkffE+/laRSz3oohWEj7i8XZUljY/d0j/GP/+x 4E2D3g674JmGODc7WNMGE4Ixzd0fkGgzQgQhXL8xHJQiKLv+jORj3mi1MYcwbss= X-Google-Smtp-Source: AGHT+IGTFOv7ajGaN7Oj91yyNX4YliXwai7Rnzztq02pK1c896bBkvNPCwlHPy+q2mD9D+JcUu9BYw== X-Received: by 2002:a81:92d2:0:b0:602:d17a:7cb8 with SMTP id j201-20020a8192d2000000b00602d17a7cb8mr4564033ywg.11.1707703988588; Sun, 11 Feb 2024 18:13:08 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWBV/XK2J2hyxNlMI3jeksAwXyUuCTfasGAi810OC2FuuysBnacw+IgGUcc9PoihUhLXlPgIEcjLAVPeTniNaMLNDpvERG4JbfE6TAbVh6TKfanF8UedM/ScooY Received: from thinkpad.lan ([2600:1700:3eca:ac1f:a11a:f043:3678:9ceb]) by smtp.gmail.com with ESMTPSA id r71-20020a0de84a000000b006049b905176sm998816ywe.39.2024.02.11.18.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 18:13:07 -0800 (PST) From: Abilio Marques To: buildroot@buildroot.org Date: Sun, 11 Feb 2024 18:12:53 -0800 Message-ID: <20240212021255.246556-1-abiliojr@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707703988; x=1708308788; darn=buildroot.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wiNdBhPmcHGXDhX9/zNsR39SSeoKQJuC0vA3h97ZgCA=; b=io85M3HduTwupq8XyosvuBOQBBbhNpFpAQ2V1s7+Rn1bbpBvxYwm9MmAa6Amntzk9v Z7XOPJRw5gpOEHXEB3nog9EDq5GhCzOFXXwmq4EYlhoX887Ato15jizYPR9iaHxLls47 RHolOZ+WGRJBfClAXH0PIJek7wrN/KK88Rb8a2N73DgwmeCYr8Zb9mxAXUqfXiY25sHC OCvyoPBMZL+Ui5IM0F9VlzsN6Ah/vZctABZ5SPE1CbV2gm6bHvtn4WMza29MbYPu55MR OGYn6KVkxm8fGjVfpZjjK5TBspxwmpe1SfC8Ta7FPky6XF+rMG4uoq7TOWnCW7lPDDyz okrg== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=io85M3Hd Subject: [Buildroot] [PATCH v2 1/1] package/micropython: add support for manifest.py in the configuration X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Packham , "Yann E . MORIN" , Abilio Marques Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Micropython can embed packages an modules as frozen bytecode. What code gets built this way can be defined by means of a "manifest.py" file. This commit exposes the variable FROZEN_MANIFEST to Buildroot users through a new variable called BR2_PACKAGE_MICROPYTHON_MANIFEST. Please check Micropython's documentation for more information: https://docs.micropython.org/en/latest/reference/manifest.html We only support freezing of modules from micropython-lib. Freezing arbitrary modules would require some handling of absoulte paths, and a guarantee that the files be available before micropython is built, which is considered a bit too complex; an interested party can provide such support in the future. Signed-off-by: Abilio Marques --- package/micropython/Config.in | 17 +++++++++++++++++ package/micropython/micropython.mk | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/package/micropython/Config.in b/package/micropython/Config.in index 26a00baab0..6b99cfd2ff 100644 --- a/package/micropython/Config.in +++ b/package/micropython/Config.in @@ -17,6 +17,23 @@ config BR2_PACKAGE_MICROPYTHON_LIB help Core Python libraries ported to MicroPython. +config BR2_PACKAGE_MICROPYTHON_MANIFEST + string "Path to a manifest.py file" + help + MicroPython allows Python code to be “frozen” as bytecode + into its binary, as an alternative to loading code from + the filesystem. + + A list of "frozen" modules can be provided using a "manifest.py" + file. You can set the path to such file using this variable. + + See MicroPython's documentation for more information on how to + use the file. + + Note: in Buildroot, only modules provided with micropython-lib + can be frozen with a manifest; freezing arbitrary files is + currently not supported. + endif # BR2_PACKAGE_MICROPYTHON comment "micropython needs a toolchain w/ threads, dynamic library" diff --git a/package/micropython/micropython.mk b/package/micropython/micropython.mk index 125a0edcfb..5a2c136547 100644 --- a/package/micropython/micropython.mk +++ b/package/micropython/micropython.mk @@ -43,6 +43,11 @@ else MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=0 endif +ifneq ($(BR2_PACKAGE_MICROPYTHON_MANIFEST),"") +MICROPYTHON_MAKE_OPTS += \ + FROZEN_MANIFEST=$(BR2_PACKAGE_MICROPYTHON_MANIFEST) +endif + define MICROPYTHON_BUILD_CMDS $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/mpy-cross $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \