waf: cmake: do a clean configuration

We need to remove CMakeCache.txt, otherwise cached variables would remain the
old value when they are removed from cmake_vars parameter.

We use `os.remove()` instead of `Node.delete()` because the latter removes the
node instance from its parent's children list. That makes the node be ignored
when storing persistent information after the build, thus the node signature
wouldn't be saved with that approach, which would make waf always think that
the task should be executed.
This commit is contained in:
Gustavo Jose de Sousa 2016-02-22 14:20:27 +00:00 committed by Lucas De Marchi
parent eacf9d8a0e
commit 181b6f5c2e
1 changed files with 10 additions and 0 deletions

View File

@ -97,6 +97,7 @@ from waflib import Node, Task, Utils
from waflib.TaskGen import feature, taskgen_method
from collections import OrderedDict
import os
class cmake_configure_task(Task.Task):
vars = ['CMAKE_BLD_DIR']
@ -120,6 +121,15 @@ class cmake_configure_task(Task.Task):
def keyword(self):
return 'CMake Configure'
# Clean cmake configuration
cmake_configure_task._original_run = cmake_configure_task.run
def _cmake_configure_task_run(self):
cmakecache_path = self.outputs[0].abspath()
if os.path.exists(cmakecache_path):
os.remove(cmakecache_path)
self._original_run()
cmake_configure_task.run = _cmake_configure_task_run
class cmake_build_task(Task.Task):
run_str = '${CMAKE} --build ${CMAKE_BLD_DIR} --target ${CMAKE_TARGET}'