public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: claudius.heine.ext@siemens.com
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [PATCH 1/2] meta/classes/base: extend sys.path with lib directory
Date: Wed, 14 Feb 2018 14:15:08 +0100	[thread overview]
Message-ID: <20180214131509.16361-2-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20180214131509.16361-1-claudius.heine.ext@siemens.com>

From: Claudius Heine <ch@denx.de>

Currently scripts and modules that are placed in the 'lib' directory of
layers are not available in the recipes.

This change adds the required code to the base.bbclass in order to have
those imports available.

This change contains code from:
http://git.openembedded.org/openembedded-core/tree/meta/classes/base.bbclass?id=4a4eff9b9e3c614ff41b17cbec359b72dcbd41bd

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/base.bbclass | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index ae84677..3334789 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -37,6 +37,30 @@ bbfatal() {
 	exit 1
 }
 
+# Derived from openembedded-core/meta/classes/base.bbclass
+ISAR_IMPORTS += "os sys time"
+
+def isar_imports(d):
+	import sys
+
+	bbpath = d.getVar("BBPATH").split(":")
+	sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
+
+	def inject(name, value):
+		"""Make a python object accessible from the metadata"""
+		if hasattr(bb.utils, "_context"):
+			bb.utils._context[name] = value
+		else:
+			__builtins__[name] = value
+
+	for toimport in d.getVar("ISAR_IMPORTS", True).split():
+		imported = __import__(toimport)
+		inject(toimport.split(".", 1)[0], imported)
+
+	return ""
+
+ISAR_IMPORTED := "${@isar_imports(d)}"
+
 # Derived from bitbake: bitbake/classes/base.bbclass
 addtask showdata
 do_showdata[nostamp] = "1"
-- 
2.15.1


  reply	other threads:[~2018-02-14 13:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 13:15 [PATCH 0/2] Consolidate multistrap configuration generation claudius.heine.ext
2018-02-14 13:15 ` claudius.heine.ext [this message]
2018-02-15  7:28   ` [PATCH 1/2] meta/classes/base: extend sys.path with lib directory Jan Kiszka
2018-02-14 13:15 ` [PATCH 2/2] centralize multistrap configuration generation claudius.heine.ext
2018-02-15  7:28   ` Jan Kiszka
2018-02-15  8:16     ` Claudius Heine
2018-02-15  8:50       ` Jan Kiszka
2018-02-15  9:34     ` Alexander Smirnov
2018-02-15 10:05       ` Claudius Heine
2018-02-15 10:15         ` Jan Kiszka
2018-02-15 10:29           ` Alexander Smirnov
2018-02-15 11:27           ` Baurzhan Ismagulov
2018-02-15 13:17             ` Claudius Heine
2018-02-15 13:18             ` Jan Kiszka
2018-02-15 11:42   ` Baurzhan Ismagulov
2018-02-15 12:08     ` Claudius Heine
2018-02-15 12:37       ` Alexander Smirnov
2018-02-15 13:20         ` Claudius Heine
2018-02-15 13:39           ` Alexander Smirnov
2018-02-16  9:31             ` Claudius Heine
2018-02-16 10:35               ` Alexander Smirnov
2018-02-16 11:35                 ` Jan Kiszka
2018-02-15 13:53           ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180214131509.16361-2-claudius.heine.ext@siemens.com \
    --to=claudius.heine.ext@siemens.com \
    --cc=ch@denx.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox