Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Perez de Castro <aperez@igalia.com>
To: buildroot@buildroot.org
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>,
	Pierre Ducroquet <pinaraf@pinaraf.info>,
	Samuel Martin <s.martin49@gmail.com>,
	Peter Seiderer <ps.report@gmx.net>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [Buildroot] [PATCH RFC v2 7/7] package/racehound: add patch to support building with ninja
Date: Fri, 21 Jan 2022 17:42:35 +0200	[thread overview]
Message-ID: <20220121154235.798255-8-aperez@igalia.com> (raw)
In-Reply-To: <20220121154235.798255-1-aperez@igalia.com>

SSIA.

Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>
Upstream-Status: https://github.com/euspectre/racehound/pull/6
---
Changes v1 -> v2:
  - Patch added to call into Kbuild with plain make.
---
 ...pport-non-Make-generators-e.g.-Ninja.patch | 112 ++++++++++++++++++
 1 file changed, 112 insertions(+)
 create mode 100644 package/racehound/0002-CMake-Support-non-Make-generators-e.g.-Ninja.patch

diff --git a/package/racehound/0002-CMake-Support-non-Make-generators-e.g.-Ninja.patch b/package/racehound/0002-CMake-Support-non-Make-generators-e.g.-Ninja.patch
new file mode 100644
index 0000000000..7f90fb8c69
--- /dev/null
+++ b/package/racehound/0002-CMake-Support-non-Make-generators-e.g.-Ninja.patch
@@ -0,0 +1,112 @@
+From f8d266b017fd76e2de9d20e0bb3951a5338075d1 Mon Sep 17 00:00:00 2001
+From: Adrian Perez de Castro <aperez@igalia.com>
+Date: Fri, 14 Jan 2022 14:33:21 +0200
+Subject: [PATCH] CMake: Support non-Make generators, e.g. Ninja
+
+---
+ cmake/modules/FindKbuild.cmake             | 15 +++++++++++++--
+ cmake/modules/kbuild_system.cmake          |  4 ++--
+ cmake/modules/kmodule_files/CMakeLists.txt | 11 +++++++++--
+ core/tests/common_target/CMakeLists.txt    |  2 +-
+ 4 files changed, 25 insertions(+), 7 deletions(-)
+
+diff --git a/cmake/modules/FindKbuild.cmake b/cmake/modules/FindKbuild.cmake
+index b79d140..2ba0a78 100644
+--- a/cmake/modules/FindKbuild.cmake
++++ b/cmake/modules/FindKbuild.cmake
+@@ -5,6 +5,7 @@
+ #     (often /lib/modules/${KBUILD_VERSION_STRING}/build)
+ # KBUILD_INCLUDE_DIR - not used
+ # KBUILD_FOUND - TRUE if everything is correct, FALSE otherwise
++# KBUILD_MAKE_COMMAND - Command to run for Make invocations.
+ 
+ if (NOT KBUILD_VERSION_STRING)
+ 	set(KBUILD_VERSION_STRING ${CMAKE_SYSTEM_VERSION} CACHE STRING 
+@@ -18,8 +19,18 @@ endif (NOT KBUILD_BUILD_DIR)
+ 
+ set(KBUILD_INCLUDE_DIRS "NOT USED")
+ 
+-# Note: only KBUILD_BUILD_DIR variable is really used in the project.
+-# Other variables defined only for FindModule architecture of CMake.
++# Only makefiles have $(MAKE) defined, in other cases invoke make directly.
++if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
++    set(KBUILD_MAKE_COMMAND $\(MAKE\))
++else ()
++    find_program(KBUILD_MAKE_COMMAND make REQUIRED)
++    set(KBUILD_MAKE_COMMAND ${KBUILD_MAKE_COMMAND} CC=${CMAKE_C_COMPILER} CFLAGS=${CMAKE_C_FLAGS})
++endif ()
++
++
++# Note: only KBUILD_BUILD_DIR and KBUILD_MAKE_COMMAND variables are really
++# used in the project. Other variables defined only for FindModule
++# architecture of CMake.
+ 
+ # Handle the QUIETLY and REQUIRED arguments and set KBUILD_FOUND to TRUE if 
+ # all listed variables are TRUE
+diff --git a/cmake/modules/kbuild_system.cmake b/cmake/modules/kbuild_system.cmake
+index e28ef33..e4e33df 100644
+--- a/cmake/modules/kbuild_system.cmake
++++ b/cmake/modules/kbuild_system.cmake
+@@ -262,13 +262,13 @@ function(kbuild_add_module name)
+ 					> "${_dir}.${_name}.o.cmd")
+ 		endforeach(shipped_source_noext_abs ${shipped_source_noext_abs})
+ 	endif(shipped_sources_noext_abs)
+-	
++
+ 	# The rule to create module
+ 	add_custom_command(
+ 		OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.ko ${symvers_file}
+ 		${cmd_create_command}
+ 		${symvers_command}
+-		COMMAND $(MAKE) -C ${KBUILD_BUILD_DIR}
++		COMMAND ${KBUILD_MAKE_COMMAND} -C ${KBUILD_BUILD_DIR}
+ 			M=${CMAKE_CURRENT_BINARY_DIR} modules
+ 		DEPENDS ${depend_files}
+ 	)
+diff --git a/cmake/modules/kmodule_files/CMakeLists.txt b/cmake/modules/kmodule_files/CMakeLists.txt
+index 1147cc5..6115153 100644
+--- a/cmake/modules/kmodule_files/CMakeLists.txt
++++ b/cmake/modules/kmodule_files/CMakeLists.txt
+@@ -5,7 +5,7 @@ if (NOT KERNELDIR)
+ 	set(KERNELDIR /lib/modules/${KBUILD_VERSION_STRING}/build)
+ endif (NOT KERNELDIR)
+ 
+-set(PWD $\(shell pwd\))
++set(PWD $$\(pwd\))
+ 
+ project(kmodule_try_compile)
+ # Create rule for produce file from another file via copiing
+@@ -27,9 +27,16 @@ if(COPY_FILE)
+ 	copy_file("${COPY_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/try_compile.ko")
+ endif(COPY_FILE)
+ 
++# Only makefiles have $(MAKE) defined, in other cases invoke make directly.
++if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
++    set(KBUILD_MAKE_COMMAND $\(MAKE\))
++else ()
++    find_program(KBUILD_MAKE_COMMAND make REQUIRED)
++endif ()
++
+ # Rule to produce try_compile.ko from try_compile.c
+ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/try_compile.ko"
+-	COMMAND $(MAKE) -C ${KERNELDIR} M=${PWD} modules
++	COMMAND ${KBUILD_MAKE_COMMAND} -C ${KERNELDIR} M=${PWD} modules
+ 					DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/try_compile.c")
+ 
+ # Kbuild system cannot work with out-of-source build,
+diff --git a/core/tests/common_target/CMakeLists.txt b/core/tests/common_target/CMakeLists.txt
+index cf257ad..fe48e68 100644
+--- a/core/tests/common_target/CMakeLists.txt
++++ b/core/tests/common_target/CMakeLists.txt
+@@ -17,7 +17,7 @@ add_custom_target("common_target_module"
+ 
+ add_custom_command(
+ 	OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${KMODULE_NAME}.ko"
+-	COMMAND $(MAKE) -f module.makefile
++	COMMAND ${KBUILD_MAKE_COMMAND} -f module.makefile
+ 	DEPENDS 
+ 		"${CMAKE_CURRENT_BINARY_DIR}/cfake.c"
+ 		"${CMAKE_CURRENT_BINARY_DIR}/cfake.h"
+-- 
+2.34.1
+
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2022-01-21 15:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 13:26 [Buildroot] [PATCH RFC 0/2] Use Ninja as build tool for CMake-based packages Adrian Perez de Castro
2022-01-12 13:26 ` [Buildroot] [PATCH RFC 1/2] package/ninja: do not require cmake Adrian Perez de Castro
2022-01-21 15:42   ` [Buildroot] [PATCH RFC v2 0/7] Use Ninja as build tool for CMake-based packages Adrian Perez de Castro
2022-01-21 15:42     ` [Buildroot] [PATCH RFC v2 1/7] package/ninja: do not require cmake Adrian Perez de Castro
2022-01-21 15:42     ` [Buildroot] [PATCH RFC v2 2/7] package/pkg-cmake.mk: use ninja instead of make Adrian Perez de Castro
2022-07-24 13:16       ` Arnout Vandecappelle
2022-01-21 15:42     ` [Buildroot] [PATCH RFC v2 3/7] package/musepack: use MUSEPACK_NINJA_OPTS Adrian Perez de Castro
2022-07-24 13:18       ` Arnout Vandecappelle
2022-01-21 15:42     ` [Buildroot] [PATCH RFC v2 4/7] package/mariadb: use HOST_MARIADB_NINJA_OPTS Adrian Perez de Castro
2022-01-21 15:42     ` [Buildroot] [PATCH RFC v2 5/7] package/kf5/kf5-extra-cmake-modules: do not build documentation Adrian Perez de Castro
2022-01-21 15:42     ` [Buildroot] [PATCH RFC v2 6/7] package/libcorrect: avoid multiple rules for same target Adrian Perez de Castro
2022-01-21 15:42     ` Adrian Perez de Castro [this message]
2022-01-21 15:53     ` [Buildroot] [PATCH RFC v2 0/7] Use Ninja as build tool for CMake-based packages Adrian Perez de Castro
2022-01-12 13:26 ` [Buildroot] [PATCH RFC 2/2] package/pkg-cmake.mk: use ninja instead of make Adrian Perez de Castro
2022-01-12 14:35   ` Thomas Petazzoni
2022-01-12 16:51     ` Adrian Perez de Castro
2022-01-12 14:36 ` [Buildroot] [PATCH RFC 0/2] Use Ninja as build tool for CMake-based packages Thomas Petazzoni
2022-01-12 15:09   ` Adrian Perez de Castro
2022-01-12 16:02     ` Thomas Petazzoni
2022-01-12 16:05 ` Alexander Dahl
2022-01-12 16:47   ` Adrian Perez de Castro
2022-01-12 18:55     ` Arnout Vandecappelle
2022-01-13 15:49       ` Thomas Petazzoni
2022-05-05 21:35         ` James Hilliard
2022-07-24 13:05 ` Arnout Vandecappelle

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=20220121154235.798255-8-aperez@igalia.com \
    --to=aperez@igalia.com \
    --cc=buildroot@buildroot.org \
    --cc=eric.le.bihan.dev@free.fr \
    --cc=pinaraf@pinaraf.info \
    --cc=ps.report@gmx.net \
    --cc=s.martin49@gmail.com \
    --cc=thomas.petazzoni@bootlin.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