comparison scripts/list_sln_files.py @ 0:5d2c0db51914

Initial commit
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 17 Sep 2019 13:24:24 -0700
parents
children bac97082e229
comparison
equal deleted inserted replaced
-1:000000000000 0:5d2c0db51914
1 import argparse
2 import logging
3 import os.path
4 from logutil import setup_logging
5 from vsutil import SolutionCache
6
7
8 logger = logging.getLogger(__name__)
9
10
11 def main(args=None):
12 parser = argparse.ArgumentParser()
13 parser.add_argument('solution',
14 help="The path to the Visual Studio solution file.")
15 parser.add_argument('-p', '--project',
16 help="Only list files in the named project.")
17 parser.add_argument('-c', '--cache',
18 help="Use a cache file to store the file list.")
19 parser.add_argument('-v', '--verbose',
20 action='store_true',
21 help="Show verbose information.")
22 args = parser.parse_args(args)
23 setup_logging(args.verbose)
24
25 cache, _ = SolutionCache.load_or_rebuild(args.solution, args.cache)
26 slnobj = cache.slnobj
27
28 projs = slnobj.projects
29 if args.project:
30 projs = [slnobj.find_project_by_name(args.project)]
31 projs = list(filter(lambda p: not p.is_folder, projs))
32
33 for p in projs:
34 ig = p.defaultitemgroup()
35 for i in ig.get_source_items():
36 file_path = os.path.abspath(os.path.join(p.absdirpath, i.include))
37 print(file_path)
38
39
40 if __name__ == '__main__':
41 main()