From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6994374891774410752 X-Received: by 2002:a05:651c:245:: with SMTP id x5mr15051579ljn.92.1628504809030; Mon, 09 Aug 2021 03:26:49 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a19:691e:: with SMTP id e30ls1347270lfc.0.gmail; Mon, 09 Aug 2021 03:26:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRpnIp+GgTwIC1qqfaOG6Ly2SkfSwrZVUZpgD/TgCmMhYKRahuMDKPVwMfKjFtQeipeY+5 X-Received: by 2002:a05:6512:5cb:: with SMTP id o11mr17345826lfo.359.1628504808030; Mon, 09 Aug 2021 03:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628504808; cv=none; d=google.com; s=arc-20160816; b=UQAAYyTQEeTyjB/Xv6Sx9Fn0KBUifyTU20sJ4TxI6A4PNjlqb4lE9dUQ9J1aehy9G/ OSb0SwdilXKw3Sz+eh2myox/IyQWB+qde3grVWQ+l9A9xNZW9GNghIc7c4T2/2ro2zdL c6/Jw5AFvavTXzi8kZqV63g5YGeqA7ffEgqKUq4M4aXfGt7JJ21wVgA+hArC4MAPJkxE Aj4NRXhFoyWKD2JUiH3Y5Fc1hTGAivnFnv5i9pgBN4YHAnlDhWNOOOots/QcF+CrGvBE QxP7g8N/hY/VctXgwDPOO7xkjMtgs6ZTV9QtvLVaTdAdviBbX6XwBELCHwtUJlIkMFPR BoJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ST0TL22R+H/7YRNVI81LVmW0WBu/mlJqlOKW1M/XQjw=; b=OWlIaqzasiizTWQduWKDcHVnNqOmQXxaeu+AS8cdL4tA0UoH1LTd7LU0f14ZjBSo1r lKHgwRevQPin2O0PZPvlmXtNesanYDMvkgbN+HUOF28vcmWx56zEtOg5DHGY0xK4/9wd jNytV+5nhaGUSLHKxlAvuSkE1M8wDVW2Y8m2d8kahDzGPtNQKkWtJMzjN3imU9UEs80q CXIU5CP+jVTZDnE0pwL1U3ZmrVrEnQAf5bOOZYt6VCwNjyqE+bN+emTdPP6xEbODM7yj T31YXagE/ILpMIqdaG5A4A2Sw2tFf9cmBaHB8ceATyjFTImkngG+pRx5OjDB+WTcUYnI fv0w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of quirin.gylstorff@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=Quirin.Gylstorff@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id u7si804039ljg.3.2021.08.09.03.26.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Aug 2021 03:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of quirin.gylstorff@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of quirin.gylstorff@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=Quirin.Gylstorff@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 179AQlVw008474 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 9 Aug 2021 12:26:47 +0200 Received: from md2dvrtc.fritz.box ([167.87.4.54]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 179AQkTq007138; Mon, 9 Aug 2021 12:26:46 +0200 From: "Q. Gylstorff" To: isar-users@googlegroups.com Cc: Quirin Gylstorff Subject: [RFC PATCH 1/2] Add build-config-snippet class Date: Mon, 9 Aug 2021 12:26:44 +0200 Message-Id: <20210809102645.17414-2-Quirin.Gylstorff@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210809102645.17414-1-Quirin.Gylstorff@siemens.com> References: <20210809102645.17414-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: C7bEZSvPoOZt From: Quirin Gylstorff This class allows to generate a build configuration with debian dependencies. Signed-off-by: Quirin Gylstorff --- doc/technical_overview.md | 33 ++++++++ meta/classes/build-config-snippets.bbclass | 87 ++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 meta/classes/build-config-snippets.bbclass diff --git a/doc/technical_overview.md b/doc/technical_overview.md index bbd22b6..fdfec0c 100644 --- a/doc/technical_overview.md +++ b/doc/technical_overview.md @@ -308,3 +308,36 @@ to the end. Only template files from the `WORKDIR` are accepted. Either specify relative paths based on the recipes `WORKDIR` or absolute paths containing the `WORKDIR` in the `TEMPLATE_FILES` variable. + +### 3.9.2 Build configuration snippets + +A build configuration can be created from multiple snippets files. + +This system is implemented in the `build-config-snippets.bbclass` and defines +a `do_generate_build_configuration` task. + +To define a feature set, the user has to define the following +variable to an empty string: + +``` +BUILD_FEATURE_featurename = "" +``` + +Then, required additions to the variables can be defined: + +``` +BUILD_FEATURE_featurename[BUILD_CONFIG_SNIPPETS] = "file://snippet-file-name.snippet" +BUILD_FEATURE_featurename[SRC_URI] = "file://required-file.txt" +BUILD_FEATURE_featurename[DEPENDS] = "deb-pkg1 deb-pkg2 deb-pkg3" +BUILD_FEATURE_featurename[DEBIAN_DEPENDS] = "deb-pkg1" +BUILD_FEATURE_featurename[DEBIAN_BUILD_DEPENDS] = "deb-pkg1,deb-pkg2,deb-pkg3" +``` + +The `BUILD_CONFIG_SNIPPETS` flag gives a list of URI entries, where only +file:// is supported. These snippets are appended to the BUILD_CONFIG file. + +Features can depend on other features via the following mechanism: + +``` +BUILD_FEATURE_DEPS[feature1] = "feature2" +``` diff --git a/meta/classes/build-config-snippets.bbclass b/meta/classes/build-config-snippets.bbclass new file mode 100644 index 0000000..1d1054d --- /dev/null +++ b/meta/classes/build-config-snippets.bbclass @@ -0,0 +1,87 @@ +# This software is a part of ISAR. +# Copyright (C) 2021 Siemens AG +# +# SPDX-License-Identifier: MIT + + +BUILD_CONFIG_SNIPPETS = "" + +# The following function defines the build config snippet system +# with automatich debian dependency injection +# +# To define a feature set, the user has to define the following +# variable to an empty string: +# +# BUILD_FEATURE_featurename = "" +# +# Then, required additions to the variables can be defined: +# +# BUILD_FEATURE_featurename[BUILD_CONFIG_SNIPPETS] = "file://snippet-file-name.snippet" +# BUILD_FEATURE_featurename[SRC_URI] = "file://required-file.txt" +# BUILD_FEATURE_featurename[DEPENDS] = "deb-pkg1 deb-pkg2 deb-pkg3" +# BUILD_FEATURE_featurename[DEBIAN_DEPENDS] = "deb-pkg1" +# BUILD_FEATURE_featurename[DEBIAN_BUILD_DEPENDS] = "deb-pkg1,deb-pkg2,deb-pkg3" + +# The 'BUILD_CONFIG_SNIPPETS' flag gives a list of URI entries, where only +# file:// is supported. These snippets are appended to the BUILD_CONFIG file. +# +# Features can depend on other features via the following mechanism: +# +# BUILD_FEATURE_DEPS[feature1] = "feature2" + +KOMMA_SEPERATED_ELEMENTS ?= "DEBIAN_BUILD_DEPENDS DEBIAN_DEPENDS" + +python () { + requested_features = d.getVar("BUILD_FEATURES", True) or "" + + features = set(requested_features.split()) + old_features = set() + feature_deps = d.getVarFlags("BUILD_FEATURE_DEPS") or {} + while old_features != features: + diff_features = old_features.symmetric_difference(features) + old_features = features.copy() + for i in diff_features: + features.update(feature_deps.get(i, "").split()) + + for f in sorted(features): + bb.debug(2, "Feature: " + f) + varname = "BUILD_FEATURE_" + f + dummyvar = d.getVar(varname, False) + if dummyvar == None: + bb.error("Feature var " + f + " must be defined with needed flags.") + else: + feature_flags = d.getVarFlags(varname) + for feature_varname in sorted(feature_flags): + if feature_flags.get(feature_varname, "") != "": + sep = " " + + # Required to add BUILD_CONFIG_SNIPPETS to SRC_URI here, + # because 'SRC_URI += "${BUILD_CONFIG_SNIPPETS}"' would + # conflict with SRC_APT feature. + if feature_varname == "BUILD_CONFIG_SNIPPETS": + d.appendVar('SRC_URI', + " " + feature_flags[feature_varname].strip()) + + # BUILD_DEP_DEPENDS and DEBIAN_DEPENDS is ',' separated + # Only add ',' if there is already something there + if feature_varname in (d.getVar("KOMMA_SEPERATED_ELEMENTS", True) or "").split(): + sep = "," if d.getVar(feature_varname) else "" + + d.appendVar(feature_varname, + sep + feature_flags[feature_varname].strip()) +} + +# BUILD_CONFIG must be a predefined bitbake variable and the corresponding file +# must exist in the WORKDIR. +# The resulting generated config is the same file suffixed with ".gen" + +do_generate_build_configuration() { + GENCONFIG="${WORKDIR}/${BUILD_CONFIG}".gen + rm -f "$GENCONFIG" + cp "${WORKDIR}/${BUILD_CONFIG}" "$GENCONFIG" + for CONFIG_SNIPPET in $(echo "${BUILD_CONFIG_SNIPPETS}" | sed 's#file://##g') + do + cat ${WORKDIR}/$CONFIG_SNIPPET >> "$GENCONFIG" + done +} +addtask generate_build_configuration before do_prepare_build after do_patch -- 2.20.1