From 98b802e36b2a291b39dbdb83b55546b1acae1573 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 24 Aug 2012 17:58:42 +0100 Subject: Use git ls-tree to autodetect build system The cost of one git ls-tree call is roughly the same as one git cat-file call. Therefore, when autodetecting the build system, it is much faster to list the tree once and then search for the required files than to call git cat-file for every possible one. --- morphlib/buildsystem.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'morphlib/buildsystem.py') diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index 8e213b75..86eac850 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -195,13 +195,15 @@ build_systems = [ ] -def detect_build_system(exists): +def detect_build_system(file_list): '''Automatically detect the build system, if possible. If the build system cannot be detected automatically, return None. For ``exists`` see the ``BuildSystem.exists`` method. ''' + def exists(filename): + return filename in file_list for bs in build_systems: if bs.used_by_project(exists): -- cgit v1.2.1