blob: 2b0958acb0ff917212bd0e93d02d65744e8b7a1e [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):
Alexander Afanasyevb6392e32014-05-12 23:43:50 -07009 self.check_cxx(framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"],
10 uselib_store='SPARKLE', define_name='HAVE_SPARKLE',
11 compile_filename='test.mm', use="FOUNDATION APPKIT",
12 *k,
13 **kw
14 )
Alexander Afanasyev749f0652013-09-22 13:03:21 -070015
16@conf
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070017def check_sparkle(self, *k, **kw):
Alexander Afanasyev749f0652013-09-22 13:03:21 -070018 try:
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070019 self.check_sparkle_base(*k, **kw)
Alexander Afanasyev749f0652013-09-22 13:03:21 -070020 except:
21 try:
22 # Try local path
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070023 # Logs.info("Check local version of Sparkle framework")
24 self.check_sparkle_base(cxxflags="-F%s/Frameworks/" % self.path.abspath(),
25 linkflags="-F%s/Frameworks/" % self.path.abspath())
Alexander Afanasyev749f0652013-09-22 13:03:21 -070026 except:
27 import urllib, subprocess, os, shutil
28 if not os.path.exists('osx/Frameworks/Sparkle.framework'):
29 # Download to local path and retry
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070030 Logs.info("Sparkle framework not found, trying to download it to 'build/'")
Alexander Afanasyev749f0652013-09-22 13:03:21 -070031
Alexander Afanasyeva16abd62014-07-14 11:14:29 -070032 urllib.urlretrieve("https://github.com/sparkle-project/Sparkle/releases/download/1.7.1/Sparkle-1.7.1.zip", "build/Sparkle.zip")
Alexander Afanasyev749f0652013-09-22 13:03:21 -070033 if os.path.exists('build/Sparkle.zip'):
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070034 # try:
35 subprocess.check_call(['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle'])
36 os.remove("build/Sparkle.zip")
Alexander Afanasyev749f0652013-09-22 13:03:21 -070037 if not os.path.exists("osx/Frameworks"):
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070038 os.mkdir("osx/Frameworks")
39 os.rename("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework")
Alexander Afanasyev749f0652013-09-22 13:03:21 -070040 shutil.rmtree("build/Sparkle", ignore_errors=True)
41
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070042 self.check_sparkle_base(cxxflags="-F%s/Frameworks/" % self.path.abspath(),
43 linkflags="-F%s/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")
Alexander Afanasyev749f0652013-09-22 13:03:21 -070048def configure(conf):
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070049 conf.check_sparkle()