Re: [cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-14 Thread Ben Boeckel
On Fri, Oct 03, 2014 at 20:00:00 +0200, Sylvain Joubert wrote:
 Unlike the rerun target which is manually added by the Ninja generator,
 the install and package targets are handled in a generic way by the 
 utility target generator.
 
 Thus, handling these targets is not as straightforward as rerun.
 I'll keep digging a bit, maybe I can find a way to do it. ;-)

It should be possible to set a property on the target(s) when they are
created. Though…looking at the docs, it seems that there's no generic
JOB_POOL property for custom targets. When that property is implemented,
setting 'console' for these targets for Ninja should be simple enough.

--Ben
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-03 Thread Brad King
On 10/02/2014 06:08 PM, Matthew Woehlke wrote:
 I haven't tried it yet, but I've been wanting this feature; thanks for
 the patch!

I tried the patch and it works well.  When ninja reruns CMake one can
now see the output immediately.

 Please see also
 http://public.kitware.com/Bug/view.php?id=14915 which it sounds like
 this (partly) fixes; you may want to reference that in your patch or
 vice versa.

I've applied the patch here and added the issue reference:

 Ninja: Use 'console' pool for CMake re-run if possible (#14915)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f32a241

 (The partly is that the request is also for the 'install' target to
 use the console pool; not sure if you did that, want to tackle that,
 etc., but in any case this is a step in the right direction.)

I'll leave that to a follow-up patch if anyone wants to do it.

Thanks,
-Brad
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-03 Thread Matthew Woehlke
On 2014-10-03 08:56, Brad King wrote:
 On 10/02/2014 06:08 PM, Matthew Woehlke wrote:
 Please see also
 http://public.kitware.com/Bug/view.php?id=14915 which it sounds like
 this (partly) fixes; you may want to reference that in your patch or
 vice versa.
 
 I've applied the patch here and added the issue reference:
 
  Ninja: Use 'console' pool for CMake re-run if possible (#14915)
  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f32a241
 
 (The partly is that the request is also for the 'install' target to
 use the console pool; not sure if you did that, want to tackle that,
 etc., but in any case this is a step in the right direction.)
 
 I'll leave that to a follow-up patch if anyone wants to do it.

I was sort-of hoping / encouraging that Sylvain might be interested :-).
Anyway, thanks!

(Re-running CMake is the more important task, I think, as that's known
to take minutes in some cases... install, while also an obvious
candidate for such treatment, I believe tends to be quicker, so it less
important.)

-- 
Matthew

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-03 Thread Sylvain Joubert

Le 03/10/2014 17:41, Matthew Woehlke a écrit :

On 2014-10-03 08:56, Brad King wrote:

I'll leave that to a follow-up patch if anyone wants to do it.


I was sort-of hoping / encouraging that Sylvain might be interested :-).



I quickly checked if it is possible.

Unlike the rerun target which is manually added by the Ninja generator,
the install and package targets are handled in a generic way by the 
utility target generator.


Thus, handling these targets is not as straightforward as rerun.
I'll keep digging a bit, maybe I can find a way to do it. ;-)


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-03 Thread Matthew Woehlke
On 2014-10-03 14:00, Sylvain Joubert wrote:
 Le 03/10/2014 17:41, Matthew Woehlke a écrit :
 On 2014-10-03 08:56, Brad King wrote:
 I'll leave that to a follow-up patch if anyone wants to do it.

 I was sort-of hoping / encouraging that Sylvain might be interested :-).
 
 I quickly checked if it is possible.
 
 Unlike the rerun target which is manually added by the Ninja generator,
 the install and package targets are handled in a generic way by the
 utility target generator.
 
 Thus, handling these targets is not as straightforward as rerun.
 I'll keep digging a bit, maybe I can find a way to do it. ;-)

Many thanks, Sylvain. Don't worry if it's going to be a pain; I was
thinking since you were in there anyway it might be easier for you. It's
certainly much appreciated if you want to tackle this, but no worries if
you don't.

Thanks again for the re-run CMake patch!

-- 
Matthew

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

[cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-02 Thread Sylvain Joubert

Hi,

Since Ninja 1.5, a pre-defined pool 'console' can be used for non
buffered output.
See
http://martine.github.io/ninja/manual.html#_the_literal_console_literal_pool

This patch specifies that special pool for the build.ninja build block
if the Ninja version used is at least 1.5

This is useful for projects that have a long and verbose CMake run step.
The idea is to get the output as soon as possible.

It also adds the generation of the minimal required version of Ninja in
the build.ninja file. The default version is 1.3 since the generator
uses features from that version. If the Ninja version is 1.5 or greater,
then the generator will use the 'console' pool and the build.ninja file
requires at least Ninja 1.5

Regards,
Sylvain
From 5735b36d3c8780da06c9a91b461946a814d4592b Mon Sep 17 00:00:00 2001
From: Sylvain Joubert joubert...@gmail.com
Date: Thu, 2 Oct 2014 21:21:05 +0200
Subject: [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

The pre-defined 'console' pool is a non-buffered pool that runs
with a depth of 1
CMake re-run cannot be run concurrently and it will eventually
output something
A non-buffered pool allows to get it as soon as possible

Also, generate the minimal required version of Ninja in the build file
---
 Source/cmGlobalNinjaGenerator.cxx | 23 ++-
 Source/cmGlobalNinjaGenerator.h   |  3 ++-
 Source/cmLocalNinjaGenerator.cxx  | 25 +
 Source/cmLocalNinjaGenerator.h|  1 +
 4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 50e1abb..543ecdb 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1128,6 +1128,16 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream os)
   implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()),
  implicitDeps.end());
 
+  cmNinjaVars variables;
+  // Use 'console' pool to get non buffered output of the CMake re-run call
+  // Available since Ninja 1.5
+  if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
+   ninjaVersion().c_str(),
+   1.5) == false)
+{
+variables[pool] = console;
+}
+
   this-WriteBuild(os,
Re-run CMake if any of its inputs changed.,
RERUN_CMAKE,
@@ -1135,7 +1145,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream os)
/*explicitDeps=*/ cmNinjaDeps(),
implicitDeps,
/*orderOnlyDeps=*/ cmNinjaDeps(),
-   /*variables=*/ cmNinjaVars());
+   variables);
 
   this-WritePhonyBuild(os,
 A missing CMake input file is not an error.,
@@ -1154,6 +1164,17 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
   return ninja;
 }
 
+std::string cmGlobalNinjaGenerator::ninjaVersion() const
+{
+  std::string version;
+  std::string command = ninjaCmd() +  --version;
+  cmSystemTools::RunSingleCommand(command.c_str(),
+  version, 0, 0,
+  cmSystemTools::OUTPUT_NONE);
+
+  return version;
+}
+
 void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream os)
 {
   WriteRule(*this-RulesFileStream,
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 4cbbeea..a192eee 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -297,6 +297,8 @@ public:
   void AddTargetAlias(const std::string alias, cmTarget* target);
 
   virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
+  std::string ninjaVersion() const;
 protected:
 
   /// Overloaded methods. @see cmGlobalGenerator::Generate()
@@ -335,7 +337,6 @@ private:
 
   std::string ninjaCmd() const;
 
-
   /// The file containing the build statement. (the relation ship of the
   /// compilation DAG).
   cmGeneratedFileStream* BuildFileStream;
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 2ac8363..5522e0d 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -189,6 +189,7 @@ void cmLocalNinjaGenerator::WriteBuildFileTop()
 {
   // For the build file.
   this-WriteProjectHeader(this-GetBuildFileStream());
+  this-WriteNinjaRequiredVersion(this-GetBuildFileStream());
   this-WriteNinjaFilesInclusion(this-GetBuildFileStream());
 
   // For the rule file.
@@ -205,6 +206,30 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream os)
   cmGlobalNinjaGenerator::WriteDivider(os);
 }
 
+void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream os)
+{
+  // Default required version
+  // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
+  std::string requiredVersion = 1.3;
+
+  // Ninja generator uses the 'console' pool if available (= 1.5)
+  std::string usedVersion = 

Re: [cmake-developers] [PATCH] Ninja: Use 'console' pool for CMake re-run if possible

2014-10-02 Thread Matthew Woehlke
On 2014-10-02 17:34, Sylvain Joubert wrote:
 Since Ninja 1.5, a pre-defined pool 'console' can be used for non
 buffered output.
 See
 http://martine.github.io/ninja/manual.html#_the_literal_console_literal_pool
 
 This patch specifies that special pool for the build.ninja build block
 if the Ninja version used is at least 1.5

I haven't tried it yet, but I've been wanting this feature; thanks for
the patch! Please see also
http://public.kitware.com/Bug/view.php?id=14915 which it sounds like
this (partly) fixes; you may want to reference that in your patch or
vice versa.

(The partly is that the request is also for the 'install' target to
use the console pool; not sure if you did that, want to tackle that,
etc., but in any case this is a step in the right direction.)

-- 
Matthew

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers