CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/ardupilotwaf/ap_persistent.py
Views: 1798
1
# Copyright (C) 2016 Intel Corporation. All rights reserved.
2
#
3
# This file is free software: you can redistribute it and/or modify it
4
# under the terms of the GNU General Public License as published by the
5
# Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# This file is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
# See the GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License along
14
# with this program. If not, see <http://www.gnu.org/licenses/>.
15
"""
16
Module that changes Waf to keep persistent information across clean operations
17
in for performance improvement.
18
"""
19
from waflib import Build, Task
20
21
Build.SAVED_ATTRS.append('ap_persistent_task_sigs')
22
Build.SAVED_ATTRS.append('ap_persistent_imp_sigs')
23
Build.SAVED_ATTRS.append('ap_persistent_node_deps')
24
25
_original_signature = Task.Task.signature
26
27
_original_sig_implicit_deps = Task.Task.sig_implicit_deps
28
if hasattr(_original_sig_implicit_deps, '__func__'):
29
_original_sig_implicit_deps = _original_sig_implicit_deps.__func__
30
31
def _signature(self):
32
s = _original_signature(self)
33
real_fn = self.sig_implicit_deps.__func__
34
if not self.scan or _original_sig_implicit_deps != real_fn:
35
return s
36
bld = self.generator.bld
37
bld.ap_persistent_imp_sigs[self.uid()] = bld.imp_sigs[self.uid()]
38
bld.ap_persistent_node_deps[self.uid()] = bld.node_deps[self.uid()]
39
return s
40
Task.Task.signature = _signature
41
42
class CleanContext(Build.CleanContext):
43
def clean(self):
44
if not self.options.clean_all_sigs:
45
saved_task_sigs = dict(self.ap_persistent_task_sigs)
46
saved_imp_sigs = dict(self.ap_persistent_imp_sigs)
47
saved_node_deps = dict(self.ap_persistent_node_deps)
48
49
super(CleanContext, self).clean()
50
51
if not self.options.clean_all_sigs:
52
self.task_sigs.update(saved_task_sigs)
53
self.ap_persistent_task_sigs.update(saved_task_sigs)
54
55
self.imp_sigs.update(saved_imp_sigs)
56
self.ap_persistent_imp_sigs.update(saved_imp_sigs)
57
58
self.node_deps.update(saved_node_deps)
59
self.ap_persistent_node_deps.update(saved_node_deps)
60
61