| 40 | |
| 41 | # A hack to have "generate_bundle" copy the library to the frameworks dir in the bundle |
| 42 | def monkey_patch_macos_generate_bundle(): |
| 43 | # get the current directory |
| 44 | current_dir = os.path.dirname(os.path.abspath(__file__)) |
| 45 | platform_macos_builders_dir = os.path.abspath(os.path.join(current_dir, "../../platform/macos")) |
| 46 | sys.path.insert(0, platform_macos_builders_dir) |
| 47 | import platform_macos_builders |
| 48 | |
| 49 | old_generate_bundle = platform_macos_builders.generate_bundle |
| 50 | |
| 51 | def generate_bundle(target, source, env): |
| 52 | if "disable_godot_mono_decomp" in env and env["disable_godot_mono_decomp"]: |
| 53 | old_generate_bundle(target, source, env) |
| 54 | return |
| 55 | frameworks_dir = "" |
| 56 | if env.editor_build: |
| 57 | templ = env.Dir("#misc/dist/macos_tools.app").abspath |
| 58 | frameworks_dir = os.path.join(templ, "Contents/Frameworks") |
| 59 | else: |
| 60 | templ = env.Dir("#misc/dist/macos_template.app").abspath |
| 61 | frameworks_dir = os.path.join(templ, "Contents/Frameworks") |
| 62 | remove_fw_dir = False |
| 63 | if not os.path.isdir(frameworks_dir): |
| 64 | remove_fw_dir = True |
| 65 | os.mkdir(frameworks_dir) |
| 66 | # Copy frameworks |
| 67 | monolib = env.Dir("#bin").abspath + "/libGodotMonoDecompNativeAOT.dylib" |
| 68 | shutil.copy(monolib, frameworks_dir + "/libGodotMonoDecompNativeAOT.dylib") |
| 69 | # run the original generate_bundle |
| 70 | old_generate_bundle(target, source, env) |
| 71 | # remove the library from the frameworks dir |
| 72 | os.remove(frameworks_dir + "/libGodotMonoDecompNativeAOT.dylib") |
| 73 | if remove_fw_dir: |
| 74 | os.rmdir(frameworks_dir) |
| 75 | |
| 76 | platform_macos_builders.generate_bundle = generate_bundle |
| 77 | |
| 78 | # remove the platform_macos_builders from the path |
| 79 | sys.path.remove(platform_macos_builders_dir) |
| 80 | |
| 81 | def configure(env): |
| 82 | if not env.editor_build: |