mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Switch build system to use new OS X build
This commit is contained in:
parent
96e76fb230
commit
2213a4648a
@ -13,12 +13,9 @@ from PyQt4 import pyqtconfig
|
|||||||
|
|
||||||
from setup import isosx, iswindows, islinux
|
from setup import isosx, iswindows, islinux
|
||||||
|
|
||||||
OSX_SDK = '/Developer/SDKs/MacOSX10.5.sdk'
|
OSX_SDK = '/Developer/SDKs/MacOSX10.4u.sdk'
|
||||||
if not os.path.exists(OSX_SDK):
|
|
||||||
OSX_SDK = '/Developer/SDKs/MacOSX10.4u.sdk'
|
|
||||||
leopard_build = '10.5' in OSX_SDK
|
|
||||||
|
|
||||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.5' if leopard_build else '10.4'
|
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
|
||||||
|
|
||||||
NMAKE = RC = msvc = MT = win_inc = win_lib = None
|
NMAKE = RC = msvc = MT = win_inc = win_lib = None
|
||||||
if iswindows:
|
if iswindows:
|
||||||
@ -117,24 +114,24 @@ if iswindows:
|
|||||||
podofo_inc = os.path.join(sw_inc_dir, 'podofo')
|
podofo_inc = os.path.join(sw_inc_dir, 'podofo')
|
||||||
podofo_lib = sw_lib_dir
|
podofo_lib = sw_lib_dir
|
||||||
elif isosx:
|
elif isosx:
|
||||||
fc_inc = '/Users/kovid/fontconfig/include/fontconfig'
|
fc_inc = '/sw/include/fontconfig'
|
||||||
fc_lib = '/Users/kovid/fontconfig/lib'
|
fc_lib = '/sw/lib'
|
||||||
poppler_inc_dirs = consolidate('POPPLER_INC_DIR',
|
poppler_inc_dirs = consolidate('POPPLER_INC_DIR',
|
||||||
'/Volumes/sw/build/poppler-0.12.0/poppler:/Volumes/sw/build/poppler-0.12.0')
|
'/sw/build/poppler-0.12.2/poppler:/sw/build/poppler-0.12.2')
|
||||||
popplerqt4_inc_dirs = poppler_inc_dirs + [poppler_inc_dirs[0]+'/qt4']
|
popplerqt4_inc_dirs = poppler_inc_dirs + [poppler_inc_dirs[0]+'/qt4']
|
||||||
poppler_lib_dirs = consolidate('POPPLER_LIB_DIR',
|
poppler_lib_dirs = consolidate('POPPLER_LIB_DIR',
|
||||||
'/Volumes/sw/lib')
|
'/sw/lib')
|
||||||
popplerqt4_lib_dirs = poppler_lib_dirs
|
popplerqt4_lib_dirs = poppler_lib_dirs
|
||||||
poppler_libs = popplerqt4_libs = ['poppler']
|
poppler_libs = popplerqt4_libs = ['poppler']
|
||||||
podofo_inc = '/usr/local/include/podofo'
|
podofo_inc = '/sw/podofo'
|
||||||
podofo_lib = '/usr/local/lib'
|
podofo_lib = '/sw/lib'
|
||||||
magick_inc_dirs = consolidate('MAGICK_INC',
|
magick_inc_dirs = consolidate('MAGICK_INC',
|
||||||
'/Users/kovid/ImageMagick/include/ImageMagick')
|
'/sw/include/ImageMagick')
|
||||||
magick_lib_dirs = consolidate('MAGICK_LIB',
|
magick_lib_dirs = consolidate('MAGICK_LIB',
|
||||||
'/Users/kovid/ImageMagick/lib')
|
'/sw/lib')
|
||||||
magick_libs = ['MagickWand', 'MagickCore']
|
magick_libs = ['MagickWand', 'MagickCore']
|
||||||
png_inc_dirs = consolidate('PNG_INC_DIR', '/usr/local/include')
|
png_inc_dirs = consolidate('PNG_INC_DIR', '/sw/include')
|
||||||
png_lib_dirs = consolidate('PNG_LIB_DIR', '/usr/local/lib')
|
png_lib_dirs = consolidate('PNG_LIB_DIR', '/sw/lib')
|
||||||
png_libs = ['png12']
|
png_libs = ['png12']
|
||||||
else:
|
else:
|
||||||
# Include directories
|
# Include directories
|
||||||
|
@ -83,7 +83,7 @@ linux_freeze2 = LinuxFreeze2()
|
|||||||
from setup.installer.osx import OSX, OSX32
|
from setup.installer.osx import OSX, OSX32
|
||||||
osx = OSX()
|
osx = OSX()
|
||||||
osx32 = OSX32()
|
osx32 = OSX32()
|
||||||
from setup.installer.osx.freeze import OSX32_Freeze
|
from setup.installer.osx.app.main import OSX32_Freeze
|
||||||
osx32_freeze = OSX32_Freeze()
|
osx32_freeze = OSX32_Freeze()
|
||||||
|
|
||||||
from setup.installer.windows import Win, Win32
|
from setup.installer.windows import Win, Win32
|
||||||
|
@ -15,7 +15,7 @@ from setup import Command, islinux, isosx, SRC, iswindows
|
|||||||
from setup.build_environment import fc_inc, fc_lib, \
|
from setup.build_environment import fc_inc, fc_lib, \
|
||||||
fc_error, poppler_libs, poppler_lib_dirs, poppler_inc_dirs, podofo_inc, \
|
fc_error, poppler_libs, poppler_lib_dirs, poppler_inc_dirs, podofo_inc, \
|
||||||
podofo_lib, podofo_error, poppler_error, pyqt, OSX_SDK, NMAKE, \
|
podofo_lib, podofo_error, poppler_error, pyqt, OSX_SDK, NMAKE, \
|
||||||
leopard_build, QMAKE, msvc, MT, win_inc, win_lib, png_inc_dirs, \
|
QMAKE, msvc, MT, win_inc, win_lib, png_inc_dirs, \
|
||||||
magick_inc_dirs, magick_lib_dirs, png_lib_dirs, png_libs, \
|
magick_inc_dirs, magick_lib_dirs, png_lib_dirs, png_libs, \
|
||||||
magick_error, magick_libs, ft_lib_dirs, ft_libs, jpg_libs, jpg_lib_dirs
|
magick_error, magick_libs, ft_lib_dirs, ft_libs, jpg_libs, jpg_lib_dirs
|
||||||
MT
|
MT
|
||||||
@ -156,7 +156,7 @@ if islinux:
|
|||||||
|
|
||||||
|
|
||||||
if isosx:
|
if isosx:
|
||||||
x, p = ('x86_64', 'ppc64') if leopard_build else ('i386', 'ppc')
|
x, p = ('i386', 'ppc')
|
||||||
archs = ['-arch', x, '-arch', p, '-isysroot',
|
archs = ['-arch', x, '-arch', p, '-isysroot',
|
||||||
OSX_SDK]
|
OSX_SDK]
|
||||||
cflags.append('-D_OSX')
|
cflags.append('-D_OSX')
|
||||||
@ -305,7 +305,7 @@ class Build(Command):
|
|||||||
obj_pat = 'release\\*.obj' if iswindows else '*.o'
|
obj_pat = 'release\\*.obj' if iswindows else '*.o'
|
||||||
objects = glob.glob(obj_pat)
|
objects = glob.glob(obj_pat)
|
||||||
if not objects or self.newer(objects, ext.sources+ext.headers):
|
if not objects or self.newer(objects, ext.sources+ext.headers):
|
||||||
archs = 'x86_64 ppc64' if leopard_build else 'x86 ppc'
|
archs = 'x86 ppc'
|
||||||
pro = textwrap.dedent('''\
|
pro = textwrap.dedent('''\
|
||||||
TARGET = %s
|
TARGET = %s
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
@ -316,9 +316,6 @@ class Build(Command):
|
|||||||
''')%(ext.name, ' '.join(ext.headers), ' '.join(ext.sources), archs)
|
''')%(ext.name, ' '.join(ext.headers), ' '.join(ext.sources), archs)
|
||||||
open(ext.name+'.pro', 'wb').write(pro)
|
open(ext.name+'.pro', 'wb').write(pro)
|
||||||
subprocess.check_call([QMAKE, '-o', 'Makefile', ext.name+'.pro'])
|
subprocess.check_call([QMAKE, '-o', 'Makefile', ext.name+'.pro'])
|
||||||
if leopard_build:
|
|
||||||
raw = open('Makefile', 'rb').read()
|
|
||||||
open('Makefile', 'wb').write(raw.replace('ppc64', 'x86_64'))
|
|
||||||
subprocess.check_call([make, '-f', 'Makefile'])
|
subprocess.check_call([make, '-f', 'Makefile'])
|
||||||
objects = glob.glob(obj_pat)
|
objects = glob.glob(obj_pat)
|
||||||
return list(map(self.a, objects))
|
return list(map(self.a, objects))
|
||||||
@ -354,12 +351,6 @@ class Build(Command):
|
|||||||
makefile.extra_lflags = qt_objects
|
makefile.extra_lflags = qt_objects
|
||||||
makefile.extra_include_dirs = ext.inc_dirs
|
makefile.extra_include_dirs = ext.inc_dirs
|
||||||
makefile.generate()
|
makefile.generate()
|
||||||
if leopard_build:
|
|
||||||
raw = open(mf, 'rb').read()
|
|
||||||
raw = raw.replace('ppc64 x86_64', 'x86_64')
|
|
||||||
for x in ('ppc64', 'ppc', 'i386'):
|
|
||||||
raw = raw.replace(x, 'x86_64')
|
|
||||||
open(mf, 'wb').write(raw)
|
|
||||||
|
|
||||||
subprocess.check_call([make, '-f', mf], cwd=src_dir)
|
subprocess.check_call([make, '-f', mf], cwd=src_dir)
|
||||||
shutil.copy2(module, dest)
|
shutil.copy2(module, dest)
|
||||||
|
@ -25,8 +25,9 @@ class OSX32(VMInstaller):
|
|||||||
description = 'Build 32 bit OS X binary installer'
|
description = 'Build 32 bit OS X binary installer'
|
||||||
|
|
||||||
INSTALLER_EXT = 'dmg'
|
INSTALLER_EXT = 'dmg'
|
||||||
VM_NAME = 'tiger_build'
|
VM_NAME = 'leopard_build'
|
||||||
VM = '/vmware/bin/%s'%VM_NAME
|
VM = '/vmware/bin/%s'%VM_NAME
|
||||||
|
FREEZE_TEMPLATE = 'python -OO setup.py {freeze_command}'
|
||||||
FREEZE_COMMAND = 'osx32_freeze'
|
FREEZE_COMMAND = 'osx32_freeze'
|
||||||
BUILD_PREFIX = VMInstaller.BUILD_PREFIX + ['source ~/.profile']
|
BUILD_PREFIX = VMInstaller.BUILD_PREFIX + ['source ~/.profile']
|
||||||
SHUTDOWN_CMD = ['sudo', 'halt']
|
SHUTDOWN_CMD = ['sudo', 'halt']
|
||||||
|
@ -13,9 +13,13 @@ abspath, join, basename = os.path.abspath, os.path.join, os.path.basename
|
|||||||
from setup import __version__ as VERSION, __appname__ as APPNAME, basenames, \
|
from setup import __version__ as VERSION, __appname__ as APPNAME, basenames, \
|
||||||
modules as main_modules, Command, SRC, functions as main_functions
|
modules as main_modules, Command, SRC, functions as main_functions
|
||||||
LICENSE = open('LICENSE', 'rb').read()
|
LICENSE = open('LICENSE', 'rb').read()
|
||||||
|
MAGICK_HOME='@executable_path/../Frameworks/ImageMagick'
|
||||||
ENV = dict(
|
ENV = dict(
|
||||||
FC_CONFIG_DIR='@executable_path/../Resources/fonts',
|
FC_CONFIG_DIR='@executable_path/../Resources/fonts',
|
||||||
MAGICK_HOME='@executable_path/../Frameworks/ImageMagick',
|
FC_CONFIG_FILE='@executable_path/../Resources/fonts/fonts.conf',
|
||||||
|
MAGICK_CONFIGURE_PATH=MAGICK_HOME+'/config',
|
||||||
|
MAGICK_CODER_MODULE_PATH=MAGICK_HOME+'/modules-Q16/coders',
|
||||||
|
MAGICK_CODER_FILTER_PATH=MAGICK_HOME+'/modules-Q16/filter',
|
||||||
QT_PLUGIN_PATH='@executable_path/../MacOS',
|
QT_PLUGIN_PATH='@executable_path/../MacOS',
|
||||||
PYTHONIOENCODING='UTF-8',
|
PYTHONIOENCODING='UTF-8',
|
||||||
)
|
)
|
||||||
@ -46,9 +50,9 @@ def compile_launcher_lib(contents_dir, gcc, base):
|
|||||||
src = join(base, 'util.c')
|
src = join(base, 'util.c')
|
||||||
cmd = [gcc] + '-Wall -arch i386 -arch ppc -dynamiclib -std=gnu99'.split() + [src] + \
|
cmd = [gcc] + '-Wall -arch i386 -arch ppc -dynamiclib -std=gnu99'.split() + [src] + \
|
||||||
['-I'+base] + \
|
['-I'+base] + \
|
||||||
['-I%s/python/Python.framework/Headers'%SW] + \
|
['-I/Library/Frameworks/Python.framework/Versions/Current/Headers'] + \
|
||||||
'-current_version 1.0 -compatibility_version 1.0'.split() + \
|
'-current_version 1.0 -compatibility_version 1.0'.split() + \
|
||||||
'-fvisibility=hidden -o'.split() + [dest, '-F%s/python'%SW] + \
|
'-fvisibility=hidden -o'.split() + [dest] + \
|
||||||
['-install_name',
|
['-install_name',
|
||||||
'@executable_path/../Frameworks/'+os.path.basename(dest)] + \
|
'@executable_path/../Frameworks/'+os.path.basename(dest)] + \
|
||||||
['-framework', 'Python', '-framework', 'CoreFoundation', '-headerpad_max_install_names']
|
['-framework', 'Python', '-framework', 'CoreFoundation', '-headerpad_max_install_names']
|
||||||
@ -176,6 +180,8 @@ class Py2App(object):
|
|||||||
self.create_plist()
|
self.create_plist()
|
||||||
|
|
||||||
self.add_python_framework()
|
self.add_python_framework()
|
||||||
|
self.add_site_packages()
|
||||||
|
self.add_stdlib()
|
||||||
self.add_qt_frameworks()
|
self.add_qt_frameworks()
|
||||||
self.add_calibre_plugins()
|
self.add_calibre_plugins()
|
||||||
self.add_podofo()
|
self.add_podofo()
|
||||||
@ -186,8 +192,6 @@ class Py2App(object):
|
|||||||
self.add_imagemagick()
|
self.add_imagemagick()
|
||||||
self.add_misc_libraries()
|
self.add_misc_libraries()
|
||||||
|
|
||||||
self.add_site_packages()
|
|
||||||
self.add_stdlib()
|
|
||||||
self.add_resources()
|
self.add_resources()
|
||||||
self.compile_py_modules()
|
self.compile_py_modules()
|
||||||
|
|
||||||
@ -262,8 +266,10 @@ class Py2App(object):
|
|||||||
def get_local_dependencies(self, path_to_lib):
|
def get_local_dependencies(self, path_to_lib):
|
||||||
for x in self.get_dependencies(path_to_lib):
|
for x in self.get_dependencies(path_to_lib):
|
||||||
for y in (SW+'/lib/', '/usr/local/lib/', SW+'/qt/lib/',
|
for y in (SW+'/lib/', '/usr/local/lib/', SW+'/qt/lib/',
|
||||||
SW+'/python/', SW+'/freetype/lib/'):
|
'/Library/Frameworks/Python.framework/', SW+'/freetype/lib/'):
|
||||||
if x.startswith(y):
|
if x.startswith(y):
|
||||||
|
if y == '/Library/Frameworks/Python.framework/':
|
||||||
|
y = '/Library/Frameworks/'
|
||||||
yield x, x[len(y):]
|
yield x, x[len(y):]
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -289,7 +295,7 @@ class Py2App(object):
|
|||||||
@flush
|
@flush
|
||||||
def add_python_framework(self):
|
def add_python_framework(self):
|
||||||
info('\nAdding Python framework')
|
info('\nAdding Python framework')
|
||||||
src = join(SW, 'python', 'Python.framework')
|
src = join('/Library/Frameworks', 'Python.framework')
|
||||||
x = join(self.frameworks_dir, 'Python.framework')
|
x = join(self.frameworks_dir, 'Python.framework')
|
||||||
curr = os.path.realpath(join(src, 'Versions', 'Current'))
|
curr = os.path.realpath(join(src, 'Versions', 'Current'))
|
||||||
currd = join(x, 'Versions', basename(curr))
|
currd = join(x, 'Versions', basename(curr))
|
||||||
@ -302,6 +308,7 @@ class Py2App(object):
|
|||||||
|
|
||||||
@flush
|
@flush
|
||||||
def add_qt_frameworks(self):
|
def add_qt_frameworks(self):
|
||||||
|
info('\nAdding Qt Framework')
|
||||||
for f in ('QtCore', 'QtGui', 'QtXml', 'QtNetwork', 'QtSvg', 'QtWebkit',
|
for f in ('QtCore', 'QtGui', 'QtXml', 'QtNetwork', 'QtSvg', 'QtWebkit',
|
||||||
'QtXmlPatterns', 'phonon'):
|
'QtXmlPatterns', 'phonon'):
|
||||||
self.add_qt_framework(f)
|
self.add_qt_framework(f)
|
||||||
@ -360,7 +367,7 @@ class Py2App(object):
|
|||||||
CFBundlePackageType='APPL',
|
CFBundlePackageType='APPL',
|
||||||
CFBundleSignature='????',
|
CFBundleSignature='????',
|
||||||
CFBundleExecutable='calibre',
|
CFBundleExecutable='calibre',
|
||||||
LSMinimumSystemVersion='10.5.2',
|
LSMinimumSystemVersion='10.4.2',
|
||||||
LSRequiresNativeExecution=True,
|
LSRequiresNativeExecution=True,
|
||||||
NSAppleScriptEnabled=False,
|
NSAppleScriptEnabled=False,
|
||||||
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
|
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
|
||||||
@ -433,10 +440,7 @@ class Py2App(object):
|
|||||||
for x in ('Wand', 'Core'):
|
for x in ('Wand', 'Core'):
|
||||||
self.install_dylib(os.path.join(SW, 'lib', 'libMagick%s.2.dylib'%x))
|
self.install_dylib(os.path.join(SW, 'lib', 'libMagick%s.2.dylib'%x))
|
||||||
idir = glob.glob(os.path.join(SW, 'lib', 'ImageMagick-*'))[-1]
|
idir = glob.glob(os.path.join(SW, 'lib', 'ImageMagick-*'))[-1]
|
||||||
dest = os.path.join(self.frameworks_dir, 'ImageMagick', 'lib')
|
dest = os.path.join(self.frameworks_dir, 'ImageMagick')
|
||||||
if not os.path.exists(dest):
|
|
||||||
os.makedirs(dest)
|
|
||||||
dest = os.path.join(dest, os.path.basename(idir))
|
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
shutil.rmtree(dest)
|
shutil.rmtree(dest)
|
||||||
shutil.copytree(idir, dest, True)
|
shutil.copytree(idir, dest, True)
|
||||||
@ -461,12 +465,12 @@ class Py2App(object):
|
|||||||
paths = reversed(map(abspath, [x for x in sys.path if x.startswith('/')]))
|
paths = reversed(map(abspath, [x for x in sys.path if x.startswith('/')]))
|
||||||
upaths = []
|
upaths = []
|
||||||
for x in paths:
|
for x in paths:
|
||||||
if x.endswith('/PIL') or 'site-packages' not in x:
|
if x not in upaths and (x.endswith('.egg') or
|
||||||
continue
|
x.endswith('/site-packages')):
|
||||||
if x not in upaths:
|
|
||||||
upaths.append(x)
|
upaths.append(x)
|
||||||
upaths.append(os.path.expanduser('~/build/calibre/src'))
|
upaths.append(os.path.expanduser('~/build/calibre/src'))
|
||||||
for x in upaths:
|
for x in upaths:
|
||||||
|
info('\t', x)
|
||||||
tdir = None
|
tdir = None
|
||||||
try:
|
try:
|
||||||
if not os.path.isdir(x):
|
if not os.path.isdir(x):
|
||||||
@ -536,7 +540,7 @@ class Py2App(object):
|
|||||||
@flush
|
@flush
|
||||||
def add_stdlib(self):
|
def add_stdlib(self):
|
||||||
info('\nAdding python stdlib')
|
info('\nAdding python stdlib')
|
||||||
src = join(SW, 'python/Python.framework/Versions/Current/lib/python')
|
src = '/Library/Frameworks/Python.framework/Versions/Current/lib/python'
|
||||||
src += self.version_info
|
src += self.version_info
|
||||||
dest = join(self.resources_dir, 'Python', 'lib', 'python')
|
dest = join(self.resources_dir, 'Python', 'lib', 'python')
|
||||||
dest += self.version_info
|
dest += self.version_info
|
||||||
|
@ -381,9 +381,9 @@ class FlowSplitter(object):
|
|||||||
p[i:i+1] = new_pres
|
p[i:i+1] = new_pres
|
||||||
|
|
||||||
split_point, before = self.find_split_point(root)
|
split_point, before = self.find_split_point(root)
|
||||||
self.log.debug('\t\t\tSplit point:', split_point.tag, tree.getpath(split_point))
|
|
||||||
if split_point is None:
|
if split_point is None:
|
||||||
raise SplitError(self.item.href, root)
|
raise SplitError(self.item.href, root)
|
||||||
|
self.log.debug('\t\t\tSplit point:', split_point.tag, tree.getpath(split_point))
|
||||||
|
|
||||||
for t in self.do_split(tree, split_point, before):
|
for t in self.do_split(tree, split_point, before):
|
||||||
r = t.getroot()
|
r = t.getroot()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user