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): |
| 9 | self.check_cxx (framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"], |
| 10 | uselib_store='OSX_SPARKLE', define_name='HAVE_SPARKLE', |
| 11 | compile_filename='test.mm', use="OSX_FOUNDATION OSX_APPKIT", |
| 12 | *k, |
| 13 | **kw |
| 14 | ) |
| 15 | |
| 16 | @conf |
| 17 | def 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") |
| 48 | def configure(conf): |
| 49 | conf.check_sparkle () |