[PATCH 2/4] chipsec: Provide CHIPSEC's driver with the build architecture

Ricardo Neri <[email protected]> Wed, 15 Mar 2017 12:42:01 -0700
Newsgroups dev.linux.lists.oe-chipsec
Message-ID <[email protected]>
--===============0902517831656917101==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

When cross-building for 32-bit x86, we need to make aware the CHIPSEC
driver that we intend to build the 32-bit version via the ARCH variable.
A quick fix is to define an environment varialble, CHIPSEC_ARCH, that
can be retrieved from setup.py and passed to the driver Makefile.

We no longer the EXTRA_OEMAKE variable as we rely on Python setuptools
to build CHIPSEC.

Cc: Megha Dey <[email protected]>
Signed-off-by: Ricardo Neri <[email protected]>
---
 ...ve-CPU-architecture-to-the-driver-s-Makef.patch | 40 ++++++++++++++++++=
++++
 meta-luv/recipes-core/chipsec/chipsec_git.bb       |  3 +-
 2 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-giv=
e-CPU-architecture-to-the-driver-s-Makef.patch

diff --git a/meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-give-CPU-a=
rchitecture-to-the-driver-s-Makef.patch b/meta-luv/recipes-core/chipsec/chi=
psec/0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch
new file mode 100644
index 0000000..4fe7f10
--- /dev/null
+++ b/meta-luv/recipes-core/chipsec/chipsec/0001-setup.py-give-CPU-architec=
ture-to-the-driver-s-Makef.patch
@@ -0,0 +1,40 @@
+From 4df09a6f905c9e1cf8c65235ff309ac7bebcc6eb Mon Sep 17 00:00:00 2001
+From: Ricardo Neri <[email protected]>
+Date: Wed, 15 Mar 2017 12:00:57 -0700
+Subject: [PATCH] setup.py: give CPU architecture to the driver's Makefile
+
+Driver is built differently depending on whether it is built for
+32-bit or 64-bit x86 archs. Thus, we need to pass the desired
+CPU architecture. This can be done by reading the environment
+variable CHIPSEC_ARCH. This could be done more nicely by adding
+a new variable to build_ext, though.
+
+Signed-off-by: Ricardo Neri <[email protected]>
+---
+ setup.py | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index fb0da43..e09eaa6 100644
+--- a/setup.py
++++ b/setup.py
+@@ -68,13 +68,14 @@ class build_ext(_build_ext):
+         self.set_undefined_options("build", ("skip_driver", "skip_driver"=
))
+ =

+     def _build_linux_driver(self):
+-        log.info("building the linux driver")
++        arch =3D os.environ["CHIPSEC_ARCH"]
++        log.info("building the linux driver for arch " + arch)
+         build_driver =3D os.path.join(self.real_build_lib, "drivers", "li=
nux")
+         ko_ext =3D os.path.join(build_driver, "chipsec.ko")
+         # We copy the drivers extension to the build directory.
+         self.copy_tree(os.path.join("drivers", "linux"), build_driver)
+         # Run the makefile there.
+-        subprocess.check_output(["make", "-C", build_driver])
++        subprocess.check_output(["make", "ARCH=3D"+arch, "-C", build_driv=
er])
+         # And copy the resulting .ko to the right place.
+         # That is to the source directory if we are in "develop" mode,
+         # otherwise to the helper subdirectory in the build directory.
+-- =

+2.9.3
+
diff --git a/meta-luv/recipes-core/chipsec/chipsec_git.bb b/meta-luv/recipe=
s-core/chipsec/chipsec_git.bb
index 6c29231..1a209e7 100644
--- a/meta-luv/recipes-core/chipsec/chipsec_git.bb
+++ b/meta-luv/recipes-core/chipsec/chipsec_git.bb
@@ -11,6 +11,7 @@ SRC_URI =3D "git://github.com/chipsec/chipsec.git \
     file://chipsec file://luv-parser-chipsec \
     file://0001-chipsec-building-for-32-bit-systems.patch \
     file://0001-chipsec-do-not-ship-manual.patch \
+    file://0001-setup.py-give-CPU-architecture-to-the-driver-s-Makef.patch=
 \
     "
 =

 SRCREV=3D"2fbb7a4eeb3752998dfbcbdf771cd3f8ed1985ae"
@@ -48,7 +49,7 @@ def get_target_arch(d):
  else:
     raise bb.parse.SkipPackage("TARGET_ARCH %s not supported!" % target)
 =

-EXTRA_OEMAKE +=3D "ARCH=3D"${@get_target_arch(d)}""
+export CHIPSEC_ARCH =3D "${@get_target_arch(d)}"
 =

 DISTUTILS_INSTALL_ARGS =3D "--root=3D${D}${PYTHON_SITEPACKAGES_DIR} \
     --install-data=3D${D}/${datadir}"
-- =

2.9.3


--===============0902517831656917101==--