Clean and vacuum unused source nodes after reconfiguring; also don't add nodes for configure files.
Clean and vacuum unused source nodes after reconfiguring; also don't add nodes for configure files.
1.1 --- a/ambuild2/database.py Sun Feb 02 10:47:48 2014 -0800
1.2 +++ b/ambuild2/database.py Sun Feb 02 14:00:01 2014 -0800
1.3 @@ -674,6 +674,10 @@
1.4 if entry.type == nodetypes.Mkdir:
1.5 self.drop_entry(entry)
1.6
1.7 + def drop_source(self, output):
1.8 + assert output.type == nodetypes.Source
1.9 + self.drop_entry(output)
1.10 +
1.11 def drop_output(self, output):
1.12 assert output.type == nodetypes.Output or output.type == nodetypes.SharedOutput
1.13 util.rm_path(output.path)
1.14 @@ -708,6 +712,19 @@
1.15 entry = self.import_node(id, row)
1.16 aggregate(entry)
1.17
1.18 + def query_dead_sources(self, aggregate):
1.19 + query = """
1.20 + select id from nodes
1.21 + where type == '{0}'
1.22 + and id not in (select incoming from edges)
1.23 + and id not in (select incoming from dynamic_edges)
1.24 + and id not in (select incoming from weak_edges)
1.25 + """.format(nodetypes.Source)
1.26 +
1.27 + for row in self.cn.execute(query):
1.28 + entry = self.query_node(row[0])
1.29 + aggregate(entry)
1.30 +
1.31 def query_dead_shared_outputs(self, aggregate):
1.32 query = """
1.33 select id from nodes
1.34 @@ -737,6 +754,9 @@
1.35 self.cn.execute("update nodes set type = ? where id = ?", (kind, entry.id))
1.36 entry.type = kind
1.37
1.38 + def vacuum(self):
1.39 + self.cn.execute("vacuum")
1.40 +
1.41 def printGraph(self):
1.42 # Find all mkdir nodes.
1.43 query = "select path from nodes where type = 'mkd'"
2.1 --- a/ambuild2/frontend/amb2/gen.py Sun Feb 02 10:47:48 2014 -0800
2.2 +++ b/ambuild2/frontend/amb2/gen.py Sun Feb 02 14:00:01 2014 -0800
2.3 @@ -74,6 +74,7 @@
2.4 for group in self.old_groups_:
2.5 self.db.drop_group(group)
2.6
2.7 + self.db.query_dead_sources(lambda e: self.db.drop_source(e))
2.8 self.db.query_dead_shared_outputs(lambda e: self.db.drop_output(e))
2.9
2.10 class Node:
2.11 @@ -127,6 +128,7 @@
2.12 def postGenerate(self):
2.13 self.cleanup()
2.14 self.db.commit()
2.15 + self.db.vacuum()
2.16 if self.is_bootstrap:
2.17 self.saveVars()
2.18 self.db.close()
2.19 @@ -708,12 +710,10 @@
2.20 )
2.21
2.22 def addConfigureFile(self, context, path):
2.23 - source = self.parseInput(context, path)
2.24 - if source.type != nodetypes.Source:
2.25 - util.con_err(util.ConsoleRed, 'Configure file dependencies must be source paths.',
2.26 - util.ConsoleNormal)
2.27 - raise Exception('Configure file dependencies must be source paths')
2.28 + if not os.path.isabs(path):
2.29 + path = os.path.join(context.currentSourcePath, path)
2.30 + path = os.path.normpath(path)
2.31
2.32 - self.old_scripts_.discard(source.path)
2.33 - self.db.add_or_update_script(source.path)
2.34 + self.old_scripts_.discard(path)
2.35 + self.db.add_or_update_script(path)
2.36
3.1 --- a/ambuild2/task.py Sun Feb 02 10:47:48 2014 -0800
3.2 +++ b/ambuild2/task.py Sun Feb 02 14:00:01 2014 -0800
3.3 @@ -539,7 +539,10 @@
3.4 })
3.5
3.6 def run(self):
3.7 - self.cx.messagePump.pump()
3.8 + try:
3.9 + self.cx.messagePump.pump()
3.10 + except KeyboardInterrupt:
3.11 + self.terminateBuild()
3.12 for message in self.errors_:
3.13 self.spewResult(message)
3.14 return not self.build_failed