blob: 3d628aa9bf5f62e136abf7d5198ba89b218f0cc5 [file] [log] [blame]
Alexander Afanasyev749f0652013-09-22 13:03:21 -07001#! /usr/bin/env python
2# encoding: utf-8
3
4from waflib import Logs
5from waflib.Configure import conf
6
7@conf
8def check_sparkle_base (self, *k, **kw):
9 self.check_cxx (framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"],
Alexander Afanasyev88f0b3a2013-09-24 23:52:08 -070010 uselib_store='SPARKLE', define_name='HAVE_SPARKLE',
11 compile_filename='test.mm', use="FOUNDATION APPKIT",
Alexander Afanasyev749f0652013-09-22 13:03:21 -070012 *k,
13 **kw
14 )
15
16@conf
17def check_sparkle (self, *k, **kw):
18 try:
19 self.check_sparkle_base (*k, **kw)
20 except:
21 try:
22 # Try local path
23 # Logs.info ("Check local version of Sparkle framework")
24 self.check_sparkle_base (cxxflags="-F%s/osx/Frameworks/" % self.path.abspath(),
25 linkflags="-F%s/osx/Frameworks/" % self.path.abspath())
26 except:
27 import urllib, subprocess, os, shutil
28 if not os.path.exists('osx/Frameworks/Sparkle.framework'):
29 # Download to local path and retry
30 Logs.info ("Sparkle framework not found, trying to download it to 'build/'")
31
32 urllib.urlretrieve ("http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip", "build/Sparkle.zip")
33 if os.path.exists('build/Sparkle.zip'):
34 try:
35 subprocess.check_call (['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle'])
36 os.remove ("build/Sparkle.zip")
37 if not os.path.exists("osx/Frameworks"):
38 os.mkdir ("osx/Frameworks")
39 os.rename ("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework")
40 shutil.rmtree("build/Sparkle", ignore_errors=True)
41
42 self.check_sparkle_base (cxxflags="-F%s/osx/Frameworks/" % self.path.abspath(),
43 linkflags="-F%s/osx/Frameworks/" % self.path.abspath())
44 except subprocess.CalledProcessError as e:
45 self.fatal("Cannot find Sparkle framework. Auto download failed: '%s' returned %s" % (' '.join(e.cmd), e.returncode))
46 except:
47 self.fatal("Unknown Error happened when auto downloading Sparkle framework")
48def configure(conf):
49 conf.check_sparkle ()