11defmodule BuildScript do
2- @url "https://github.com/V-Sekai/world-editor /releases/download/latest.v-sekai-editor-187 /v-sekai-world.zip"
2+ @url "https://github.com/V-Sekai/world-godot /releases/download/latest.v-sekai-editor-2 /v-sekai-world.zip"
33 @output "v-sekai-world.zip"
44 @extract_dir "export"
55 @extract_dir_extracted "#{@extract_dir}/temp"
66 @os_family :os.type()
77 @project_name "xr_grid"
8- @expected_hash "F7AB549A676C52DD47F9D74C9308EBBE447ABFA1513C7E563B3C15809C0CE3E3 "
8+ @expected_hash "657529B71E0BFF9500265FEE8C4A932E58A7FAC87CB1600F851ABA7C56FC15E6 "
99
1010 def all do
1111 pending_files_to_delete = editor_download()
@@ -110,16 +110,16 @@ defmodule BuildScript do
110110 def export_stage do
111111 editor_path = case @os_family do
112112 {:win32, :nt} ->
113- "#{@extract_dir_extracted}/godot.windows.editor.double.x86_64.llvm.exe"
113+ Path.expand( "#{@extract_dir_extracted}/godot.windows.editor.double.x86_64.llvm.exe")
114114 {:unix, :darwin} ->
115- "#{@extract_dir_extracted}/godot.macos.editor.double.arm64"
115+ Path.expand( "#{@extract_dir_extracted}/godot.macos.editor.double.arm64")
116116 {:unix, _} ->
117- "#{@extract_dir_extracted}/godot.linux.editor.double.x86_64"
117+ Path.expand( "#{@extract_dir_extracted}/godot.linux.editor.double.x86_64")
118118 end
119119
120120 if File.exists?(editor_path) do
121121 File.chmod(editor_path, 0o755)
122- version = System.cmd(editor_path, ["--version"]) |> elem(0) |> String.trim()
122+ version = System.cmd(editor_path, ["--headless", "-- version"]) |> elem(0) |> String.trim()
123123 platforms = [
124124 {"windows", "x86_64"},
125125 {"linuxbsd", "x86_64"},
@@ -132,6 +132,7 @@ defmodule BuildScript do
132132 end
133133 else
134134 IO.puts("Editor path not found: #{editor_path}")
135+ exit(:normal)
135136 end
136137 end
137138
@@ -207,30 +208,32 @@ defmodule BuildScript do
207208 File.cp!(debug_file, "#{templatedir}/#{debug_file_name}", force: true)
208209 File.cp!(release_file, "#{templatedir}/#{release_file_name}", force: true)
209210 end
210-
211211 def export_platform(from_platform, from_arch, target_platform, target_arch) do
212212 File.rm_rf!("#{@extract_dir}/export_#{target_platform}_#{target_arch}")
213213 File.mkdir_p!("#{@extract_dir}/export_#{target_platform}_#{target_arch}")
214-
215- editor_file = if from_platform == "windows" and File.exists?("#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}.llvm.exe") do
216- "#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}.llvm.exe"
217- else
218- "#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}"
214+ editor_file = cond do
215+ from_platform == "windows" and File.exists?("#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}.llvm.exe") ->
216+ "#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}.llvm.exe"
217+ from_platform == "macos" and File.exists?("#{@extract_dir_extracted}/godot.macos.editor.double.arm64") ->
218+ "#{@extract_dir_extracted}/godot.macos.editor.double.arm64"
219+ true ->
220+ "#{@extract_dir_extracted}/godot.#{from_platform}.editor.double.#{from_arch}"
219221 end
220- env = [{"ANDROID_SDK_ROOT", "#{File.cwd!()}/android_sdk"}, {"JAVA_HOME", "#{File.cwd!()}/jdk"}]
221- arguments = ["--headless", "--path", ".", "--import"]
222- System.cmd(editor_file, arguments, env: env)
222+ File.chmod(editor_file, 0o755)
223+ pwd = Path.dirname(__ENV__.file)
224+ arguments = ["--headless", "--path", pwd, "--import", "-e"]
225+ System.cmd("bash", ["-c", "#{editor_file} #{Enum.join(arguments, " ")}"], stderr_to_stdout: true)
223226
224227 output_file = "#{@extract_dir}/export_#{target_platform}_#{target_arch}/#{@project_name}"
225228 output_file = if target_platform == "windows", do: output_file <> ".exe", else: output_file
226229
227- arguments = ["--headless", "--path", "." , "--export-release", target_platform, output_file]
228- System.cmd(editor_file, arguments, env: env )
230+ arguments = ["--headless", "--path", pwd , "--export-release", target_platform, output_file, "-e" ]
231+ {_, 0} = System.cmd("bash", ["-c", "#{editor_file} #{Enum.join( arguments, " ")}"], stderr_to_stdout: true )
229232 IO.puts(Enum.join(arguments, " "))
230233
231234 case target_platform do
232235 "windows" ->
233- System.cmd("strip", [output_file])
236+ System.cmd("strip", [output_file], stderr_to_stdout: true )
234237 pdb_file = "#{@extract_dir_extracted}/godot.#{target_platform}.template_release.double.#{from_arch}.llvm.pdb"
235238 if File.exists?(pdb_file) do
236239 File.cp!(pdb_file, "#{@extract_dir}/export_#{target_platform}_#{target_arch}/#{Path.basename(pdb_file)}")
0 commit comments