public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Alexander Smirnov <asmirnov@ilbers.de>
To: isar-users@googlegroups.com
Cc: Alexander Smirnov <asmirnov@ilbers.de>
Subject: [PATCH v3 6/7] cross-compilation: Introduce variable switch
Date: Tue, 17 Jul 2018 16:18:10 +0300	[thread overview]
Message-ID: <20180717131811.14239-7-asmirnov@ilbers.de> (raw)
In-Reply-To: <20180717131811.14239-1-asmirnov@ilbers.de>

Add variable to switch from native to cross compilation.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 meta-isar/conf/local.conf.sample            |  5 +++++
 meta/classes/dpkg-base.bbclass              | 19 ++++++++++++++++---
 meta/classes/dpkg-raw.bbclass               |  1 -
 meta/classes/dpkg.bbclass                   |  4 +---
 meta/recipes-kernel/linux-module/module.inc |  7 +++++++
 meta/recipes-kernel/linux/linux-custom.inc  |  2 ++
 6 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 16ef488..27b43d1 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -156,3 +156,8 @@ CONF_VERSION = "1"
 #
 # The default list of extra packages to be installed.
 IMAGE_INSTALL = "example-hello example-raw example-module"
+
+#
+# Enable cross-compilation support
+# NOTE: this works only for stretch-armhf and stretch-amd64 targets for now.
+ISAR_CROSS_COMPILE ?= "0"
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 3234234..674c0b5 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -1,6 +1,22 @@
 # This software is a part of ISAR.
 # Copyright (C) 2017 Siemens AG
 
+ISAR_CROSS_COMPILE ??= "0"
+
+# Add dependency from the correct buildchroot: host or target
+python __anonymous() {
+    mode = d.getVar('ISAR_CROSS_COMPILE', True)
+    if mode == "0":
+        dep = "buildchroot-target:do_build"
+        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', True)
+    else:
+        dep = "buildchroot-host:do_build"
+        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', True)
+
+    d.setVarFlag('do_build', 'depends', dep)
+    d.setVar('BUILDCHROOT_DIR', rootfs)
+}
+
 do_adjust_git() {
     if [ -f ${S}/.git/objects/info/alternates ]; then
         sed -i ${S}/.git/objects/info/alternates \
@@ -14,9 +30,6 @@ do_adjust_git[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
 inherit patch
 addtask patch after do_adjust_git before do_build
 
-# Add dependency from buildchroot creation
-do_build[depends] = "buildchroot-target:do_build"
-
 # Add dependency between Isar recipes
 DEPENDS ?= ""
 do_build[deptask] = "do_deploy_deb"
diff --git a/meta/classes/dpkg-raw.bbclass b/meta/classes/dpkg-raw.bbclass
index 2f23eb7..28233ac 100644
--- a/meta/classes/dpkg-raw.bbclass
+++ b/meta/classes/dpkg-raw.bbclass
@@ -7,7 +7,6 @@ DEBIAN_DEPENDS ?= ""
 MAINTAINER ?= "FIXME Unknown maintainer"
 
 D = "${WORKDIR}/image/"
-BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
 
 # Populate folder that will be picked up as package
 do_install() {
diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 563b63c..ab70645 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -3,10 +3,8 @@
 
 inherit dpkg-base
 
-BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
-
 # Build package from sources using build script
 dpkg_runbuild() {
     E="${@ bb.utils.export_proxies(d)}"
-    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS}
+    sudo -E chroot ${BUILDCHROOT_DIR} /build.sh ${PP}/${PPS} ${DISTRO_ARCH}
 }
diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index 3075f44..aeccfba 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -15,6 +15,13 @@ SRC_URI += "file://debian/"
 
 AUTOLOAD ?= "0"
 
+# Cross-compilation is not supported for default Debian kernels.
+# For example, package with kernel headers for ARM:
+#   linux-headers-armmp
+# has hard dependencies from linux-compiler-gcc-4.8-arm, what
+# conflicts with the host binaries.
+ISAR_CROSS_COMPILE := "0"
+
 inherit dpkg
 
 dpkg_runbuild_prepend() {
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 1176b25..f7641ef 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -20,6 +20,8 @@ python() {
                              'linux-headers-' + kernel)
 }
 
+ISAR_CROSS_COMPILE = "0"
+
 inherit dpkg-base
 
 SRC_URI += "file://build-kernel.sh"
-- 
2.1.4


  parent reply	other threads:[~2018-07-17 13:18 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 13:18 [PATCH v3 0/7] Isar cross-compilation support Alexander Smirnov
2018-07-17 13:18 ` [PATCH v3 1/7] isar-bootstrap: Update routine to determine host arch Alexander Smirnov
2018-07-17 13:18 ` [PATCH v3 2/7] buildchroot: Split generic part Alexander Smirnov
2018-07-17 13:18 ` [PATCH v3 3/7] buildchroot: Add host buildchroot Alexander Smirnov
2018-07-17 19:48   ` Jan Kiszka
2018-07-17 13:18 ` [PATCH v3 4/7] isar-bootstrap-helper: Add target architecture for dpkg Alexander Smirnov
2018-07-17 13:18 ` [PATCH v3 5/7] build.sh: Add additional parameter Alexander Smirnov
2018-07-17 13:18 ` Alexander Smirnov [this message]
2018-07-17 13:18 ` [PATCH v3 7/7] linux: Add cross-compilation support Alexander Smirnov
2018-07-17 13:38 ` [PATCH v3 0/7] Isar " Jan Kiszka
2018-07-17 14:40   ` Jan Kiszka
2018-07-17 15:06     ` Alexander Smirnov
2018-07-17 15:18       ` Alexander Smirnov
2018-07-17 15:24         ` Jan Kiszka
2018-07-17 15:29           ` Alexander Smirnov
2018-07-17 15:41   ` Alexander Smirnov
2018-07-17 19:45     ` Jan Kiszka
2018-07-17 20:48       ` Alexander Smirnov
2018-07-18  7:06         ` Jan Kiszka
2018-07-18  8:19           ` Jan Kiszka
2018-07-18  8:37             ` Jan Kiszka
2018-07-18 18:52           ` Alexander Smirnov
2018-07-18 19:00             ` Jan Kiszka
2018-07-19 20:59               ` Alexander Smirnov
2018-07-20  5:56                 ` Jan Kiszka
2018-07-22 20:15                   ` Alexander Smirnov
2018-07-22 20:32                     ` Alexander Smirnov
2018-07-22 21:54                       ` Jan Kiszka
2018-07-23  6:55                         ` Jan Kiszka
2018-07-24  8:21                         ` Jan Kiszka
2018-07-22 21:40                     ` 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=20180717131811.14239-7-asmirnov@ilbers.de \
    --to=asmirnov@ilbers.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