delete sandbox_env resource

This commit is contained in:
Nordup 2025-08-31 11:27:37 +07:00
parent 632e718b2b
commit b1b0361c22
4 changed files with 1 additions and 96 deletions

View file

@ -1,12 +0,0 @@
[gd_resource type="Resource" script_class="SandboxEnv" load_steps=2 format=3 uid="uid://bo6qgr210aamc"]
[ext_resource type="Script" path="res://scripts/sandbox/sandbox_env.gd" id="1_2dvtt"]
[resource]
script = ExtResource("1_2dvtt")
zip = "sandbox/sandbox_env.zip"
the_gates_folder = "fakechroot_enviroment/root/GATES-FILES"
the_gates_folder_abs = "/GATES-FILES"
snbx_exe_name = "game"
start_sh = "run_game.sh"
subprocesses_sh = "list_child_processes.sh"

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=42 format=3 uid="uid://kywrsqro3d5i"]
[gd_scene load_steps=41 format=3 uid="uid://kywrsqro3d5i"]
[ext_resource type="Script" path="res://scripts/loading/gate_loader.gd" id="1_uxhy6"]
[ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_q7cvi"]
@ -7,7 +7,6 @@
[ext_resource type="Resource" uid="uid://l1quiaghft2f" path="res://resources/command_events.res" id="6_18mgg"]
[ext_resource type="Script" path="res://scripts/sandbox/sandbox_manager.gd" id="6_368sj"]
[ext_resource type="Script" path="res://scripts/sandbox/input_sync.gd" id="8_1blsi"]
[ext_resource type="Resource" uid="uid://bo6qgr210aamc" path="res://resources/sandbox_env.tres" id="8_a6dvr"]
[ext_resource type="Script" path="res://scripts/sandbox/sandbox_logger.gd" id="9_fikc8"]
[ext_resource type="Resource" uid="uid://crjhix0osmtnf" path="res://resources/ui_events.res" id="9_ir58h"]
[ext_resource type="Shader" path="res://shaders/render_result.gdshader" id="10_2auwe"]
@ -147,7 +146,6 @@ gate_events = ExtResource("2_q7cvi")
render_result = NodePath("../WorldCanvas/RenderResult")
snbx_logger = NodePath("../SandboxLogger")
snbx_executable = ExtResource("4_shus3")
snbx_env = ExtResource("8_a6dvr")
[node name="SandboxLogger" type="Node" parent="."]
script = ExtResource("9_fikc8")

View file

@ -1,80 +0,0 @@
extends Resource
class_name SandboxEnv
@export var zip: String
@export var the_gates_folder: String
@export var the_gates_folder_abs: String
@export var snbx_exe_name: String
@export var start_sh: String
@export var subprocesses_sh: String
const ENV_FOLDER := "/tmp/sandbox_env"
var zip_path: String :
get = get_zip_path
var start: String :
get = get_start_sh
var subprocesses: String :
get = get_subprocesses_sh
var main_pack: String
func get_zip_path() -> String:
var executable_dir = OS.get_executable_path().get_base_dir() + "/"
return executable_dir + zip
func get_start_sh() -> String:
return ProjectSettings.globalize_path(ENV_FOLDER + "/" + start_sh)
func get_subprocesses_sh() -> String:
return ProjectSettings.globalize_path(ENV_FOLDER + "/" + subprocesses_sh)
func zip_exists() -> bool:
return FileAccess.file_exists(zip_path)
func create_env(snbx_executable: String, gate: Gate) -> void:
Debug.logclr("create_env %s" % [ENV_FOLDER], Color.DIM_GRAY)
UnZip.unzip(zip_path, ENV_FOLDER, true)
var folder = ENV_FOLDER + "/" + the_gates_folder
var executable = folder + "/" + snbx_exe_name
DirAccess.copy_absolute(snbx_executable, executable)
main_pack = executable.get_basename() + "." + gate.resource_pack.get_extension()
DirAccess.copy_absolute(gate.resource_pack, main_pack)
main_pack = the_gates_folder_abs + "/" + main_pack.get_file()
if not gate.shared_libs_dir.is_empty() and DirAccess.dir_exists_absolute(gate.shared_libs_dir):
for file in DirAccess.get_files_at(gate.shared_libs_dir):
var lib = gate.shared_libs_dir + "/" + file
var lib_in_folder = folder + "/" + file
DirAccess.copy_absolute(lib, lib_in_folder)
Debug.logclr(lib_in_folder, Color.DIM_GRAY)
func get_subprocesses(ppid: int) -> Array[int]:
var pids: Array[int] = []
var output = []
OS.execute(subprocesses, [str(ppid)], output)
if output.is_empty(): return pids
var s_pids = output[0].split('\n')
for s_pid in s_pids:
if s_pid.is_empty(): continue
var pid = s_pid.to_int()
pids.append(pid)
return pids
func clean() -> void:
OS.execute("rm", ["-rf", ProjectSettings.globalize_path(ENV_FOLDER)])

View file

@ -5,7 +5,6 @@ class_name SandboxManager
@export var render_result: RenderResult
@export var snbx_logger: SandboxLogger
@export var snbx_executable: SandboxExecutable
@export var snbx_env: SandboxEnv
const IPC_FOLDER := "sandbox"