IGN:New windows build system

This commit is contained in:
Kovid Goyal 2009-08-25 11:10:44 -06:00
parent 5e65dd3499
commit a04024d455
4 changed files with 66 additions and 60 deletions

View File

@ -7,15 +7,12 @@ __docformat__ = 'restructuredtext en'
Freeze app into executable using py2exe.
'''
QT_DIR = 'C:\\Qt\\4.5.2'
LIBUSB_DIR = 'C:\\libusb'
LIBUSB_DIR = r'C:\cygwin\home\kovid\win32\libusb'
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
PDFTOHTML = 'C:\\cygwin\\home\\kovid\\poppler-0.10.6\\rel\\pdftohtml.exe'
POPPLER = 'C:\\cygwin\\home\\kovid\\poppler'
IMAGEMAGICK_DIR = 'C:\\ImageMagick'
PDFTK = 'C:\\pdftk.exe'
PODOFO = 'C:\\podofo'
FONTCONFIG_DIR = 'C:\\fontconfig'
VC90 = r'C:\VC90.CRT'
BINARIES = r'C:\cygwin\home\kovid\win32\bin'
IMAGEMAGICK_DIR = r'C:\cygwin\home\kovid\win32\imagemagick'
FONTCONFIG_DIR = r'C:\cygwin\home\kovid\win32\etc'
VC90 = r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT'
# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
import sys
@ -98,25 +95,17 @@ class BuildEXE(py2exe.build_exe.py2exe):
shutil.copyfile(f, os.path.join(tdir, os.path.basename(f)))
print '\tAdding unrar'
shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR)))
print '\tAdding poppler'
for x in ('bin\\pdftohtml.exe', 'bin\\poppler-qt4.dll',
'bin\\freetype.dll', 'bin\\jpeg62.dll'):
shutil.copyfile(os.path.join(POPPLER, x),
os.path.join(PY2EXE_DIR, os.path.basename(x)))
print '\tAdding podofo'
for f in glob.glob(os.path.join(PODOFO, '*.dll')):
shutil.copyfile(f, os.path.join(PY2EXE_DIR, os.path.basename(f)))
print '\tAdding Binaries'
for x in glob.glob(os.path.join(BINARIES, '*.dll')) + \
[os.path.join(BINARIES, 'pdftohtml.exe')] + \
glob.glob(os.path.join(BINARIES, '*.manifest')):
shutil.copyfile(x, os.path.join(PY2EXE_DIR, os.path.basename(x)))
print '\tAdding ImageMagick'
for f in os.listdir(IMAGEMAGICK_DIR):
shutil.copyfile(os.path.join(IMAGEMAGICK_DIR, f), os.path.join(PY2EXE_DIR, f))
print '\tCopying fontconfig'
for f in glob.glob(os.path.join(FONTCONFIG_DIR, '*')):
tgt = os.path.join(PY2EXE_DIR, os.path.basename(f))
if os.path.isdir(f):
shutil.copytree(f, tgt)
else:
shutil.copyfile(f, tgt)
tgt = os.path.join(PY2EXE_DIR, 'etc')
shutil.copytree(FONTCONFIG_DIR, tgt)
print
print 'Doing DLL redirection' # See http://msdn.microsoft.com/en-us/library/ms682600(VS.85).aspx
@ -169,8 +158,7 @@ def main(args=sys.argv):
'email.iterators',
'email.generator',
'win32process', 'win32api', 'msvcrt',
'win32event', 'calibre.ebooks.lrf.any.*',
'calibre.ebooks.lrf.feeds.*',
'win32event',
'BeautifulSoup', 'pyreadline',
'pydoc', 'IPython.Extensions.*',
'calibre.web.feeds.recipes.*',

View File

@ -94,8 +94,8 @@ if __name__ == '__main__':
sources=['src/calibre/utils/windows/winutil.c'],
libraries=['shell32', 'setupapi'],
include_dirs=os.environ.get('INCLUDE',
'C:/WinDDK/6001.18001/inc/api/;'
'C:/WinDDK/6001.18001/inc/crt/').split(';'),
'C:/WinDDK/7600.16385.0/inc/api/;'
'C:/WinDDK/7600.16385.0/inc/crt/').split(';'),
extra_compile_args=['/X']
))
@ -103,8 +103,8 @@ if __name__ == '__main__':
poppler_lib = '/usr/lib'
poppler_libs = []
if iswindows:
poppler_inc = r'C:\cygwin\home\kovid\poppler\include\poppler\qt4'
poppler_lib = r'C:\cygwin\home\kovid\poppler\lib'
poppler_inc = r'C:\cygwin\home\kovid\win32\include\poppler\qt4'
poppler_lib = r'C:\cygwin\home\kovid\win32\lib'
poppler_libs = ['QtCore4', 'QtGui4']
if isosx:
poppler_inc = '/Volumes/sw/build/poppler-0.10.7/qt4/src'
@ -124,9 +124,10 @@ if __name__ == '__main__':
print 'POPPLER_LIB_DIR environment variables.'
podofo_inc = '/usr/include/podofo' if islinux else \
'C:\\podofo\\include\\podofo' if iswindows else \
r'C:\cygwin\home\kovid\win32\include\podofo' if iswindows else \
'/usr/local/include/podofo'
podofo_lib = '/usr/lib' if islinux else r'C:\podofo' if iswindows else \
podofo_lib = '/usr/lib' if islinux else \
r'C:\cygwin\home\kovid\win32\lib' if iswindows else \
'/usr/local/lib'
podofo_inc = os.environ.get('PODOFO_INC_DIR', podofo_inc)
if os.path.exists(os.path.join(podofo_inc, 'podofo.h')):
@ -141,10 +142,10 @@ if __name__ == '__main__':
print 'PODOFO_LIB_DIR environment variables.'
fc_inc = '/usr/include/fontconfig' if islinux else \
r'C:\cygwin\home\kovid\fontconfig\include\fontconfig' if iswindows else \
r'C:\cygwin\home\kovid\win32\include\fontconfig' if iswindows else \
'/Users/kovid/fontconfig/include/fontconfig'
fc_lib = '/usr/lib' if islinux else \
r'C:\cygwin\home\kovid\fontconfig\lib' if iswindows else \
r'C:\cygwin\home\kovid\win32\lib' if iswindows else \
'/Users/kovid/fontconfig/lib'

View File

@ -110,7 +110,7 @@ class LibraryServer(object):
<title>${authors}</title>
<id>urn:calibre:${record[FM['id']]}</id>
<updated>${timestamp}</updated>
<link type="application/atom+xml" href="/?authorid=${record[FM['id']]}" />
<link type="application/atom+xml" href="/stanza/?authorid=${record[FM['id']]}" />
</entry>
'''))
@ -120,7 +120,7 @@ class LibraryServer(object):
<title>calibre Library</title>
<id>$id</id>
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
<link rel="search" title="Search" type="application/atom+xml" href="/?search={searchTerms}"/>
<link rel="search" title="Search" type="application/atom+xml" href="/stanza/?search={searchTerms}"/>
<author>
<name>calibre</name>
<uri>http://calibre.kovidgoyal.net</uri>
@ -140,7 +140,7 @@ class LibraryServer(object):
<title>calibre Library</title>
<id>$id</id>
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
<link rel="search" title="Search" type="application/atom+xml" href="/?search={searchTerms}"/>
<link rel="search" title="Search" type="application/atom+xml" href="/stanza/?search={searchTerms}"/>
<author>
<name>calibre</name>
<uri>http://calibre.kovidgoyal.net</uri>
@ -152,19 +152,19 @@ class LibraryServer(object):
<title>By Author</title>
<id>urn:uuid:fc000fa0-8c23-11de-a31d-0002a5d5c51b</id>
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
<link type="application/atom+xml" href="/?sortby=byauthor" />
<link type="application/atom+xml" href="/stanza/?sortby=byauthor" />
</entry>
<entry>
<title>By Title</title>
<id>urn:uuid:1df4fe40-8c24-11de-b4c6-0002a5d5c51b</id>
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
<link type="application/atom+xml" href="/?sortby=bytitle" />
<link type="application/atom+xml" href="/stanza/?sortby=bytitle" />
</entry>
<entry>
<title>By Newest</title>
<id>urn:uuid:3c6d4940-8c24-11de-a4d7-0002a5d5c51b</id>
<updated>${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')}</updated>
<link type="application/atom+xml" href="/?sortby=bynewest" />
<link type="application/atom+xml" href="/stanza/?sortby=bynewest" />
</entry>
</feed>
'''))

View File

@ -528,6 +528,27 @@ class VMInstaller(OptionlessCommand):
def get_build_script(self, subs):
return self.BUILD_SCRIPT%subs
def vmware_started(self):
return 'started' in subprocess.Popen('/etc/init.d/vmware status', shell=True, stdout=subprocess.PIPE).stdout.read()
def start_vmware(self):
if not self.vmware_started():
if os.path.exists('/dev/kvm'):
check_call('sudo rmmod -w kvm-intel kvm', shell=True)
subprocess.Popen('sudo /etc/init.d/vmware start', shell=True)
def stop_vmware(self):
while True:
try:
check_call('sudo /etc/init.d/vmware stop', shell=True)
break
except:
pass
while 'vmblock' in open('/proc/modules').read():
check_call('sudo rmmod -f vmblock')
check_call('sudo modprobe kvm-intel', shell=True)
def run_vm(self):
vmware = ('vmware', '-q', '-x', '-n', self.VM)
self.__p = Popen(vmware)
@ -547,9 +568,18 @@ class VMInstaller(OptionlessCommand):
check_call(('scp', t.name, ssh_host+':build-calibre'))
check_call('ssh -t %s bash build-calibre'%ssh_host, shell=True)
class build_linux32(VMInstaller):
class KVMInstaller(VMInstaller):
def run_vm(self):
self.stop_vmware()
self.__p = Popen(self.VM)
class build_linux32(KVMInstaller):
description = 'Build linux 32bit installer'
VM = '/vmware/bin/linux_build'
def run_vm(self):
self.__p = Popen('/vmware/bin/linux_build')
@ -569,25 +599,23 @@ class build_linux32(VMInstaller):
return _build_linux()
class build_windows(VMInstaller):
class build_windows(KVMInstaller):
description = 'Build windows installer'
VM = '/mnt/backup/calibre_windows_xp_home/calibre_windows_xp_home.vmx'
if not os.path.exists(VM):
VM = '/home/kovid/calibre_windows_xp_home/calibre_windows_xp_home.vmx'
VM = '/vmware/bin/win_build'
def run(self):
installer = installer_name('exe')
self.start_vm('windows', ('python setup.py develop',
self.start_vm('win_build', ('python setup.py develop',
'python',
r'installer\\windows\\freeze.py'))
if os.path.exists('build/py2exe'):
shutil.rmtree('build/py2exe')
check_call(('scp', '-rp', 'windows:build/%s/build/py2exe'%__appname__,
check_call(('scp', '-rp', 'win_build:build/%s/build/py2exe'%__appname__,
'build'))
if not os.path.exists('build/py2exe'):
raise Exception('Failed to run py2exe')
if not self.dont_shutdown:
Popen(('ssh', 'windows', 'shutdown', '-s', '-t', '0'))
Popen(('ssh', 'win_build', 'shutdown', '-s', '-t', '0'))
self.run_windows_install_jammer(installer)
return os.path.basename(installer)
@ -613,9 +641,7 @@ class build_osx(VMInstaller):
def run(self):
installer = installer_name('dmg')
python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python'
if os.path.exists('/dev/kvm'):
check_call('sudo rmmod -w kvm-intel kvm', shell=True)
check_call('sudo /etc/init.d/vmware restart', shell=True)
self.start_vmware()
self.start_vm('osx_build', ('sudo %s setup.py develop'%python, python,
'installer/osx/freeze.py'))
check_call(('scp', 'osx_build:build/calibre/dist/*.dmg', 'dist'))
@ -624,18 +650,9 @@ class build_osx(VMInstaller):
if not self.dont_shutdown:
Popen(('ssh', 'osx_build', 'sudo', '/sbin/shutdown', '-h', 'now'))
time.sleep(20)
while True:
try:
check_call('sudo /etc/init.d/vmware stop', shell=True)
break
except:
pass
check_call('sudo modprobe kvm-intel', shell=True)
self.stop_vmware()
return os.path.basename(installer)
class upload_installers(OptionlessCommand):
description = 'Upload any installers present in dist/'
def curl_list_dir(self, url=MOBILEREAD, listonly=1):