3 from __future__ import print_function
9 # This file is in the dist directory, need to add ../plugin/TagHighlight to
11 sys.path = [os.path.abspath(os.path.join(os.path.dirname(__file__),'../plugin/TagHighlight'))] + \
14 library_types_root = os.path.abspath(os.path.join(os.path.dirname(__file__),
15 '../plugin/TagHighlight/standard_libraries'))
17 from module.worker import RunWithOptions
18 from module.utilities import TagHighlightOptionDict
20 library_root = os.path.join(os.environ['HOME'], 'development','libraries')
21 tools_dir = os.path.join(library_root, 'tools')
22 if not os.path.exists(tools_dir):
23 os.makedirs(tools_dir)
25 fLog = open(os.path.join(library_root, 'log_%s.txt' % time.strftime('%Y%m%d_%H%M%S')), 'w')
27 repo_location = os.path.join(tools_dir, 'repo')
31 'Name': 'Android SDK',
32 'Directory': 'android',
33 'Output': 'android_sdk.taghl',
35 'ToolFetchCommands': [['wget', '-O', repo_location, '--no-check-certificate', 'https://android.git.kernel.org/repo'],
36 ['chmod','a+x',repo_location]],
38 'UpdateCommands': [[repo_location, 'sync']],
39 'GetStart': 'InDirectory',
40 'GetCommands': [[repo_location,'init','-u','git://android.git.kernel.org/platform/manifest.git'],
41 [repo_location, 'sync']],
47 'Output': 'jdk.taghl',
49 'ToolFetchCommands': [],
51 'UpdateCommands': [['hg','pull','-u']],
52 'GetStart': 'AboveDirectory',
53 'GetCommands': [['hg','clone','http://hg.openjdk.java.net/jdk7/jdk7/jdk']],
59 'Output': 'qt4.taghl',
61 'ToolFetchCommands': [],
63 'UpdateCommands': [['git','pull']],
64 'GetStart': 'AboveDirectory',
65 'GetCommands': [['git','clone','git://gitorious.org/qt/qt.git','qt4']],
70 'Directory': 'wxwidgets',
71 'Output': 'wxwidgets.taghl',
73 'ToolFetchCommands': [],
75 'UpdateCommands': [['svn','update']],
76 'GetStart': 'AboveDirectory',
77 'GetCommands': [['svn','co','http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk','wxwidgets']],
82 'Directory': 'wxpython',
83 'Output': 'wxpython.taghl',
85 'ToolFetchCommands': [],
87 'UpdateCommands': [['svn','update']],
88 'GetStart': 'AboveDirectory',
89 'GetCommands': [['svn','co','http://svn.wxwidgets.org/svn/wx/wxPython/trunk','wxpython']],
94 'Directory': 'pyside',
95 'Output': 'pyside.taghl',
97 'ToolFetchCommands': [],
99 'UpdateCommands': [['git','pull']],
100 'GetStart': 'AboveDirectory',
101 'GetCommands': [['git','clone','git://gitorious.org/pyside/pyside.git','pyside']],
106 if len(sys.argv) > 1:
107 library_list = [i.lower() for i in sys.argv[1:]]
109 library_list = [i['Name'].lower() for i in libraries]
112 for library in libraries:
113 if library['Name'].lower() in library_list:
114 CreateLibraryTypes(library)
116 def CreateLibraryTypes(library):
117 os.chdir(library_root)
118 library_source_dir = os.path.join(library_root, library['Directory'])
120 if os.path.exists(library_source_dir):
121 if library['CanUpdate']:
122 # We've downloaded this before, just run the update commands
123 os.chdir(library_source_dir)
124 for command in library['UpdateCommands']:
125 p = subprocess.Popen(command, stdout=fLog, stderr=fLog)
130 shutil.rmtree(library_source_dir)
132 # New project, we need to get any required tools and then download
133 # the source from scratch
134 for command in library['ToolFetchCommands']:
135 p = subprocess.Popen(command, stdout=fLog, stderr=fLog)
137 if library['GetStart'] == 'InDirectory':
138 os.mkdir(library_source_dir)
139 os.chdir(library_source_dir)
141 os.chdir(library_root)
142 for command in library['GetCommands']:
143 p = subprocess.Popen(command, stdout=fLog, stderr=fLog)
146 output_dir = os.path.join(library_types_root, library['Directory'])
147 if not os.path.exists(output_dir):
150 os.chdir(library_root)
151 # Should now have the library; start making the options
152 options = TagHighlightOptionDict()
153 options['recurse'] = True
154 options['types_file_name_override'] = library['Output']
155 options['skip_patterns'] = library['SkipPatterns']
156 options['languages'] = [library['Language']]
157 options['types_file_location'] = output_dir
158 options['source_root'] = library_source_dir
159 options['check_keywords'] = True
160 RunWithOptions(options)