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