Mercurial > vim-crosoft
comparison scripts/get_proj_config.py @ 0:5d2c0db51914
Initial commit
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Tue, 17 Sep 2019 13:24:24 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:5d2c0db51914 |
|---|---|
| 1 import argparse | |
| 2 import logging | |
| 3 import re | |
| 4 from vsutil import SolutionCache | |
| 5 | |
| 6 | |
| 7 re = _re_proj_cfg_suffix = re.compile(r'\.(ActiveCfg|Build\.0)$') | |
| 8 | |
| 9 | |
| 10 def main(): | |
| 11 parser = argparse.ArgumentParser() | |
| 12 parser.add_argument('solution', | |
| 13 help="The path to the Visual Studio solution file.") | |
| 14 parser.add_argument('cache', | |
| 15 help="The path to the solution cache.") | |
| 16 parser.add_argument('project', | |
| 17 help="The name of the project to check for.") | |
| 18 parser.add_argument('slnconfig', | |
| 19 help="The solution configuration.") | |
| 20 parser.add_argument('-v', '--verbose', | |
| 21 action='store_true', | |
| 22 help="Show verbose information.") | |
| 23 args = parser.parse_args() | |
| 24 | |
| 25 loglevel = logging.INFO | |
| 26 if args.verbose: | |
| 27 loglevel = logging.DEBUG | |
| 28 logging.basicConfig(level=loglevel) | |
| 29 logger = logging.getLogger() | |
| 30 | |
| 31 cache, loaded = SolutionCache.load_or_rebuild(args.solution, args.cache) | |
| 32 logger.debug("Cache was %s" % ("valid" if loaded else "not valid")) | |
| 33 | |
| 34 proj = cache.slnobj.find_project_by_name(args.project) | |
| 35 if proj is None: | |
| 36 raise Exception("No such project: %s" % args.project) | |
| 37 projguid = '{%s}' % proj.guid | |
| 38 | |
| 39 slnconfig = args.slnconfig.replace(' ', '_') | |
| 40 sec = cache.slnobj.globalsection('ProjectConfigurationPlatforms') | |
| 41 for e in sec.entries: | |
| 42 if e.name.startswith(projguid): | |
| 43 if slnconfig == e.value.replace(' ', '_'): | |
| 44 projcfg = e.name[len(projguid) + 1:] | |
| 45 projcfg = _re_proj_cfg_suffix.sub('', projcfg) | |
| 46 print(projcfg) | |
| 47 break | |
| 48 | |
| 49 | |
| 50 if __name__ == '__main__': | |
| 51 main() | |
| 52 |
