-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmake-info
67 lines (55 loc) · 1.79 KB
/
cmake-info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /usr/bin/python
import json
import os
import sys
import subprocess
import time
import re
import argparse
from sys import exit
print('CMake Project Info')
def isCmakeToolsProject():
if(os.path.exists('.cmake-project.json')):
os.rename('.cmake-project.json', 'cmake-project.json')
if(os.path.exists('cmake-project.json')):
return True
return False
def loadProject():
if(isCmakeToolsProject()):
with open('cmake-project.json') as json_file:
return json.load(json_file)
return None
project = loadProject()
if project == None:
print('No project found')
exit()
# Construct the argument parser
ap = argparse.ArgumentParser()
# Add the arguments to the parser
ap.add_argument("-b", "--basic", help="show only basic info", action='store_true')
ap.add_argument("-e", "--exes", help="show only executables", action='store_true')
ap.add_argument("-l", "--libs", help="show only libraries", action='store_true')
args = ap.parse_args()
if not args.exes and not args.libs:
print("Name: %s" % project['name'])
print("Language: %s" % project['language'])
if 'version' in project:
print("Version: %s" % project['version'])
if 'descr' in project:
print("Description: %s" % project['descr'])
if not args.basic and not args.libs:
if len(project['exes']) == 0:
print("Executables (0):")
else:
print("Executables (%d):" % len(project['exes']))
for exe in project['exes']:
if exe is str:
exe = [exe, exe]
print(" %s" % (exe[0], exe[1]))
if not args.basic and not args.exes:
if len(project['libs']) == 0:
print("Libraries (0):")
else:
print("Libraries (%d):" % len(project['libs']))
for lib in project['libs']:
print(" %s" % lib)