From patchwork Mon Jun 9 09:56:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 64546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ECAEC677C4 for ; Mon, 9 Jun 2025 09:56:35 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.web11.55632.1749462984485000124 for ; Mon, 09 Jun 2025 02:56:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=M8OgYlh+; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.47, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a531fcaa05so1434423f8f.3 for ; Mon, 09 Jun 2025 02:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1749462982; x=1750067782; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=pzTACMX/iZ1OQhYoyItMxq0mbZStFqW9BD/w/MCWMCk=; b=M8OgYlh+8QzRlMqYN6per9SLwhjl0qj+nBSWAy+pTk47yBRNsc30WnZrI6KnnaH9/l HJaHu1AQBXs8YWh2JRcj9OpQAZx3+hhfNmT5fLUFDeI1FZ74qyHWZzIfrlM60DD5D2I0 64JoGAyIEhYb6PK2np90M+ICupsqzg4u8vfQc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749462982; x=1750067782; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pzTACMX/iZ1OQhYoyItMxq0mbZStFqW9BD/w/MCWMCk=; b=Hpg4EgdnZYgj4hT6BC2wD+pbKaPleA7ttRouo9XzKImz/5fxzmssh+ebny1av0uUMj 2QJb0xFLZubMtdd1QSmgSSKuUOPAZWzKo3ADkIH55+giesaA+5R1CzvmXimu+JBvkv20 d993Cf2Hy6yIvtdXnxamthBMJEZQl2zJIDr8tNcj5CLBcafRkWvWP/Mg7XNjhpmym66r ay0zunUz6LkcXUEJqhdqQTdfh96GKR+lhsm4BcM6z/Cvk7i1ge6hwV6Ouyp4nk7gvqHX jOvt+kUlVaTOzaKmNxk/L+igiqM0/VE7qz1bD23qO+42h1HxIi+Q0s6og+ef72U/AUn8 dkmQ== X-Gm-Message-State: AOJu0YxYgOA9uVQV8iLU5NTVnaQfgGKCG/VhLkCO2q++1sfp6ZBbTiwt gVRYcdvI+hZzpE0Q0KqDTx3vRBNie93A8In0dn+abNKgiXKtQI46gY36saREEbvc6tc3mEa2QId WeJGeovg= X-Gm-Gg: ASbGncv/TZlx7LuMMiZk/XPGmfrQeMS3GaWRd/6fbOR3Ydnnr0Fwacmeft+/ZkiMSRI 0Eyu6e5oVvdHGLv4bdGRufVV+qy2BQvPbwJQBNNRkSflY09BlybzHsO62WfXbvp3nOHPGGkBFEV tpWZ4QUJfsDFXKTCR1mIPWXZWnW+/mkLsdtTVKXb4E+QxT7BWAgB2N1XxsBC5Wl4JXR7HtBHXnR sczPDf81fcmDupMn309tVNl3gSy03OWNefYvczlaZlubr8NrUTVpi4jXMy0j0ucn3IUcetcwT6S KIioKcPKZ1GEohnhVcE4/UlyA5sPKWp1hLwjG6GoafVB8FkwnQaVx5yXspEwEfMfM3P3I9bEfEK 6sFMQtdvVbjn1W2E= X-Google-Smtp-Source: AGHT+IGE9bXN0W8+NbzEDqm2eaEInH5XXKt7k5z4jQ3jdLzGHp+BdB02LNRtHZ2DZD356y5VtyaZAA== X-Received: by 2002:a05:6000:1acc:b0:3a5:27ba:47a8 with SMTP id ffacd0b85a97d-3a531ceb9a9mr10792039f8f.52.1749462982453; Mon, 09 Jun 2025 02:56:22 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:fa9f:168d:c475:ba8f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a532435fbfsm9229759f8f.64.2025.06.09.02.56.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 02:56:21 -0700 (PDT) From: Richard Purdie To: bitbake-devel@lists.openembedded.org Subject: [PATCH 1/3] ast: Change deferred inherits to happen per recipe Date: Mon, 9 Jun 2025 10:56:19 +0100 Message-ID: <20250609095621.937299-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 09 Jun 2025 09:56:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17689 Currently deferred inherits get processed once for all class extensions as a minor speed optimisation. Unfortunately this limits our options for being able to report deferred classes to our code. There are two challenges with using our deferred classes in OE at present. One is that PACKAGECONFIG values don't work well with class overrides like class-native if there are deferred classes based on PACKAGECONFIG, such as python support. The second is that toolchain selection is proving problematic to implement due to interactions between the toolchain deferred inherit, the class extensions and class overrides being very late. By changing deferred inherits to be recipe extension specific, we open the way to generate events and "peek" at where things will end up, allowing the class overrides to be set earlier. The class extension code is updated to use a deferred inherit for the class extension inheriting so that it is still inherited last. Signed-off-by: Richard Purdie --- lib/bb/parse/ast.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py index 290ed45048..f9998798d8 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -471,6 +471,14 @@ def finalize(fn, d, variant = None): if d.getVar("_FAILPARSINGERRORHANDLED", False) == True: raise bb.BBHandledException() + while True: + inherits = d.getVar('__BBDEFINHERITS', False) or [] + if not inherits: + break + inherit, filename, lineno = inherits.pop(0) + d.setVar('__BBDEFINHERITS', inherits) + bb.parse.BBHandler.inherit(inherit, filename, lineno, d, deferred=True) + for var in d.getVar('__BBHANDLERS', False) or []: # try to add the handler handlerfn = d.getVarFlag(var, "filename", False) @@ -525,14 +533,6 @@ def multi_finalize(fn, d): logger.debug("Appending .bbappend file %s to %s", append, fn) bb.parse.BBHandler.handle(append, d, True) - while True: - inherits = d.getVar('__BBDEFINHERITS', False) or [] - if not inherits: - break - inherit, filename, lineno = inherits.pop(0) - d.setVar('__BBDEFINHERITS', inherits) - bb.parse.BBHandler.inherit(inherit, filename, lineno, d, deferred=True) - onlyfinalise = d.getVar("__ONLYFINALISE", False) safe_d = d @@ -568,7 +568,9 @@ def multi_finalize(fn, d): d.setVar("BBEXTENDVARIANT", variantmap[name]) else: d.setVar("PN", "%s-%s" % (pn, name)) - bb.parse.BBHandler.inherit(extendedmap[name], fn, 0, d) + inherits = d.getVar('__BBDEFINHERITS', False) or [] + inherits.append((extendedmap[name], fn, 0)) + d.setVar('__BBDEFINHERITS', inherits) safe_d.setVar("BBCLASSEXTEND", extended) _create_variants(datastores, extendedmap.keys(), extendfunc, onlyfinalise) From patchwork Mon Jun 9 09:56:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 64545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27EABC5B552 for ; Mon, 9 Jun 2025 09:56:35 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web10.56055.1749462985631372932 for ; Mon, 09 Jun 2025 02:56:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=gY1x1hBJ; spf=pass (domain: linuxfoundation.org, ip: 209.85.221.42, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3a4f72cba73so3506201f8f.1 for ; Mon, 09 Jun 2025 02:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1749462984; x=1750067784; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3YxWBXIM2ad/j3C75NGLbtQKhx9jBZAiUcVQ2JlWbTk=; b=gY1x1hBJnNDJue1Ee+9L28P31qdUaqXF+Az7W0JoK/eGXI8lRXR1ubpZqFFVn9V6SF EcUpR3VFp4YQhmhh5UDwbOMYLcMlOH+NiT3dGvw6YZJEobFKVmIOZdPFBOo6V1xJX5Vo nFTbfNZwmLzQMNlq7KMA6tdjpv23jctBAJURw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749462984; x=1750067784; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3YxWBXIM2ad/j3C75NGLbtQKhx9jBZAiUcVQ2JlWbTk=; b=v6pm9ybZ4GpDw7j1GkZp6BgAKJ3Jk9xERNSpKqHWprqRRAo1Blr+l4huuSVviKLKi5 x4gS/G4KedqNzJcyHt8wXQDDF+Y91CePlsPazdGNhVVTtCNY0PLVlpuCN1vwr97XUYrF tNM2VbNIZfqQULPjaAt3uoPHZneRLgOdBr8PgaoF8SCwEcpe7M+DNwlZ7ORp6bvpejHl jRfWEkK0M3455++LqRHy9JO87dB/ZZpNMeAlGth7j3Y0yCOERYSkDcTTKF0exPOgr7lX +ffpyWZDUZvQHD0xNpq5vwW3NzDO4ciQAEgX9Zmz6sCf2AbmKycdEWsysmU5ucpW8oVf /TJQ== X-Gm-Message-State: AOJu0YxuxDDYhQscRaLgC+CYWBs31RAj7nO6hUyieW6eB2MttvXmLC8Y paf8VGm7GppwsQVCD3FkK09H4VAqvcYrDGc9oCQpw8mZGXPqo7ztviEy7wuVtmavCon6EKk4ADV E2E0KZ6M= X-Gm-Gg: ASbGncs7wcg0hKZN9Q0CFMP/2WV67SGmZq5P+2fdh5TcIPBzF9doKalslgqAKHPaTKI kud7WXdBaFxeAK6GXWCBo4D9fzZT2AYYw2zBoUB5zXj72ZB9c3kbpUGjtDYLXmViH/IerCpvsw6 ROciXXmJBlsAuHfW/9ZrSk8O2OMFWsiBNtMsT6I+dy/J8zWnXfe71yekUhu0N3bYl4Ru5N8EIOC JExjMDatP+pRPZaXWMMy/3UZYfvkxkUWcVSgc+Ij/vSQwDJLP+vPciFlh49WydGUTToqkkMw2Pr 3mpGh8Uz+JRqIWctCb3fwY4SMwEqu+aFoFM7ah6Y2q4Tua/QFrf5pcff0+FxdBy711eqKslM9fM rk183ft6GYkRRMfA= X-Google-Smtp-Source: AGHT+IHq/YxyXxCF3VdPEl1g3vCNaYIg0XvQkrnCOHu77T6CCsAZ98kK5lLhATxMQE+A7dD9ydo8Uw== X-Received: by 2002:a05:6000:2285:b0:3a4:f7ae:77c9 with SMTP id ffacd0b85a97d-3a531315562mr10413045f8f.5.1749462983606; Mon, 09 Jun 2025 02:56:23 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:fa9f:168d:c475:ba8f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a532435fbfsm9229759f8f.64.2025.06.09.02.56.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 02:56:22 -0700 (PDT) From: Richard Purdie To: bitbake-devel@lists.openembedded.org Subject: [PATCH 2/3] event: Add event for deferred inherits Date: Mon, 9 Jun 2025 10:56:20 +0100 Message-ID: <20250609095621.937299-2-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250609095621.937299-1-richard.purdie@linuxfoundation.org> References: <20250609095621.937299-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 09 Jun 2025 09:56:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17690 Now that deferred inherits are extension specific, we can pass this list to an event, which our metadata can use to set class overrides earlier (as an example). There are limitations to this, the list of classes is unexpanded and recursive classes are not visible. There isn't much that can be done about this, the ones we are interested in would usually be visible at the top level (such as class extensions). Signed-off-by: Richard Purdie --- lib/bb/event.py | 10 ++++++++++ lib/bb/parse/ast.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/lib/bb/event.py b/lib/bb/event.py index a12adbc937..b29f0a5568 100644 --- a/lib/bb/event.py +++ b/lib/bb/event.py @@ -431,6 +431,16 @@ class RecipeEvent(Event): self.fn = fn Event.__init__(self) +class RecipePreDeferredInherits(RecipeEvent): + """ + Called before deferred inherits are processed so code can snoop on class extensions for example + Limitations: It won't see inherits of inherited classes and the data is unexpanded + """ + def __init__(self, fn, inherits): + self.fn = fn + self.inherits = inherits + Event.__init__(self) + class RecipePreFinalise(RecipeEvent): """ Recipe Parsing Complete but not yet finalised""" diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py index f9998798d8..5a086b4e95 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -471,6 +471,9 @@ def finalize(fn, d, variant = None): if d.getVar("_FAILPARSINGERRORHANDLED", False) == True: raise bb.BBHandledException() + inherits = [x[0] for x in (d.getVar('__BBDEFINHERITS', False) or [('',)])] + bb.event.fire(bb.event.RecipePreDeferredInherits(fn, inherits), d) + while True: inherits = d.getVar('__BBDEFINHERITS', False) or [] if not inherits: From patchwork Mon Jun 9 09:56:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 64544 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27088C61CE8 for ; Mon, 9 Jun 2025 09:56:35 +0000 (UTC) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.web10.56056.1749462986657984931 for ; Mon, 09 Jun 2025 02:56:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=LKNMwniK; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.48, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-442f4a3a4d6so22252555e9.0 for ; Mon, 09 Jun 2025 02:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1749462985; x=1750067785; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4nWaGF3ClwltPPtHrC81v+QGhShEWGyDfxk+Cr83H7M=; b=LKNMwniKgEEHKUJJrb8eoREjkfA6GD5VW5TzTeJPbbFQYVvTBtXCbuNn4dFDsqp4VY v9IXDRaQeg5VfvfEv3GkEjYgWR96jF1MTJBayX/yox6A7m2Eg5hi3f/1IOoeNphr5ZIP jlU+mA8JPe8rWrGws3Vv72jFEJNjJSAicnJN4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749462985; x=1750067785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4nWaGF3ClwltPPtHrC81v+QGhShEWGyDfxk+Cr83H7M=; b=MB7X4nP06FqqVrEguyNjmTK1c+dMBZaD+rJbkeVU+5Lkn4AG34clJNacdilubroyjq N4tkX5Gh56YD4iqzgTk0W+OReLn1/x4Rz16/YdAaWtF0irbPXyl3+t1oQmldyfNn4bQ4 oqEbPSVbuXNqW3tu85zMisCSDIS/MRRFnxoJZ9omP51Zx2aI9/kL2CpzDGShAYvSrMGc 55RzAUZgnJ2G5mhTrDyG2wSFQc+Mslkr2HxwiFcplr6JCQ8BkRXL2HSxlA1DlBPjRQ36 T7ukWepkDkdOKmHDmgaglS0lFSOBO1ltYq3NXjSEfVSPsy/Zs8QtYN60KK7qQV/CiWGw STaQ== X-Gm-Message-State: AOJu0Yxq+lvwyK0J7sbYTB2XAIQwpUJoMP1Rm2zgWmgTuARZTazMnN7X DEns7bJomAVKyJnJmW6B7hES8fycslw0+FkzIEWOe2DEAKEWWsriqTgrW0dlAeF1VYewU/E/ynM MbqHKt5E= X-Gm-Gg: ASbGncuaDiQ0ZPdrjGum1UOtfCDUJGZTCuxmhB0ZCU3zu1/AsCZPkrpN2mvWpcmWGao LEGEZu00x2OB/iIRhIElgP1bSpNHoBvaDZT6+BZCe40OdIVkOx6urYQhdwXHx2BiyzhsORg9eFm We0fDD1viH9orRxx8lkxpWlmknhKL1vNKOZ32eNcotkyf0UxiyhXBlVBRs7hlgJz5on5UcA4kKk mOu93XEQONvBoWbqd2Q7p4jEeYnfHGO1vNp1nlhop98gNAjWeIJ4TU3OE/eGksTCtH1V2nzVfV/ biHU2+ydN3fqCNRTnnQhsXNwnKxAUsDJVkobKjMerWX/wsqY+D6a2lpJWvpyeNK/VHkPDnY6Wve srPZKV2Htxss7fJs= X-Google-Smtp-Source: AGHT+IE8oTuTinGbQnjeQ/NbjJtB1xYxsAESruS+h44b+jaMyxENwxj69viDE6pPIrqQ2kqwOritXw== X-Received: by 2002:a05:600c:1f90:b0:43c:f3e1:a729 with SMTP id 5b1f17b1804b1-451f88ad8c5mr146269535e9.12.1749462984673; Mon, 09 Jun 2025 02:56:24 -0700 (PDT) Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:fa9f:168d:c475:ba8f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a532435fbfsm9229759f8f.64.2025.06.09.02.56.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jun 2025 02:56:23 -0700 (PDT) From: Richard Purdie To: bitbake-devel@lists.openembedded.org Subject: [PATCH 3/3] ast/BBHandler: Add support for BB_DEFER_BBCLASSES Date: Mon, 9 Jun 2025 10:56:21 +0100 Message-ID: <20250609095621.937299-3-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250609095621.937299-1-richard.purdie@linuxfoundation.org> References: <20250609095621.937299-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 09 Jun 2025 09:56:35 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17691 Add support for automatically promoting class inherits to deferred inherits by listing them in the BB_DEFER_BBCLASSES variable. Signed-off-by: Richard Purdie --- lib/bb/parse/ast.py | 8 ++------ lib/bb/parse/parse_py/BBHandler.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py index 5a086b4e95..ea1096f2de 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -340,9 +340,7 @@ class InheritDeferredNode(AstNode): self.inherit = (classes, filename, lineno) def eval(self, data): - inherits = data.getVar('__BBDEFINHERITS', False) or [] - inherits.append(self.inherit) - data.setVar('__BBDEFINHERITS', inherits) + bb.parse.BBHandler.inherit_defer(*self.inherit, data) class AddFragmentsNode(AstNode): def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable): @@ -571,9 +569,7 @@ def multi_finalize(fn, d): d.setVar("BBEXTENDVARIANT", variantmap[name]) else: d.setVar("PN", "%s-%s" % (pn, name)) - inherits = d.getVar('__BBDEFINHERITS', False) or [] - inherits.append((extendedmap[name], fn, 0)) - d.setVar('__BBDEFINHERITS', inherits) + bb.parse.BBHandler.inherit_defer(extendedmap[name], fn, 0, d) safe_d.setVar("BBCLASSEXTEND", extended) _create_variants(datastores, extendedmap.keys(), extendfunc, onlyfinalise) diff --git a/lib/bb/parse/parse_py/BBHandler.py b/lib/bb/parse/parse_py/BBHandler.py index 4bdb11994f..008fec2308 100644 --- a/lib/bb/parse/parse_py/BBHandler.py +++ b/lib/bb/parse/parse_py/BBHandler.py @@ -42,12 +42,22 @@ def supports(fn, d): """Return True if fn has a supported extension""" return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] +def inherit_defer(expression, fn, lineno, d): + inherit = (expression, fn, lineno) + inherits = d.getVar('__BBDEFINHERITS', False) or [] + inherits.append(inherit) + d.setVar('__BBDEFINHERITS', inherits) + def inherit(files, fn, lineno, d, deferred=False): __inherit_cache = d.getVar('__inherit_cache', False) or [] #if "${" in files and not deferred: # bb.warn("%s:%s has non deferred conditional inherit" % (fn, lineno)) files = d.expand(files).split() for file in files: + defer = (d.getVar("BB_DEFER_BBCLASSES") or "").split() + if not deferred and file in defer: + inherit_defer(file, fn, lineno, d) + continue classtype = d.getVar("__bbclasstype", False) origfile = file for t in ["classes-" + classtype, "classes"]: