0.2.0-dev Download ZIP
50 lines ·1.6 KB Raw
| 1 | #!/usr/bin/env python |
| 2 | from misc.utility.scons_hints import * |
| 3 | |
| 4 | from platform_ios_builders import generate_bundle |
| 5 | from SCons.Script import Glob |
| 6 | |
| 7 | from platform_methods import combine_libs_apple_embedded, setup_swift_builder |
| 8 | |
| 9 | Import("env") |
| 10 | |
| 11 | swift_files = Glob("*.swift") |
| 12 | swift_file_names = list(map(lambda f: f.name, swift_files)) |
| 13 | |
| 14 | mm_files = Glob("*.mm") |
| 15 | mm_file_names = list(map(lambda f: f.name, mm_files)) |
| 16 | |
| 17 | env_ios = env.Clone() |
| 18 | |
| 19 | # Configure Swift builder |
| 20 | additional_swift_file_names = ["../../drivers/apple_embedded/godot_swiftui_view_controller.swift"] |
| 21 | apple_platform = env["APPLE_PLATFORM"] |
| 22 | sdk_path = env["APPLE_SDK_PATH"] |
| 23 | current_path = Dir(".").abspath |
| 24 | bridging_header_filename = "bridging_header_ios.h" |
| 25 | # The Swift sources are compiled together into a single object that's linked into the library. |
| 26 | swift_module = setup_swift_builder( |
| 27 | env_ios, |
| 28 | apple_platform, |
| 29 | sdk_path, |
| 30 | current_path, |
| 31 | bridging_header_filename, |
| 32 | swift_file_names + additional_swift_file_names, |
| 33 | ) |
| 34 | |
| 35 | # Enable module support |
| 36 | env_ios.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) |
| 37 | |
| 38 | ios_lib = env_ios.add_library("ios", mm_file_names + list(swift_module)) |
| 39 | if "LIBS_EXTERNAL" in env_ios: |
| 40 | env_ios.Depends(ios_lib, env_ios["LIBS_EXTERNAL"]) |
| 41 | |
| 42 | # Build the Swift->ObjC interop header before any ObjC++ source that #imports it. |
| 43 | env_ios.Depends(ios_lib, env_ios["SWIFT_OBJC_HEADER_TARGET"]) |
| 44 | |
| 45 | combine_command = env_ios.CommandNoCache( |
| 46 | "#bin/libgodot" + env_ios["LIBSUFFIX"], [ios_lib] + env_ios["LIBS"], env.Run(combine_libs_apple_embedded) |
| 47 | ) |
| 48 | |
| 49 | if env["generate_bundle"]: |
| 50 | env.AlwaysBuild(env.CommandNoCache("generate_bundle", combine_command, env.Run(generate_bundle))) |