blob: 9936778c74259455adeabe35f36e0b0a1c928300 [file] [log] [blame]
Alexander Afanasyevfda42a82017-02-01 18:03:39 -08001#! /usr/bin/env python
2# encoding: utf-8
3
4from waflib import Logs, Utils
5from waflib.Configure import conf
6
7OSX_SECURITY_CODE='''
8#import <AppKit/AppKit.h>
9#import <Foundation/Foundation.h>
10#import <Sparkle/Sparkle.h>
11#import <CoreWLAN/CWInterface.h>
12#import <CoreWLAN/CoreWLAN.h>
13#import <CoreWLAN/CoreWLANConstants.h>
14#import <CoreWLAN/CoreWLANTypes.h>
15int main() { }
16'''
17
18@conf
19def configure(conf):
20 if Utils.unversioned_sys_platform () == "darwin":
21 conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', mandatory=False, compile_filename='test.mm')
22 conf.check_cxx(framework_name='AppKit', uselib_store='OSX_APPKIT', mandatory=False, compile_filename='test.mm')
23 conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', define_name='HAVE_COREWLAN',
24 use="OSX_FOUNDATION", mandatory=False, compile_filename='test.mm')
25
26 def check_sparkle(**kwargs):
27 conf.check_cxx(framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"],
28 uselib_store='OSX_SPARKLE', define_name='HAVE_SPARKLE', mandatory=True,
29 compile_filename='test.mm', use="OSX_FOUNDATION OSX_APPKIT",
30 **kwargs
31 )
32 try:
33 # Try standard paths first
34 check_sparkle()
35 except:
36 try:
37 # Try local path
38 Logs.info ("Check local version of Sparkle framework")
39 check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(),
40 linkflags="-F%s/osx/Frameworks/" % conf.path.abspath())
41 conf.env.HAVE_LOCAL_SPARKLE = 1
42 except:
43 import urllib, subprocess, os, shutil
44 if not os.path.exists('osx/Frameworks/Sparkle.framework'):
45 # Download to local path and retry
46 Logs.info ("Sparkle framework not found, trying to download it to 'build/'")
47
48 urllib.urlretrieve ("https://github.com/sparkle-project/Sparkle/releases/download/1.16.0/Sparkle-1.16.0.tar.bz2", "build/Sparkle.tar.bz2")
49 if os.path.exists('build/Sparkle.tar.bz2'):
50 try:
51 subprocess.check_call(['mkdir', 'build/Sparkle'])
52 subprocess.check_call(['tar', 'xjf', 'build/Sparkle.tar.bz2', '-C', 'build/Sparkle'])
53 os.remove("build/Sparkle.tar.bz2")
54 if not os.path.exists("osx/Frameworks"):
55 os.mkdir ("osx/Frameworks")
56 os.rename("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework")
Alexander Afanasyevfda42a82017-02-01 18:03:39 -080057
58 check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(),
59 linkflags="-F%s/osx/Frameworks/" % conf.path.abspath())
60 conf.env.HAVE_LOCAL_SPARKLE = 1
61 except subprocess.CalledProcessError as e:
62 conf.fatal("Cannot find Sparkle framework. Auto download failed: '%s' returned %s" % (' '.join(e.cmd), e.returncode))
63 except:
64 conf.fatal("Unknown Error happened when auto downloading Sparkle framework")
65
66 conf.env['LDFLAGS_OSX_SPARKLE'] += ['-Wl,-rpath,@loader_path/../Frameworks']
67 if conf.is_defined('HAVE_SPARKLE'):
68 conf.env.HAVE_SPARKLE = 1 # small cheat for wscript