Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | # encoding: utf-8 |
| 3 | |
| 4 | from waflib import Logs |
| 5 | from waflib.Configure import conf |
| 6 | |
| 7 | @conf |
| 8 | def check_sparkle_base (self, *k, **kw): |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 9 | 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 Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 15 | |
| 16 | @conf |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 17 | def check_sparkle(self, *k, **kw): |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 18 | try: |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 19 | self.check_sparkle_base(*k, **kw) |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 20 | except: |
| 21 | try: |
| 22 | # Try local path |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 23 | # 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 Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 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 |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 30 | Logs.info("Sparkle framework not found, trying to download it to 'build/'") |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 31 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 32 | urllib.urlretrieve("http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip", "build/Sparkle.zip") |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 33 | if os.path.exists('build/Sparkle.zip'): |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 34 | # try: |
| 35 | subprocess.check_call(['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle']) |
| 36 | os.remove("build/Sparkle.zip") |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 37 | if not os.path.exists("osx/Frameworks"): |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 38 | os.mkdir("osx/Frameworks") |
| 39 | os.rename("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework") |
Alexander Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 40 | shutil.rmtree("build/Sparkle", ignore_errors=True) |
| 41 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 42 | 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 Afanasyev | 749f065 | 2013-09-22 13:03:21 -0700 | [diff] [blame] | 48 | def configure(conf): |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame^] | 49 | conf.check_sparkle() |