MacOS support

This commit is contained in:
Nordup 2024-07-11 00:55:41 +04:00
parent 643f750156
commit 644a8bb969
7 changed files with 45 additions and 6 deletions

2
app/.gitignore vendored
View file

@ -2,4 +2,4 @@
.godot/
# for ipc files (inter process communication)
sandbox/
./sandbox/

View file

@ -8,3 +8,5 @@ linux = "sandbox/Sandbox.x86_64"
linux_debug = "godot.linuxbsd.template_debug.dev.sandbox.x86_64.llvm"
windows = "sandbox/Sandbox.exe"
windows_debug = "godot.windows.template_debug.dev.sandbox.x86_64.exe"
macos = "sandbox/Sandbox.arm64"
macos_debug = "godot.macos.template_debug.dev.sandbox.arm64"

View file

@ -313,6 +313,7 @@ script = ExtResource("9_ncfxj")
ui_events = ExtResource("9_ir58h")
[node name="RenderResult" type="TextureRect" parent="HBoxContainer/WorldCanvas"]
texture_filter = 1
layout_mode = 1
anchors_preset = 14
anchor_top = 0.5
@ -328,6 +329,7 @@ stretch_mode = 5
script = ExtResource("5_nlg2s")
gate_events = ExtResource("2_q7cvi")
command_events = ExtResource("6_18mgg")
ui_events = ExtResource("9_ir58h")
splash_screen = ExtResource("10_23bjc")
[node name="HideOnPress" type="TextureButton" parent="HBoxContainer/WorldCanvas/RenderResult"]

View file

@ -3,14 +3,15 @@ class_name RenderResult
@export var gate_events: GateEvents
@export var command_events: CommandEvents
@export var ui_events: UiEvents
@export var splash_screen: Texture2D
var rd: RenderingDevice
var ext_texure: ExternalTexture
var texture_rid: RID
@onready var width: int = get_viewport().size.x
@onready var height: int = get_viewport().size.y
@onready var width: int = int(ui_events.current_ui_size.x)
@onready var height: int = int(ui_events.current_ui_size.y)
func _ready() -> void:

View file

@ -7,6 +7,9 @@ class_name SandboxExecutable
@export var windows: String
@export var windows_debug: String
@export var macos: String
@export var macos_debug: String
var path: String :
get = get_executable_path
@ -24,6 +27,8 @@ func get_filename() -> String:
return windows_debug if is_debug else windows
Platform.LINUX_BSD:
return linux_debug if is_debug else linux
Platform.MACOS:
return macos_debug if is_debug else macos
_:
assert(false, "Platform is not supported")
return ""

View file

@ -21,6 +21,8 @@ func start_sandbox(gate: Gate) -> void:
start_sandbox_windows(gate)
Platform.LINUX_BSD:
start_sandbox_linux(gate)
Platform.MACOS:
start_sandbox_macos(gate)
_:
assert(false, "Platform is not supported")
@ -37,7 +39,7 @@ func start_sandbox_linux(gate: Gate) -> void:
snbx_env.start.get_base_dir(), # cd to dir
"--main-pack", snbx_env.main_pack,
"--resolution", "%dx%d" % [render_result.width, render_result.height],
"--verbose"
"--verbose" if OS.is_stdout_verbose() else ""
]
Debug.logclr(snbx_env.start + " " + " ".join(args), Color.DARK_VIOLET)
sandbox_pid = OS.create_process(snbx_env.start, args)
@ -56,7 +58,26 @@ func start_sandbox_windows(gate: Gate) -> void:
var args = [
"--main-pack", pack_file,
"--gdext-libs-dir", shared_libs,
"--resolution", "%dx%d" % [render_result.width, render_result.height]
"--resolution", "%dx%d" % [render_result.width, render_result.height],
"--verbose" if OS.is_stdout_verbose() else ""
]
Debug.logclr(snbx_executable.path + " " + " ".join(args), Color.DARK_VIOLET)
sandbox_pid = OS.create_process(snbx_executable.path, args)
gate_events.gate_entered_emit()
func start_sandbox_macos(gate: Gate) -> void:
if not snbx_executable.exists():
Debug.logerr("Sandbox executable not found at " + snbx_executable.path); return
var pack_file = ProjectSettings.globalize_path(gate.resource_pack)
var shared_libs = ProjectSettings.globalize_path(gate.shared_libs_dir)
var args = [
"--main-pack", pack_file,
"--gdext-libs-dir", shared_libs,
"--resolution", "%dx%d" % [render_result.width, render_result.height],
"--verbose" if OS.is_stdout_verbose() else ""
]
Debug.logclr(snbx_executable.path + " " + " ".join(args), Color.DARK_VIOLET)
sandbox_pid = OS.create_process(snbx_executable.path, args)
@ -70,6 +91,8 @@ func kill_sandbox() -> void:
kill_sandbox_windows()
Platform.LINUX_BSD:
kill_sandbox_linux()
Platform.MACOS:
kill_sandbox_macos()
_:
assert(false, "Platform is not supported")
@ -93,5 +116,11 @@ func kill_sandbox_windows() -> void:
Debug.logclr("Process killed " + str(sandbox_pid), Color.DIM_GRAY)
func kill_sandbox_macos() -> void:
if OS.is_process_running(sandbox_pid):
OS.kill(sandbox_pid)
Debug.logclr("Process killed " + str(sandbox_pid), Color.DIM_GRAY)
func _exit_tree() -> void:
kill_sandbox()

2
godot

@ -1 +1 @@
Subproject commit 29d6d651a6dd28c0a132a97de65098a7a13e145c
Subproject commit a165561a8e7615abc82ed5d549e7788a55a44568