Mercurial > vim-crosoft
view scripts/get_proj_config.py @ 10:f444739dd8af
Improvements to YCM dynamic flags.
- Fallback to a "companion" item (e.g. header/source) or a nearby item
when no flags are found for an item.
- Finding a "companion" is also exposed as a standalone script.
- Ability to pass extra clang flags, including some from a special
file found in the .vimcrosoft directory.
- Add support for PCH and other forced-include files.
- Add options for short/long args, or forcing forward slashes.
- Debugging/troubleshooting options, including dumping a batch file and
response file to run clang directly, and the ability to auto-load a
solution's last known environment when running in command line.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 24 Sep 2020 23:02:16 -0700 |
parents | 5d2c0db51914 |
children |
line wrap: on
line source
import argparse import logging import re from vsutil import SolutionCache re = _re_proj_cfg_suffix = re.compile(r'\.(ActiveCfg|Build\.0)$') def main(): parser = argparse.ArgumentParser() parser.add_argument('solution', help="The path to the Visual Studio solution file.") parser.add_argument('cache', help="The path to the solution cache.") parser.add_argument('project', help="The name of the project to check for.") parser.add_argument('slnconfig', help="The solution configuration.") parser.add_argument('-v', '--verbose', action='store_true', help="Show verbose information.") args = parser.parse_args() loglevel = logging.INFO if args.verbose: loglevel = logging.DEBUG logging.basicConfig(level=loglevel) logger = logging.getLogger() cache, loaded = SolutionCache.load_or_rebuild(args.solution, args.cache) logger.debug("Cache was %s" % ("valid" if loaded else "not valid")) proj = cache.slnobj.find_project_by_name(args.project) if proj is None: raise Exception("No such project: %s" % args.project) projguid = '{%s}' % proj.guid slnconfig = args.slnconfig.replace(' ', '_') sec = cache.slnobj.globalsection('ProjectConfigurationPlatforms') for e in sec.entries: if e.name.startswith(projguid): if slnconfig == e.value.replace(' ', '_'): projcfg = e.name[len(projguid) + 1:] projcfg = _re_proj_cfg_suffix.sub('', projcfg) print(projcfg) break if __name__ == '__main__': main()