|
1 | 1 | from kivy_ios.toolchain import Recipe, shprint
|
| 2 | +from os.path import join |
| 3 | +import os |
2 | 4 | import sh
|
3 | 5 |
|
4 | 6 |
|
5 | 7 | class LibSDL2Recipe(Recipe):
|
6 |
| - # version = "2.0.9" |
7 |
| - # url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz" |
8 |
| - version = "7cc4fc886d9e" |
9 |
| - url = "https://hg.libsdl.org/SDL/archive/{version}.tar.gz" |
10 |
| - library = "Xcode-iOS/SDL/build/Release-{arch.sdk}/libSDL2.a" |
| 8 | + version = "ios-use-metalangle" |
| 9 | + url = "https://github.com/misl6/SDL/archive/refs/heads/feature/{version}.zip" |
| 10 | + |
| 11 | + metalangle_baseurl = ( |
| 12 | + "https://github.com/kakashidinho/metalangle/releases/download/gles3-0.0.6" |
| 13 | + ) |
| 14 | + metalangle_arch_map = dict( |
| 15 | + x86_64="MetalANGLE.framework.ios.simulator.zip", |
| 16 | + arm64="MetalANGLE.framework.ios.zip", |
| 17 | + ) |
| 18 | + |
| 19 | + library = "Xcode/SDL/build/Release-{arch.sdk}/libSDL2.a" |
11 | 20 | include_dir = "include"
|
12 | 21 | pbx_frameworks = [
|
13 |
| - "OpenGLES", "AudioToolbox", "QuartzCore", "CoreGraphics", |
14 |
| - "CoreMotion", "GameController", "AVFoundation", "Metal", |
15 |
| - "UIKit"] |
| 22 | + "AudioToolbox", |
| 23 | + "QuartzCore", |
| 24 | + "CoreGraphics", |
| 25 | + "CoreMotion", |
| 26 | + "GameController", |
| 27 | + "AVFoundation", |
| 28 | + "Metal", |
| 29 | + "UIKit", |
| 30 | + "CoreHaptics", |
| 31 | + ] |
| 32 | + |
| 33 | + def __init__(self): |
| 34 | + if os.environ.get("KIVYIOS_USE_METALANGLE"): |
| 35 | + self.frameworks = ["MetalANGLE"] |
| 36 | + self.pbx_frameworks.append("MetalANGLE") |
| 37 | + else: |
| 38 | + self.pbx_frameworks.append("OpenGLES") |
16 | 39 |
|
17 | 40 | def prebuild_arch(self, arch):
|
18 | 41 | if self.has_marker("patched"):
|
19 | 42 | return
|
20 | 43 | self.apply_patch("uikit-transparent.patch")
|
| 44 | + if os.environ.get("KIVYIOS_USE_METALANGLE"): |
| 45 | + self.apply_patch("enable-metalangle.patch") |
| 46 | + downloaded_file = self.download_file( |
| 47 | + join(self.metalangle_baseurl, self.metalangle_arch_map[arch.arch]), |
| 48 | + self.metalangle_arch_map[arch.arch], |
| 49 | + ) |
| 50 | + self.extract_file( |
| 51 | + downloaded_file, |
| 52 | + join(self.get_build_dir(arch.arch), "Xcode/SDL/third-party/frameworks"), |
| 53 | + ) |
| 54 | + if arch.arch == "arm64": |
| 55 | + self.extract_file( |
| 56 | + downloaded_file, |
| 57 | + join(self.ctx.dist_dir, "frameworks"), |
| 58 | + ) |
21 | 59 | self.set_marker("patched")
|
22 | 60 |
|
| 61 | + def install_frameworks(self): |
| 62 | + pass |
| 63 | + |
23 | 64 | def build_arch(self, arch):
|
24 | 65 | env = arch.get_env()
|
25 |
| - shprint(sh.xcodebuild, self.ctx.concurrent_xcodebuild, |
26 |
| - "ONLY_ACTIVE_ARCH=NO", |
27 |
| - "ARCHS={}".format(arch.arch), |
28 |
| - "BITCODE_GENERATION_MODE=bitcode", |
29 |
| - "CC={}".format(env['CC']), |
30 |
| - "-sdk", arch.sdk, |
31 |
| - "-project", "Xcode-iOS/SDL/SDL.xcodeproj", |
32 |
| - "-target", "libSDL-iOS", |
33 |
| - "-configuration", "Release") |
| 66 | + shprint( |
| 67 | + sh.xcodebuild, |
| 68 | + self.ctx.concurrent_xcodebuild, |
| 69 | + "ONLY_ACTIVE_ARCH=NO", |
| 70 | + "ARCHS={}".format(arch.arch), |
| 71 | + "BITCODE_GENERATION_MODE=bitcode", |
| 72 | + "CC={}".format(env["CC"]), |
| 73 | + "-sdk", |
| 74 | + arch.sdk, |
| 75 | + "-project", |
| 76 | + "Xcode/SDL/SDL.xcodeproj", |
| 77 | + "-target", |
| 78 | + "Static Library-iOS", |
| 79 | + "-configuration", |
| 80 | + "Release", |
| 81 | + ) |
34 | 82 |
|
35 | 83 |
|
36 | 84 | recipe = LibSDL2Recipe()
|
0 commit comments