Add some switches that set proper paths for Windows

This commit is contained in:
Sebastian Morr 2020-09-09 11:48:42 +02:00
parent d352bd24c2
commit 724a5fff03
3 changed files with 27 additions and 14 deletions

21
game.gd
View file

@ -1,12 +1,18 @@
extends Node extends Node
var tmp_prefix = "/tmp/" var tmp_prefix = _tmp_prefix()
var global_shell var global_shell
var debug = false var debug = false
var fake_editor
func _ready(): func _ready():
global_shell = Shell.new() global_shell = Shell.new()
global_shell.cd(tmp_prefix)
# Copy fake-editor to tmp directory (because the original might be in a .pck file).
var fake_editor = tmp_prefix + "fake-editor"
var content = game.read_file("res://scripts/fake-editor")
write_file(fake_editor, content)
global_shell.run("chmod u+x " + fake_editor)
func read_file(path): func read_file(path):
if debug: if debug:
@ -25,3 +31,14 @@ func write_file(path, content):
file.store_string(content) file.store_string(content)
file.close() file.close()
return true return true
func _tmp_prefix():
var os = OS.get_name()
if os == "X11":
return "/tmp/"
elif os == "Windows":
return "%temp%/"
else:
push_error("Unsupported OS")
get_tree().quit()

10
main.gd
View file

@ -83,11 +83,11 @@ func construct_repo(script, path):
var script_path = game.tmp_prefix+"/git-hydra-script" var script_path = game.tmp_prefix+"/git-hydra-script"
game.write_file(script_path, content) game.write_file(script_path, content)
var shell = Shell.new() game.global_shell.run("mkdir " + path)
shell.run("mkdir " + path) game.global_shell.cd(path)
shell.cd(path) game.global_shell.run("git init")
shell.run("git init") var o = game.global_shell.run("source "+script_path)
var o = shell.run("source "+script_path)
if game.debug: if game.debug:
print(o) print(o)

View file

@ -7,11 +7,7 @@ var _fake_editor
signal output(text) signal output(text)
func _init(): func _init():
# Copy fake-editor to tmp directory (because the original might be in a .pck file). _cwd = game.tmp_prefix
_fake_editor = game.tmp_prefix + "fake-editor"
var content = game.read_file("res://scripts/fake-editor")
game.write_file(_fake_editor, content)
_exec("chmod", ["u+x", _fake_editor])
func cd(dir): func cd(dir):
_cwd = dir _cwd = dir
@ -44,9 +40,9 @@ func _shell_binary():
var os = OS.get_name() var os = OS.get_name()
if os == "X11": if os == "X11":
return "/bin/sh" return "sh"
elif os == "Windows": elif os == "Windows":
return "external/git_bash.exe" return "sh.exe"
else: else:
push_error("Unsupported OS") push_error("Unsupported OS")
get_tree().quit() get_tree().quit()