package/ninja: enforce Python3 on the host
diff mbox series

Message ID 20190222203756.8795-1-joerg.krause@embedded.rocks
State Changes Requested
Headers show
Series
  • package/ninja: enforce Python3 on the host
Related show

Commit Message

Jörg Krause Feb. 22, 2019, 8:37 p.m. UTC
The current logic selects Python3 for the host only if Python3 is
selected for the target, otherwise it selects Python2.

As Meson, the only package infrastructure using ninja, needs Python3, it is
desirable to also depend on Python3 on the host for the ninja host
package.

Otherwise, if no Python interpreter is selected for the target, both
Python2 and Python3 are build for the host, which is time consuming
without any benefit.

For example when building libmpdclient (and all its target and host
dependencies) the actual elapsed time for is reduced from around 286s to 207s
as reported by `time -p make clean all`.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
 package/ninja/ninja.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Adam Duskett Feb. 28, 2019, 2:30 p.m. UTC | #1
All:


Tested by: Adam Duskett <Aduskett@gmail.com>

On Fri, Feb 22, 2019 at 3:38 PM Jörg Krause <joerg.krause@embedded.rocks> wrote:
>
> The current logic selects Python3 for the host only if Python3 is
> selected for the target, otherwise it selects Python2.
>
> As Meson, the only package infrastructure using ninja, needs Python3, it is
> desirable to also depend on Python3 on the host for the ninja host
> package.
>
> Otherwise, if no Python interpreter is selected for the target, both
> Python2 and Python3 are build for the host, which is time consuming
> without any benefit.
>
> For example when building libmpdclient (and all its target and host
> dependencies) the actual elapsed time for is reduced from around 286s to 207s
> as reported by `time -p make clean all`.
>
> Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
> ---
>  package/ninja/ninja.mk | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/package/ninja/ninja.mk b/package/ninja/ninja.mk
> index 9d6f30e9fe..42dc3cb567 100644
> --- a/package/ninja/ninja.mk
> +++ b/package/ninja/ninja.mk
> @@ -9,7 +9,10 @@ NINJA_SITE = $(call github,ninja-build,ninja,$(NINJA_VERSION))
>  NINJA_LICENSE = Apache-2.0
>  NINJA_LICENSE_FILES = COPYING
>
> -HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
> +# Enforce Python3 on the host, to prevent building Python2 and Python3 when
> +# using packages using the Meson infrastructure and not having any Python
> +# interperter selected for the target.
> +HOST_NINJA_NEEDS_HOST_PYTHON = python3
>
>  define HOST_NINJA_BUILD_CMDS
>         (cd $(@D); ./configure.py --bootstrap)
> --
> 2.20.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni May 7, 2019, 9:07 p.m. UTC | #2
Hello,

On Fri, 22 Feb 2019 21:37:56 +0100
Jörg Krause <joerg.krause@embedded.rocks> wrote:

> The current logic selects Python3 for the host only if Python3 is
> selected for the target, otherwise it selects Python2.
> 
> As Meson, the only package infrastructure using ninja, needs Python3, it is
> desirable to also depend on Python3 on the host for the ninja host
> package.
> 
> Otherwise, if no Python interpreter is selected for the target, both
> Python2 and Python3 are build for the host, which is time consuming
> without any benefit.
> 
> For example when building libmpdclient (and all its target and host
> dependencies) the actual elapsed time for is reduced from around 286s to 207s
> as reported by `time -p make clean all`.
> 
> Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>

I think this is a good idea, but...

> -HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
> +# Enforce Python3 on the host, to prevent building Python2 and Python3 when
> +# using packages using the Meson infrastructure and not having any Python
> +# interperter selected for the target.
> +HOST_NINJA_NEEDS_HOST_PYTHON = python3

This definitely cannot be the right change: <pkg>_NEEDS_HOST_PYTHON
only makes sense for packages using the python-package infrastructure,
but Ninja is using the generic-package infrastructure. So basically,
the line you have added does not do anything at all, and it only works
by chance because host-python3 was already built before host-ninja by
some other package.

I think the right change is to just do:

HOST_NINJA_DEPENDENCIES = host-python3

Best regards,

Thomas

Patch
diff mbox series

diff --git a/package/ninja/ninja.mk b/package/ninja/ninja.mk
index 9d6f30e9fe..42dc3cb567 100644
--- a/package/ninja/ninja.mk
+++ b/package/ninja/ninja.mk
@@ -9,7 +9,10 @@  NINJA_SITE = $(call github,ninja-build,ninja,$(NINJA_VERSION))
 NINJA_LICENSE = Apache-2.0
 NINJA_LICENSE_FILES = COPYING
 
-HOST_NINJA_DEPENDENCIES = $(if $(BR2_PACKAGE_PYTHON3),host-python3,host-python)
+# Enforce Python3 on the host, to prevent building Python2 and Python3 when
+# using packages using the Meson infrastructure and not having any Python
+# interperter selected for the target.
+HOST_NINJA_NEEDS_HOST_PYTHON = python3
 
 define HOST_NINJA_BUILD_CMDS
 	(cd $(@D); ./configure.py --bootstrap)