forked from Pich78/docfetcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-man.py
executable file
·63 lines (53 loc) · 1.37 KB
/
build-man.py
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
#!/usr/bin/python
import os, shutil, platform, sys
from os.path import exists, join, isfile, isdir
if len(sys.argv) <= 1:
print('Must specify a language ID, for example: en, de, fr, ...')
exit(0)
is_windows = 'windows' in platform.system().lower()
classpath_sep = ';' if is_windows else ':'
print('Cleaning build directory...')
class_dir = 'build/man/classes'
if not exists(class_dir):
os.makedirs(class_dir)
for filename in os.listdir(class_dir):
path = join(class_dir, filename)
if isfile(path):
os.remove(path)
elif isdir(path):
shutil.rmtree(path)
def execute(cmd_parts):
os.system(' '.join(cmd_parts))
# Recursively collect library jars
jars = []
for root, dirs, files in os.walk('lib'):
for filename in files:
if not filename.endswith('.jar'): continue
jars.append(join(root, filename))
print('Compiling sources...')
execute([
'javac',
'-sourcepath src',
'-classpath \"%s\"' % classpath_sep.join(jars),
'-nowarn',
'-d %s' % class_dir,
'src/net/sourceforge/docfetcher/man/Manual.java'
])
jar_path = 'build/man/docfetcher-man-builder.jar'
main_class = 'net.sourceforge.docfetcher.man.Manual'
print('Creating builder jar...')
execute([
'jar cfe',
jar_path,
main_class,
'-C %s net' % class_dir
])
print('Launching builder...')
print('-' * 40)
jars.append(jar_path)
execute([
'java',
'-classpath \"%s\"' % classpath_sep.join(jars),
main_class,
sys.argv[1]
])