This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwin
executable file
·67 lines (51 loc) · 1.74 KB
/
win
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/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import (unicode_literals, division, absolute_import,
print_function)
import sys
import os
import errno
import subprocess
from vms import ensure_vm, shutdown_vm, Rsync, to_vm, from_vm, run_main, get_calibre_dir
VM = 'win-calibre-build'
rsync = Rsync(VM)
base = os.path.dirname(os.path.abspath(__file__))
if sys.argv[1:] == ['shutdown']:
shutdown_vm(VM)
raise SystemExit(0)
def abspath(x):
return os.path.abspath(os.path.join(base, x))
def usage():
raise SystemExit((
'Usage: %s 32|64|shutdown'
' [the rest of the command line is passed to main.py]'
) % sys.argv[0])
arch = sys.argv[1].decode('utf-8')
if arch not in '64 32'.split() or len(sys.argv) < 2:
usage()
def mkdir(x):
try:
os.mkdir(abspath(x))
except EnvironmentError as err:
if err.errno == errno.EEXIST:
return
raise
mkdir('sources-cache')
mkdir('build')
mkdir('build/win')
output_dir = os.path.join(abspath('build'), 'win', arch)
mkdir(output_dir)
ensure_vm(VM)
calibre_dir = get_calibre_dir()
if os.path.exists(os.path.join(calibre_dir, 'setup.py')):
if 'calibre' in sys.argv and not os.path.exists(os.path.join(calibre_dir, 'icons', 'library.ico')):
# Ensure .ico files are built
print('Building .ico icons...')
subprocess.check_call([sys.executable, os.path.join(calibre_dir, 'icons', 'make_ico_files.py')])
to_vm(rsync, output_dir, prefix='/cygdrive/c/', name='sw' + arch)
try:
run_main(VM, 'python', '/scripts/main.py', *sys.argv[1:])
finally:
print()
from_vm(rsync, output_dir, prefix='/cygdrive/c/', name='sw' + arch)