All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Barnett <ryanbarnett3@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v5 2/2] i2c-tools: add support to build python extension
Date: Sun,  5 Apr 2015 17:15:05 -0500	[thread overview]
Message-ID: <1428272105-27627-2-git-send-email-ryanbarnett3@gmail.com> (raw)
In-Reply-To: <1428272105-27627-1-git-send-email-ryanbarnett3@gmail.com>

Add a config option to build the python bindings for i2c-tools -
py-smbus. The steps for building the python bindings is the same as
the distutil steps that are a part of the python infrastructure.

Signed-off-by: Ryan Barnett <ryanbarnett3@gmail.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Baruch Siach <baruch@tkos.co.il>
CC: Yann E. MORIN <yann.morin.1998@free.fr>

---
Changes v4 -> v5:
 - Actually send v4 change :)

Changes v3 -> v4:
 - Move define of BASE_ENV under BR2_PACKAGE_PYTHON (Yann)

Changes v2 -> v3:
 - Removed Config.in entry (suggested by Baruch)
 - Moved install and build defines with the CMD block (suggested
   by Yann)

Changes v1 -> v2:
 - Fixed spelling in config entry
 - Utilize the python infrastructure variables for environment and
   build/install opts (suggested by Thomas P)
 - Only support python2.7 since this is not compatabile with python3
   (suggested by Baruch)
---
 package/i2c-tools/i2c-tools.mk | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/package/i2c-tools/i2c-tools.mk b/package/i2c-tools/i2c-tools.mk
index 0115e22..6c156ca 100644
--- a/package/i2c-tools/i2c-tools.mk
+++ b/package/i2c-tools/i2c-tools.mk
@@ -10,8 +10,34 @@ I2C_TOOLS_SITE = http://dl.lm-sensors.org/i2c-tools/releases
 I2C_TOOLS_LICENSE = GPLv2+, GPLv2 (py-smbus)
 I2C_TOOLS_LICENSE_FILES = COPYING
 
+# Build/install steps mirror the distutil python package type in the python package
+# infrastructure
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+I2C_TOOLS_DEPENDENCIES += python
+# BASE_ENV taken from PKG_PYTHON_DISTUTILS_ENV in package/pkg-python.mk
+I2C_TOOLS_PYTHON_BASE_ENV = \
+	$(PKG_PYTHON_DISTUTILS_ENV) \
+	CFLAGS="$(TARGET_CFLAGS) -I../include"
+
+define I2C_TOOLS_BUILD_PYSMBUS
+	(cd $(@D)/py-smbus;  \
+	$(I2C_TOOLS_PYTHON_BASE_ENV) \
+		$(HOST_DIR)/usr/bin/python setup.py build \
+		$(PKG_PYTHON_DISTUTILS_BUILD_OPTS))
+endef
+
+define I2C_TOOLS_INSTALL_PYSMBUS
+	(cd $(@D)/py-smbus; \
+	$(I2C_TOOLS_PYTHON_BASE_ENV) \
+		$(HOST_DIR)/usr/bin/python setup.py install \
+		$(PKG_PYTHON_DISTUTILS_INSTALL_TARGET_OPTS))
+endef
+
+endif # BR2_PACKAGE_PYTHON
+
 define I2C_TOOLS_BUILD_CMDS
 	$(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
+	$(I2C_TOOLS_BUILD_PYSMBUS)
 endef
 
 define I2C_TOOLS_INSTALL_TARGET_CMDS
@@ -19,6 +45,7 @@ define I2C_TOOLS_INSTALL_TARGET_CMDS
 	do \
 		$(INSTALL) -m 755 -D $(@D)/tools/$$i $(TARGET_DIR)/usr/bin/$$i; \
 	done
+	$(I2C_TOOLS_INSTALL_PYSMBUS)
 endef
 
 $(eval $(generic-package))
-- 
1.9.1

  reply	other threads:[~2015-04-05 22:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-05 22:15 [Buildroot] [PATCH v5 1/2] i2c-tools: add hash file Ryan Barnett
2015-04-05 22:15 ` Ryan Barnett [this message]
2015-04-06  9:03   ` [Buildroot] [PATCH v5 2/2] i2c-tools: add support to build python extension Thomas Petazzoni
2015-04-06  9:07     ` Yann E. MORIN
2015-04-09  6:32       ` Angelo Compagnucci
2015-04-09 13:11         ` Ryan Barnett
2015-04-09 20:26           ` Angelo Compagnucci
2015-04-06  9:03 ` [Buildroot] [PATCH v5 1/2] i2c-tools: add hash file Thomas Petazzoni

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=1428272105-27627-2-git-send-email-ryanbarnett3@gmail.com \
    --to=ryanbarnett3@gmail.com \
    --cc=buildroot@busybox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.