diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 17:58:42 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 17:58:42 +0100 |
commit | 98b802e36b2a291b39dbdb83b55546b1acae1573 (patch) | |
tree | a6579f891f29f15a7b8b7c94ea3847cc66ad5428 /morphlib/buildsystem.py | |
parent | 975b3f30605c36a714bf5b9619817a897cb6a4a3 (diff) | |
download | morph-98b802e36b2a291b39dbdb83b55546b1acae1573.tar.gz |
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.
Diffstat (limited to 'morphlib/buildsystem.py')
-rw-r--r-- | morphlib/buildsystem.py | 4 |
1 files changed, 3 insertions, 1 deletions
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): |