All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmake: refactor compile and install for easier re-use
@ 2018-02-23 14:50 André Draszik
  2018-02-23 20:32 ` Christopher Larson
  0 siblings, 1 reply; 3+ messages in thread
From: André Draszik @ 2018-02-23 14:50 UTC (permalink / raw)
  To: openembedded-core

From: André Draszik <andre.draszik@jci.com>

cmake_do_compile() and cmake_do_install() basically do the
same, except they use a different --target, and at the
moment this is copy/pasted code with a minor modification.

Other recipes which e.g. might want to support compilation
as part of ptest have to do the same. This is a bit
inconvenient.

By factoring out all of this into a common helper,
cmake_runcmake_build(), this is easily re-used. An
(imaginary) recipe can compile ptest support simply by
using
  cmake_runcmake_build --target buildtest-TESTS
(assuming such a build target exists).

Also, this now is very similar to oe_runmake().

Signed-off-by: André Draszik <andre.draszik@jci.com>
---
 meta/classes/cmake.bbclass | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index d60dad8d66..fcfd5dda4f 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -159,14 +159,17 @@ cmake_do_configure() {
 	  -Wno-dev
 }
 
+cmake_runcmake_build() {
+	bbnote ${DESTDIR:+DESTDIR=${DESTDIR} }VERBOSE=1 cmake --build '${B}' "$@" -- ${EXTRA_OECMAKE_BUILD}
+	eval ${DESTDIR:+DESTDIR=${DESTDIR} }VERBOSE=1 cmake --build '${B}' "$@" -- ${EXTRA_OECMAKE_BUILD}
+}
+
 cmake_do_compile()  {
-	bbnote VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
-	VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
+	cmake_runcmake_build --target ${OECMAKE_TARGET_COMPILE}
 }
 
 cmake_do_install() {
-	bbnote DESTDIR='${D}' cmake --build '${B}' --target ${OECMAKE_TARGET_INSTALL} -- ${EXTRA_OECMAKE_BUILD}
-	DESTDIR='${D}' cmake --build '${B}' --target ${OECMAKE_TARGET_INSTALL} -- ${EXTRA_OECMAKE_BUILD}
+	DESTDIR='${D}' cmake_runcmake_build --target ${OECMAKE_TARGET_INSTALL}
 }
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_generate_toolchain_file
-- 
2.16.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cmake: refactor compile and install for easier re-use
  2018-02-23 14:50 [PATCH] cmake: refactor compile and install for easier re-use André Draszik
@ 2018-02-23 20:32 ` Christopher Larson
  2018-02-23 22:31   ` André Draszik
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2018-02-23 20:32 UTC (permalink / raw)
  To: André Draszik; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

On Fri, Feb 23, 2018 at 7:50 AM, André Draszik <git@andred.net> wrote:

> From: André Draszik <andre.draszik@jci.com>
>
> cmake_do_compile() and cmake_do_install() basically do the
> same, except they use a different --target, and at the
> moment this is copy/pasted code with a minor modification.
>
> Other recipes which e.g. might want to support compilation
> as part of ptest have to do the same. This is a bit
> inconvenient.
>
> By factoring out all of this into a common helper,
> cmake_runcmake_build(), this is easily re-used. An
> (imaginary) recipe can compile ptest support simply by
> using
>   cmake_runcmake_build --target buildtest-TESTS
> (assuming such a build target exists).
>
> Also, this now is very similar to oe_runmake().
>

If it’s similar to oe_runmake, why the long overly verbose function name
for the new function? Is oe_runcmake not viable?
-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 1564 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cmake: refactor compile and install for easier re-use
  2018-02-23 20:32 ` Christopher Larson
@ 2018-02-23 22:31   ` André Draszik
  0 siblings, 0 replies; 3+ messages in thread
From: André Draszik @ 2018-02-23 22:31 UTC (permalink / raw)
  To: Christopher Larson; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 750 bytes --]

On 23 Feb 2018 20:32, "Christopher Larson" <kergoth@gmail.com> wrote:


On Fri, Feb 23, 2018 at 7:50 AM, André Draszik <git@andred.net> wrote:

> From: André Draszik <andre.draszik@jci.com>
>
> [...]
> Also, this now is very similar to oe_runmake().
>

If it’s similar to oe_runmake, why the long overly verbose function name
for the new function? Is oe_runcmake not viable?


I was contemplating that, but in the end thought no as I'd personally find
it confusing. This is not running cmake, in that cmake alone generates the
build system files (make files, ninja build, msvc solutions, etc). It is
running cmake --build to execute the actual build (make, ninja, etc), hence
the name.

I'm open for other thoughts...

A.

[-- Attachment #2: Type: text/html, Size: 1541 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-23 22:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 14:50 [PATCH] cmake: refactor compile and install for easier re-use André Draszik
2018-02-23 20:32 ` Christopher Larson
2018-02-23 22:31   ` André Draszik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.