Bug 1635491 - Delete tup backend and `mach analyze` r=froydnj

It's not maintained and doesn't work as-is. If we want to revive it we can grab it from source control later, but in the meantime it's just confusing and it comes up in search results even though we never look for it.

Also delete `mach analyze` which depends on the existence of a Tup backend.

Differential Revision: https://phabricator.services.mozilla.com/D73911
This commit is contained in:
Ricky Stewart 2020-05-05 16:32:42 +00:00
Родитель af08f79b29
Коммит cdac3a2e15
5 изменённых файлов: 1 добавлений и 1598 удалений

1
mach
Просмотреть файл

@ -11,7 +11,6 @@
# shell because `''':'`, `':'` and `:` are all equivalent, and `:` is a no-op.
''':'
py2commands="
analyze
android
android-emulator
awsy-test

Просмотреть файл

@ -1,134 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function
import os
import sqlite3 as lite
class Node(object):
def __init__(self, graph, node_id):
sql_result = graph.query_arg('SELECT id, dir, type, mtime, name \
FROM node WHERE id=?', (node_id,)).fetchone()
self.id, self.dir, self.type, self.mtime, self.name = sql_result
children = graph.query_arg('SELECT to_id FROM \
normal_link WHERE from_id=?', (self.id,)).fetchall()
self.children = [graph.get_node(x) for (x,) in children]
self.cmds = list(set(self.get_cmd_nodes()))
self.path = self.get_path(graph) if self.type == 0 else ''
self.cost = self.calculate_mtime()
graph.add_node(self.id, self)
@property
def num_cmds(self):
return len(self.cmds)
def get_cmd_nodes(self):
res = []
if self.type == 1:
res += [self]
return res + [c for x in self.children for c in x.cmds]
def get_cmd_ids(self):
return [x.id for x in self.cmds]
def get_path(self, graph):
if self.dir == 1:
return self.name
parent = graph.get_node(self.dir)
return os.path.join(parent.get_path(graph), self.name)
def calculate_mtime(self):
if self.type == 0: # only files have meaningful costs
return sum(x.mtime for x in self.cmds)
else:
return None
class Graph(object):
def __init__(self, path=None, connect=None):
self.connect = connect
if path is not None:
self.connect = lite.connect(path)
elif self.connect is None:
raise Exception
if not self.table_check():
print('\n Tup db does not have the necessary tables.')
raise Exception
self.node_dict = {}
self.results = None
def table_check(self):
tables = [x[0] for x in self.query_arg('SELECT name \
FROM sqlite_master WHERE type=?', ('table',)).fetchall()]
return ('node' in tables and 'normal_link' in tables)
def close(self):
self.connect.close()
def query_arg(self, q, arg):
assert isinstance(arg, tuple) # execute() requires tuple argument
cursor = self.connect.cursor()
cursor.execute(q, arg)
return cursor
def query(self, q):
cursor = self.connect.cursor()
cursor.execute(q)
return cursor
@property
def nodes(self):
return self.node_dict
def add_node(self, k, v):
self.node_dict[k] = v
def get_id(self, filepath):
nodeid = 1
for part in filepath.split('/'):
ret = self.query_arg('SELECT id FROM node \
WHERE dir=? AND name=?', (nodeid, part)).fetchone()
# fetchone should be ok bc dir and and name combo is unique
if ret is None:
print("\nCould not find id number for '%s'" % filepath)
return None
nodeid = ret[0]
return nodeid
def get_node(self, node_id):
if node_id is not None:
node = self.node_dict.get(node_id)
if node is None:
return Node(self, node_id)
else:
return node
def file_summaries(self, files):
for f in files:
node = self.get_node(self.get_id(f))
if node is not None:
sec = node.cost / 1000.0
m, s = sec / 60, sec % 60
print("\n------ Summary for %s ------\
\nTotal Build Time (mm:ss) = %d:%d\nNum Downstream Commands = %d"
% (f, m, s, node.num_cmds))
def populate(self):
# make nodes for files with downstream commands
files = self.query('SELECT id FROM node WHERE type=0 AND id in \
(SELECT DISTINCT from_id FROM normal_link)').fetchall()
res = []
for (i,) in files:
node = self.get_node(i)
res.append((node.path, node.cost))
self.results = res
def get_cost_dict(self):
if self.results is None:
self.populate()
return {k: v for k, v in self.results if v > 0}

Просмотреть файл

@ -14,7 +14,6 @@ backends = {
'GnMozbuildWriter': 'mozbuild.gn_processor',
'RecursiveMake': 'mozbuild.backend.recursivemake',
'TestManifest': 'mozbuild.backend.test_manifest',
'Tup': 'mozbuild.backend.tup',
'VisualStudio': 'mozbuild.backend.visualstudio',
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -486,14 +486,8 @@ class GTestCommands(MachCommandBase):
print("Please run |./mach build| before |./mach gtest|.")
return 1
active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
if 'Tup' in active_backend:
gtest_build_target = mozpath.join(self.topobjdir, '<gtest>')
else:
gtest_build_target = 'recurse_gtest'
res = self._mach_context.commands.dispatch('build', self._mach_context,
what=[gtest_build_target])
what=['recurse_gtest'])
if res:
print("Could not build xul-gtest")
return res
@ -1583,76 +1577,6 @@ class Repackage(MachCommandBase):
)
@CommandProvider
class Analyze(MachCommandBase):
""" Get information about a file in the build graph """
@Command('analyze', category='misc',
description='Analyze the build graph.')
def analyze(self):
print("Usage: ./mach analyze [files|report] [args...]")
@SubCommand('analyze', 'files',
description='Get incremental build cost for file(s) from the tup database.')
@CommandArgument('--path', help='Path to tup db',
default=None)
@CommandArgument('files', nargs='*', help='Files to analyze')
def analyze_files(self, path, files):
from mozbuild.analyze.graph import Graph
if path is None:
path = mozpath.join(self.topsrcdir, '.tup', 'db')
if os.path.isfile(path):
g = Graph(path)
g.file_summaries(files)
g.close()
else:
res = 'Please make sure you have a local tup db *or* specify the location with --path.'
print('Could not find a valid tup db in ' + path, res, sep='\n')
return 1
@SubCommand('analyze', 'all',
description='Get a report of files changed within the last n days and '
'their corresponding build cost.')
@CommandArgument('--days', '-d', type=int, default=14,
help='Number of days to include in the report.')
@CommandArgument('--format', default='pretty',
choices=['pretty', 'csv', 'json', 'html'],
help='Print or export data in the given format.')
@CommandArgument('--limit', type=int, default=None,
help='Get the top n most expensive files from the report.')
@CommandArgument('--path', help='Path to cost_dict.gz',
default=None)
def analyze_report(self, days, format, limit, path):
from mozbuild.analyze.hg import Report
self._activate_virtualenv()
try:
self.virtualenv_manager.install_pip_package('tablib==0.12.1')
except Exception:
print('Could not install tablib via pip.')
return 1
if path is None:
# go find tup db and make a cost_dict
from mozbuild.analyze.graph import Graph
db_path = mozpath.join(self.topsrcdir, '.tup', 'db')
if os.path.isfile(db_path):
g = Graph(db_path)
r = Report(days, cost_dict=g.get_cost_dict())
g.close()
r.generate_output(format, limit, self.topobjdir)
else:
res = 'Please specify the location of cost_dict.gz with --path.'
print('Could not find %s to make a cost dictionary.' % db_path, res, sep='\n')
return 1
else:
# path to cost_dict.gz was specified
if os.path.isfile(path):
r = Report(days, path)
r.generate_output(format, limit, self.topobjdir)
else:
res = 'Please specify the location of cost_dict.gz with --path.'
print('Could not find cost_dict.gz at %s' % path, res, sep='\n')
return 1
@SettingsProvider
class TelemetrySettings():
config_settings = [