2012-07-28 20:22:51 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2012-08-30 19:35:18 +00:00
|
|
|
import sys
|
2012-07-28 20:22:51 +00:00
|
|
|
import os
|
|
|
|
import os.path as op
|
|
|
|
|
|
|
|
top = '.'
|
|
|
|
out = 'build'
|
|
|
|
|
|
|
|
def options(opt):
|
|
|
|
opt.load('compiler_c python')
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
# We use clang to compile our app
|
|
|
|
conf.env.CC = 'clang'
|
|
|
|
# WAF has a "pyembed" feature allowing us to automatically find Python and compile by linking
|
|
|
|
# to it. The problem is that because we made a copy of the Python library to mangle with its
|
|
|
|
# "install name", we don't actually want to link to our installed python, but to our mangled
|
|
|
|
# Python. The line below tells the "pyembed" WAF feature to look in ../build for Python.
|
|
|
|
conf.env.LIBPATH_PYEMBED = op.abspath('../build')
|
|
|
|
# I did a lot of fiddling-around, but I didn't find how to tell WAF the Python library name
|
|
|
|
# to look for without making the whole compilation process fail, so I just create a symlink
|
|
|
|
# with the name WAF is looking for.
|
2016-07-01 23:50:19 +00:00
|
|
|
versioned_dylib_path = '../build/libpython{}m.dylib'.format(sys.version[:3])
|
2012-08-30 19:35:18 +00:00
|
|
|
if not op.exists(versioned_dylib_path):
|
|
|
|
os.symlink('../build/Python', versioned_dylib_path)
|
2012-07-28 20:22:51 +00:00
|
|
|
# The rest is standard WAF code that you can find the the python and macapp demos.
|
|
|
|
conf.load('compiler_c python')
|
2016-06-06 01:18:48 +00:00
|
|
|
conf.check_python_version((3,4,0))
|
2012-07-28 20:22:51 +00:00
|
|
|
conf.check_python_headers()
|
|
|
|
conf.env.FRAMEWORK_COCOA = 'Cocoa'
|
2013-07-28 20:39:53 +00:00
|
|
|
conf.env.ARCH_COCOA = ['x86_64']
|
2016-07-01 19:36:15 +00:00
|
|
|
conf.env.MACOSX_DEPLOYMENT_TARGET = '10.8'
|
2016-06-08 17:28:52 +00:00
|
|
|
conf.env.CFLAGS = ['-F'+op.abspath('Sparkle/build/Release')]
|
|
|
|
conf.env.LINKFLAGS = ['-F'+op.abspath('Sparkle/build/Release')]
|
2012-07-28 20:22:51 +00:00
|
|
|
|
|
|
|
def build(ctx):
|
|
|
|
# What do we compile?
|
|
|
|
cocoalib_node = ctx.srcnode.find_dir('..').find_dir('cocoalib')
|
2012-07-28 20:49:36 +00:00
|
|
|
cocoalib_folders = ['controllers', 'views']
|
2012-07-28 20:22:51 +00:00
|
|
|
cocoalib_includes = [cocoalib_node] + [cocoalib_node.find_dir(folder) for folder in cocoalib_folders]
|
2013-11-30 22:54:40 +00:00
|
|
|
cocoalib_uses = ['NSEventAdditions', 'Dialogs', 'HSAboutBox', 'Utils',
|
2012-07-28 20:22:51 +00:00
|
|
|
'HSPyUtil', 'ProgressController', 'HSRecentFiles', 'HSQuicklook', 'ValueTransformers',
|
2012-07-29 15:01:28 +00:00
|
|
|
'NSImageAdditions', 'NSNotificationAdditions',
|
2012-07-28 20:22:51 +00:00
|
|
|
'views/HSTableView', 'views/HSOutlineView', 'views/NSIndexPathAdditions',
|
|
|
|
'views/NSTableViewAdditions',
|
|
|
|
'controllers/HSColumns', 'controllers/HSGUIController', 'controllers/HSTable',
|
2013-08-03 20:27:36 +00:00
|
|
|
'controllers/HSOutline', 'controllers/HSPopUpList', 'controllers/HSSelectableList',
|
|
|
|
'controllers/HSTextField', 'controllers/HSProgressWindow']
|
2012-07-28 20:22:51 +00:00
|
|
|
cocoalib_src = [cocoalib_node.find_node(usename + '.m') for usename in cocoalib_uses] + cocoalib_node.ant_glob('autogen/*.m')
|
2016-06-06 01:18:48 +00:00
|
|
|
project_folders = [ctx.srcnode, ctx.srcnode.find_dir('autogen')]
|
|
|
|
project_src = ctx.srcnode.ant_glob('autogen/*.m') + ctx.srcnode.ant_glob('*.m')
|
2012-07-28 20:22:51 +00:00
|
|
|
|
|
|
|
# Compile
|
|
|
|
ctx.program(
|
|
|
|
# "pyembed" takes care of the include and linking stuff to compile an app that embed Python.
|
|
|
|
features = 'c cprogram pyembed',
|
|
|
|
target = ctx.bldnode.make_node("dupeGuru"),
|
|
|
|
source = cocoalib_src + project_src,
|
|
|
|
includes = project_folders + cocoalib_includes,
|
|
|
|
use = 'COCOA',
|
|
|
|
# Because our python lib's install name is "@rpath/Python", we need to set the executable's
|
|
|
|
# rpath. Fortunately, WAF supports it and we just need to supply the "rpath" argument.
|
|
|
|
rpath = '@executable_path/../Frameworks',
|
|
|
|
framework = ['Sparkle', 'Quartz'],
|
|
|
|
)
|
|
|
|
|
|
|
|
from waflib import TaskGen
|
|
|
|
@TaskGen.extension('.m')
|
|
|
|
def m_hook(self, node):
|
|
|
|
"""Alias .m files to be compiled the same as .c files, gcc will do the right thing."""
|
|
|
|
return self.create_compiled_task('c', node)
|
|
|
|
|