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')
|
2012-07-28 22:10:05 +00:00
|
|
|
opt.add_option('--edition', default='se', help="dupeGuru edition to build (se, me pe)")
|
2012-07-28 20:22:51 +00:00
|
|
|
|
|
|
|
def configure(conf):
|
2012-07-28 22:10:05 +00:00
|
|
|
if conf.options.edition not in ('se', 'me', 'pe'):
|
|
|
|
conf.options.edition = 'se'
|
|
|
|
print("Building dupeGuru {}".format(conf.options.edition.upper()))
|
|
|
|
conf.env.DGEDITION = conf.options.edition
|
2012-07-28 20:22:51 +00:00
|
|
|
# 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.
|
2012-08-30 19:35:18 +00:00
|
|
|
versioned_dylib_path = '../build/libpython{}.dylib'.format(sys.version[:3])
|
|
|
|
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')
|
2013-12-07 22:23:18 +00:00
|
|
|
conf.check_python_version((3,3,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']
|
2012-07-28 20:22:51 +00:00
|
|
|
# Add cocoalib dir to the framework search path so we can find Sparkle.
|
|
|
|
conf.env.CFLAGS = ['-F'+op.abspath('../cocoalib')]
|
|
|
|
conf.env.LINKFLAGS = ['-F'+op.abspath('../cocoalib')]
|
|
|
|
|
|
|
|
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')
|
2012-07-28 22:10:05 +00:00
|
|
|
project_folders = ['autogen', 'base', ctx.env.DGEDITION]
|
2012-07-28 20:22:51 +00:00
|
|
|
project_src = sum([ctx.srcnode.ant_glob('%s/*.m' % folder) for folder in project_folders], [])
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
|