Switch build system to use new OS X build

This commit is contained in:
Kovid Goyal 2009-12-22 09:52:42 -07:00
parent 96e76fb230
commit 2213a4648a
6 changed files with 39 additions and 46 deletions

View File

@ -13,12 +13,9 @@ from PyQt4 import pyqtconfig
from setup import isosx, iswindows, islinux
OSX_SDK = '/Developer/SDKs/MacOSX10.5.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
if iswindows:
@ -117,24 +114,24 @@ if iswindows:
podofo_inc = os.path.join(sw_inc_dir, 'podofo')
podofo_lib = sw_lib_dir
elif isosx:
fc_inc = '/Users/kovid/fontconfig/include/fontconfig'
fc_lib = '/Users/kovid/fontconfig/lib'
fc_inc = '/sw/include/fontconfig'
fc_lib = '/sw/lib'
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']
poppler_lib_dirs = consolidate('POPPLER_LIB_DIR',
'/Volumes/sw/lib')
'/sw/lib')
popplerqt4_lib_dirs = poppler_lib_dirs
poppler_libs = popplerqt4_libs = ['poppler']
podofo_inc = '/usr/local/include/podofo'
podofo_lib = '/usr/local/lib'
podofo_inc = '/sw/podofo'
podofo_lib = '/sw/lib'
magick_inc_dirs = consolidate('MAGICK_INC',
'/Users/kovid/ImageMagick/include/ImageMagick')
'/sw/include/ImageMagick')
magick_lib_dirs = consolidate('MAGICK_LIB',
'/Users/kovid/ImageMagick/lib')
'/sw/lib')
magick_libs = ['MagickWand', 'MagickCore']
png_inc_dirs = consolidate('PNG_INC_DIR', '/usr/local/include')
png_lib_dirs = consolidate('PNG_LIB_DIR', '/usr/local/lib')
png_inc_dirs = consolidate('PNG_INC_DIR', '/sw/include')
png_lib_dirs = consolidate('PNG_LIB_DIR', '/sw/lib')
png_libs = ['png12']
else:
# Include directories

View File

@ -83,7 +83,7 @@ linux_freeze2 = LinuxFreeze2()
from setup.installer.osx import OSX, OSX32
osx = OSX()
osx32 = OSX32()
from setup.installer.osx.freeze import OSX32_Freeze
from setup.installer.osx.app.main import OSX32_Freeze
osx32_freeze = OSX32_Freeze()
from setup.installer.windows import Win, Win32

View File

@ -15,7 +15,7 @@ from setup import Command, islinux, isosx, SRC, iswindows
from setup.build_environment import fc_inc, fc_lib, \
fc_error, poppler_libs, poppler_lib_dirs, poppler_inc_dirs, podofo_inc, \
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_error, magick_libs, ft_lib_dirs, ft_libs, jpg_libs, jpg_lib_dirs
MT
@ -156,7 +156,7 @@ if islinux:
if isosx:
x, p = ('x86_64', 'ppc64') if leopard_build else ('i386', 'ppc')
x, p = ('i386', 'ppc')
archs = ['-arch', x, '-arch', p, '-isysroot',
OSX_SDK]
cflags.append('-D_OSX')
@ -305,7 +305,7 @@ class Build(Command):
obj_pat = 'release\\*.obj' if iswindows else '*.o'
objects = glob.glob(obj_pat)
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('''\
TARGET = %s
TEMPLATE = lib
@ -316,9 +316,6 @@ class Build(Command):
''')%(ext.name, ' '.join(ext.headers), ' '.join(ext.sources), archs)
open(ext.name+'.pro', 'wb').write(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'])
objects = glob.glob(obj_pat)
return list(map(self.a, objects))
@ -354,12 +351,6 @@ class Build(Command):
makefile.extra_lflags = qt_objects
makefile.extra_include_dirs = ext.inc_dirs
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)
shutil.copy2(module, dest)

View File

@ -25,8 +25,9 @@ class OSX32(VMInstaller):
description = 'Build 32 bit OS X binary installer'
INSTALLER_EXT = 'dmg'
VM_NAME = 'tiger_build'
VM_NAME = 'leopard_build'
VM = '/vmware/bin/%s'%VM_NAME
FREEZE_TEMPLATE = 'python -OO setup.py {freeze_command}'
FREEZE_COMMAND = 'osx32_freeze'
BUILD_PREFIX = VMInstaller.BUILD_PREFIX + ['source ~/.profile']
SHUTDOWN_CMD = ['sudo', 'halt']

