removed all but vam submodule to let autoinstall work
[stack/conf/vim.git] / addons / TagHighlight / dist / make_taghighlight_libraries.py
1 #!/usr/bin/python
2
3 from __future__ import print_function
4 import os
5 import sys
6 import subprocess
7 import time
8
9 # This file is in the dist directory, need to add ../plugin/TagHighlight to
10 # module search path
11 sys.path = [os.path.abspath(os.path.join(os.path.dirname(__file__),'../plugin/TagHighlight'))] + \
12         sys.path
13
14 library_types_root = os.path.abspath(os.path.join(os.path.dirname(__file__),
15     '../plugin/TagHighlight/standard_libraries'))
16
17 from module.worker import RunWithOptions
18 from module.utilities import TagHighlightOptionDict
19
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)
24
25 fLog = open(os.path.join(library_root, 'log_%s.txt' % time.strftime('%Y%m%d_%H%M%S')), 'w')
26
27 repo_location = os.path.join(tools_dir, 'repo')
28
29 libraries = [
30         {
31             'Name': 'Android SDK',
32             'Directory': 'android',
33             'Output': 'android_sdk.taghl',
34             'Language': 'java',
35             'ToolFetchCommands': [['wget', '-O', repo_location, '--no-check-certificate', 'https://android.git.kernel.org/repo'],
36                 ['chmod','a+x',repo_location]],
37             'CanUpdate': True,
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']],
42             'SkipPatterns': [],
43         },
44         {
45             'Name': 'JDK',
46             'Directory': 'jdk',
47             'Output': 'jdk.taghl',
48             'Language': 'java',
49             'ToolFetchCommands': [],
50             'CanUpdate': True,
51             'UpdateCommands': [['hg','pull','-u']],
52             'GetStart': 'AboveDirectory',
53             'GetCommands': [['hg','clone','http://hg.openjdk.java.net/jdk7/jdk7/jdk']],
54             'SkipPatterns': [],
55         },
56         {
57             'Name': 'Qt4',
58             'Directory': 'qt4',
59             'Output': 'qt4.taghl',
60             'Language': 'c',
61             'ToolFetchCommands': [],
62             'CanUpdate': True,
63             'UpdateCommands': [['git','pull']],
64             'GetStart': 'AboveDirectory',
65             'GetCommands': [['git','clone','git://gitorious.org/qt/qt.git','qt4']],
66             'SkipPatterns': [],
67         },
68         {
69             'Name': 'wxWidgets',
70             'Directory': 'wxwidgets',
71             'Output': 'wxwidgets.taghl',
72             'Language': 'c',
73             'ToolFetchCommands': [],
74             'CanUpdate': True,
75             'UpdateCommands': [['svn','update']],
76             'GetStart': 'AboveDirectory',
77             'GetCommands': [['svn','co','http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk','wxwidgets']],
78             'SkipPatterns': [],
79         },
80         {
81             'Name': 'wxPython',
82             'Directory': 'wxpython',
83             'Output': 'wxpython.taghl',
84             'Language': 'python',
85             'ToolFetchCommands': [],
86             'CanUpdate': True,
87             'UpdateCommands': [['svn','update']],
88             'GetStart': 'AboveDirectory',
89             'GetCommands': [['svn','co','http://svn.wxwidgets.org/svn/wx/wxPython/trunk','wxpython']],
90             'SkipPatterns': [],
91         },
92         {
93             'Name': 'PySide',
94             'Directory': 'pyside',
95             'Output': 'pyside.taghl',
96             'Language': 'python',
97             'ToolFetchCommands': [],
98             'CanUpdate': True,
99             'UpdateCommands': [['git','pull']],
100             'GetStart': 'AboveDirectory',
101             'GetCommands': [['git','clone','git://gitorious.org/pyside/pyside.git','pyside']],
102             'SkipPatterns': [],
103         },
104         ]
105
106 if len(sys.argv) > 1:
107     library_list = [i.lower() for i in sys.argv[1:]]
108 else:
109     library_list = [i['Name'].lower() for i in libraries]
110
111 def Run():
112     for library in libraries:
113         if library['Name'].lower() in library_list:
114             CreateLibraryTypes(library)
115
116 def CreateLibraryTypes(library):
117     os.chdir(library_root)
118     library_source_dir = os.path.join(library_root, library['Directory'])
119     done = False
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)
126                 p.communicate()
127             done = True
128         else:
129             import shutil
130             shutil.rmtree(library_source_dir)
131     if not done:
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)
136             p.communicate()
137         if library['GetStart'] == 'InDirectory':
138             os.mkdir(library_source_dir)
139             os.chdir(library_source_dir)
140         else:
141             os.chdir(library_root)
142         for command in library['GetCommands']:
143             p = subprocess.Popen(command, stdout=fLog, stderr=fLog)
144             p.communicate()
145
146     output_dir = os.path.join(library_types_root, library['Directory'])
147     if not os.path.exists(output_dir):
148         os.mkdir(output_dir)
149
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)
161
162 Run()
163
164 fLog.close()