Alexander Afanasyev | e83c056 | 2016-12-24 10:20:41 -0800 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | # encoding: utf-8 |
| 3 | |
| 4 | from waflib import Logs, Utils |
| 5 | from waflib.Configure import conf |
| 6 | |
| 7 | OSX_SECURITY_CODE=''' |
| 8 | #include <CoreFoundation/CoreFoundation.h> |
| 9 | #include <Security/Security.h> |
| 10 | #include <Security/SecRandom.h> |
| 11 | #include <CoreServices/CoreServices.h> |
| 12 | #include <Security/SecDigestTransform.h> |
| 13 | |
| 14 | int main(int argc, char **argv) { |
| 15 | (void)argc; (void)argv; |
| 16 | return 0; |
| 17 | } |
| 18 | ''' |
| 19 | |
| 20 | @conf |
| 21 | def configure(conf): |
| 22 | if Utils.unversioned_sys_platform () == "darwin": |
| 23 | conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', mandatory=False, compile_filename='test.mm') |
| 24 | conf.check_cxx(framework_name='AppKit', uselib_store='OSX_APPKIT', mandatory=False, compile_filename='test.mm') |
| 25 | conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', define_name='HAVE_COREWLAN', |
| 26 | use="OSX_FOUNDATION", mandatory=False, compile_filename='test.mm') |
| 27 | |
| 28 | if conf.options.autoupdate: |
| 29 | def check_sparkle(**kwargs): |
| 30 | conf.check_cxx (framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"], |
| 31 | uselib_store='OSX_SPARKLE', define_name='HAVE_SPARKLE', mandatory=True, |
| 32 | compile_filename='test.mm', use="OSX_FOUNDATION OSX_APPKIT", |
| 33 | **kwargs |
| 34 | ) |
| 35 | try: |
| 36 | # Try standard paths first |
| 37 | check_sparkle() |
| 38 | except: |
| 39 | try: |
| 40 | # Try local path |
| 41 | Logs.info ("Check local version of Sparkle framework") |
| 42 | check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(), |
| 43 | linkflags="-F%s/osx/Frameworks/" % conf.path.abspath()) |
| 44 | conf.env.HAVE_LOCAL_SPARKLE = 1 |
| 45 | except: |
| 46 | import urllib, subprocess, os, shutil |
| 47 | if not os.path.exists('osx/Frameworks/Sparkle.framework'): |
| 48 | # Download to local path and retry |
| 49 | Logs.info ("Sparkle framework not found, trying to download it to 'build/'") |
| 50 | |
| 51 | urllib.urlretrieve ("http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip", "build/Sparkle.zip") |
| 52 | if os.path.exists('build/Sparkle.zip'): |
| 53 | try: |
| 54 | subprocess.check_call (['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle']) |
| 55 | os.remove ("build/Sparkle.zip") |
| 56 | if not os.path.exists("osx/Frameworks"): |
| 57 | os.mkdir ("osx/Frameworks") |
| 58 | os.rename ("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework") |
| 59 | shutil.rmtree("build/Sparkle", ignore_errors=True) |
| 60 | |
| 61 | check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(), |
| 62 | linkflags="-F%s/osx/Frameworks/" % conf.path.abspath()) |
| 63 | conf.env.HAVE_LOCAL_SPARKLE = 1 |
| 64 | except subprocess.CalledProcessError as e: |
| 65 | conf.fatal("Cannot find Sparkle framework. Auto download failed: '%s' returned %s" % (' '.join(e.cmd), e.returncode)) |
| 66 | except: |
| 67 | conf.fatal("Unknown Error happened when auto downloading Sparkle framework") |
| 68 | |
| 69 | if conf.is_defined('HAVE_SPARKLE'): |
| 70 | conf.env.HAVE_SPARKLE = 1 # small cheat for wscript |