View File

@ -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, \
modules as main_modules, Command, SRC, functions as main_functions
LICENSE = open('LICENSE', 'rb').read()
MAGICK_HOME='@executable_path/../Frameworks/ImageMagick'
ENV = dict(
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',
PYTHONIOENCODING='UTF-8',
)
@ -46,9 +50,9 @@ def compile_launcher_lib(contents_dir, gcc, base):
src = join(base, 'util.c')
cmd = [gcc] + '-Wall -arch i386 -arch ppc -dynamiclib -std=gnu99'.split() + [src] + \
['-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() + \
'-fvisibility=hidden -o'.split() + [dest, '-F%s/python'%SW] + \
'-fvisibility=hidden -o'.split() + [dest] + \
['-install_name',
'@executable_path/../Frameworks/'+os.path.basename(dest)] + \
['-framework', 'Python', '-framework', 'CoreFoundation', '-headerpad_max_install_names']
@ -176,6 +180,8 @@ class Py2App(object):
self.create_plist()
self.add_python_framework()
self.add_site_packages()
self.add_stdlib()
self.add_qt_frameworks()
self.add_calibre_plugins()
self.add_podofo()
@ -186,8 +192,6 @@ class Py2App(object):
self.add_imagemagick()
self.add_misc_libraries()
self.add_site_packages()
self.add_stdlib()
self.add_resources()
self.compile_py_modules()
@ -262,8 +266,10 @@ class Py2App(object):
def get_local_dependencies(self, path_to_lib):
for x in self.get_dependencies(path_to_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 y == '/Library/Frameworks/Python.framework/':
y = '/Library/Frameworks/'
yield x, x[len(y):]
break
@ -289,7 +295,7 @@ class Py2App(object):
@flush
def add_python_framework(self):
info('\nAdding Python framework')
src = join(SW, 'python', 'Python.framework')
src = join('/Library/Frameworks', 'Python.framework')
x = join(self.frameworks_dir, 'Python.framework')
curr = os.path.realpath(join(src, 'Versions', 'Current'))
currd = join(x, 'Versions', basename(curr))
@ -302,6 +308,7 @@ class Py2App(object):
@flush
def add_qt_frameworks(self):
info('\nAdding Qt Framework')
for f in ('QtCore', 'QtGui', 'QtXml', 'QtNetwork', 'QtSvg', 'QtWebkit',
'QtXmlPatterns', 'phonon'):
self.add_qt_framework(f)
@ -360,7 +367,7 @@ class Py2App(object):
CFBundlePackageType='APPL',
CFBundleSignature='????',
CFBundleExecutable='calibre',
LSMinimumSystemVersion='10.5.2',
LSMinimumSystemVersion='10.4.2',
LSRequiresNativeExecution=True,
NSAppleScriptEnabled=False,
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
@ -433,10 +440,7 @@ class Py2App(object):
for x in ('Wand', 'Core'):
self.install_dylib(os.path.join(SW, 'lib', 'libMagick%s.2.dylib'%x))
idir = glob.glob(os.path.join(SW, 'lib', 'ImageMagick-*'))[-1]
dest = os.path.join(self.frameworks_dir, 'ImageMagick', 'lib')
if not os.path.exists(dest):
os.makedirs(dest)
dest = os.path.join(dest, os.path.basename(idir))
dest = os.path.join(self.frameworks_dir, 'ImageMagick')
if os.path.exists(dest):
shutil.rmtree(dest)
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('/')]))
upaths = []
for x in paths:
if x.endswith('/PIL') or 'site-packages' not in x:
continue
if x not in upaths:
if x not in upaths and (x.endswith('.egg') or
x.endswith('/site-packages')):
upaths.append(x)
upaths.append(os.path.expanduser('~/build/calibre/src'))
for x in upaths:
info('\t', x)
tdir = None
try:
if not os.path.isdir(x):
@ -536,7 +540,7 @@ class Py2App(object):
@flush
def add_stdlib(self):
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
dest = join(self.resources_dir, 'Python', 'lib', 'python')
dest += self.version_info

View File

@ -381,9 +381,9 @@ class FlowSplitter(object):
p[i:i+1] = new_pres
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:
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):
r = t.getroot()