Hal Canary | f72728e | 2019-07-10 11:24:52 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2019 Google Inc. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import os |
| 7 | import sys |
| 8 | |
| 9 | ''' |
| 10 | Look for the first match in the format |
| 11 | C:\\Program Files (x86)\\Microsoft Visual Studio\\${RELEASE}\\${VERSION}\\VC |
| 12 | ''' |
| 13 | def find_msvc(): |
| 14 | if sys.platform.startswith('win'): |
| 15 | default_dir = r'C:\Program Files (x86)\Microsoft Visual Studio' |
| 16 | for release in ['2019', '2017']: |
| 17 | for version in ['Enterprise', 'Professional', 'Community', 'BuildTools']: |
| 18 | path = os.path.join(default_dir, release, version, 'VC') |
| 19 | if os.path.isdir(path): |
| 20 | return path |
| 21 | return None |
| 22 | |
| 23 | if __name__ == '__main__': |
| 24 | result = find_msvc() |
| 25 | if result: |
| 26 | sys.stdout.write(result + '\n') |