From patchwork Fri Jan 6 22:37:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Marie?= X-Patchwork-Id: 712203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3twKdR447Bz9vFl for ; Sat, 7 Jan 2017 09:55:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=openmailbox.org header.i=@openmailbox.org header.b="qR6iEY8x"; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=openmailbox.org header.i=@openmailbox.org header.b="jacBpnpk"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id F1BCA82051; Fri, 6 Jan 2017 22:55:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UAydTljS+wDg; Fri, 6 Jan 2017 22:55:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 2232082036; Fri, 6 Jan 2017 22:55:20 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 41C2A1C08E7 for ; Fri, 6 Jan 2017 22:55:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3E7A2822EA for ; Fri, 6 Jan 2017 22:55:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id di9muudKs5UX for ; Fri, 6 Jan 2017 22:55:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lb1.openmailbox.org (lb1.openmailbox.org [5.79.108.160]) by whitealder.osuosl.org (Postfix) with ESMTPS id E1BD18233F for ; Fri, 6 Jan 2017 22:55:17 +0000 (UTC) Received: by lb1.openmailbox.org (Postfix, from userid 20002) id 3C130503388; Fri, 6 Jan 2017 23:38:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1483742329; bh=1MpBVnt4gpYQawmjVFBwP8kVP5jMBxmdNIRrApTC49M=; h=From:To:Cc:Subject:Date:From; b=qR6iEY8xleE+OhfUoOg8rjcIVqVhFZNMkdWn2k0JXYJxhi+GOVDiye4c0W9XA6Kzp fXv6nMEPFKlUNJVHkfnfo13vA1UWdwGKs0y1RpwLHyQgOxaemABqUUZuRtiFiKk/IW GHS4zS7NBV/sSltSkYrf2rnvTVJXGWgmd7TjLo6A= From: =?UTF-8?q?C=C3=A9dric=20Marie?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1483742328; bh=1MpBVnt4gpYQawmjVFBwP8kVP5jMBxmdNIRrApTC49M=; h=From:To:Cc:Subject:Date:From; b=jacBpnpkagCNzGCyfpy6Ne1Uwz/HrN/oxl4J9Xgx5VmTGYzJx7P0EMlX1LkpBSHKq uVkgnvQd8SrkiaH1G9efpLB2HzeVASqpShLq4Chy2iVjWEsoia3Oni+g+1fT1Mjx/U 6z5CdRVP1Tccbw9a79mZ2d7wP5TvSgiMOE2ZsRWw= To: buildroot@buildroot.org Date: Fri, 6 Jan 2017 23:37:47 +0100 Message-Id: <20170106223748.2203-1-cedric.marie@openmailbox.org> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Cc: =?UTF-8?q?C=C3=A9dric=20Marie?= Subject: [Buildroot] [PATCH 1/2] Add BR2_CMAKE_USE_NINJA_BACKEND option X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" CMake provides several backends. The default one is Make, but Ninja is also supported. Ninja is a small build system with a focus on speed. If the new option BR2_CMAKE_USE_NINJA_BACKEND is enabled, CMake will use Ninja backend. In CMake package infrastructure, when this option is set: - Add host-ninja dependency - Add "-G Ninja" option in CMake configure step - Use ninja command instead of make ($(MAKE)) Most of make arguments are compatible with ninja command. But there are a few differences: - Environment variables such as DESTDIR cannot be given in arguments. Instead they must be set before the command (which is compatible with make) - CMake does not handle VERBOSE variable with Ninja backend. Instead, we must add -v option when VERBOSE is set. - install/fast target is specific to make backend. With ninja backend, install target must be used (and it will not try to compile as make backend does). Tested on following packages: cannelloni, graphite2, libcuefile, libubox, rabbitmq-c, ubus. Signed-off-by: Cédric Marie --- Config.in | 6 ++++++ package/pkg-cmake.mk | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Config.in b/Config.in index ccd777e..26ebcf6 100644 --- a/Config.in +++ b/Config.in @@ -656,6 +656,12 @@ config BR2_SHARED_STATIC_LIBS endchoice +config BR2_CMAKE_USE_NINJA_BACKEND + bool "Compile CMake packages with Ninja backend" + help + CMake provides several backends. The default one is Make, but + Ninja is also supported. Ninja is a small build system with a + focus on speed. config BR2_PACKAGE_OVERRIDE_FILE string "location of a package override file" diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk index 4e0e838..83bf79e 100644 --- a/package/pkg-cmake.mk +++ b/package/pkg-cmake.mk @@ -53,24 +53,35 @@ define inner-cmake-package $(2)_CONF_ENV ?= $(2)_CONF_OPTS ?= +$(2)_INSTALL_STAGING_ENV ?= DESTDIR=$$(STAGING_DIR) +$(2)_INSTALL_TARGET_ENV ?= DESTDIR=$$(TARGET_DIR) + +ifeq ($(BR2_CMAKE_USE_NINJA_BACKEND),y) +$(2)_MAKE ?= $$(HOST_DIR)/usr/bin/ninja +$(2)_MAKE_ENV ?= +$(2)_MAKE_OPTS ?= $(if $(VERBOSE),-v) +$(2)_INSTALL_OPTS ?= install +else $(2)_MAKE ?= $$(MAKE) $(2)_MAKE_ENV ?= $(2)_MAKE_OPTS ?= -$(2)_INSTALL_OPTS ?= install -$(2)_INSTALL_STAGING_OPTS ?= DESTDIR=$$(STAGING_DIR) install/fast -$(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install/fast +$(2)_INSTALL_OPTS ?= install/fast +endif $(2)_SRCDIR = $$($(2)_DIR)/$$($(2)_SUBDIR) $(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES - ifeq ($$($(3)_SUPPORTS_IN_SOURCE_BUILD),YES) $(2)_BUILDDIR = $$($(2)_SRCDIR) else $(2)_BUILDDIR = $$($(2)_SRCDIR)/buildroot-build endif +ifeq ($(BR2_CMAKE_USE_NINJA_BACKEND),y) +$(2)_CONF_OPTS += -G Ninja +endif + # # Configure step. Only define it if not already defined by the package # .mk file. And take care of the differences between host and target @@ -146,6 +157,9 @@ endif $(2)_DEPENDENCIES += host-pkgconf $(2)_DEPENDENCIES += $(BR2_CMAKE_HOST_DEPENDENCY) +ifeq ($(BR2_CMAKE_USE_NINJA_BACKEND),y) +$(2)_DEPENDENCIES += host-ninja +endif # # Build step. Only define it if not already defined by the package .mk @@ -179,7 +193,7 @@ endif # ifndef $(2)_INSTALL_STAGING_CMDS define $(2)_INSTALL_STAGING_CMDS - $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) $$($$(PKG)_INSTALL_STAGING_OPTS) -C $$($$(PKG)_BUILDDIR) + $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_INSTALL_STAGING_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) $$($$(PKG)_INSTALL_OPTS) -C $$($$(PKG)_BUILDDIR) endef endif @@ -189,7 +203,7 @@ endif # ifndef $(2)_INSTALL_TARGET_CMDS define $(2)_INSTALL_TARGET_CMDS - $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) $$($$(PKG)_INSTALL_TARGET_OPTS) -C $$($$(PKG)_BUILDDIR) + $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_INSTALL_TARGET_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) $$($$(PKG)_INSTALL_OPTS) -C $$($$(PKG)_BUILDDIR) endef endif