bl
This commit is contained in:
parent
41adeeb47f
commit
5b65c4c0e4
11 changed files with 4237 additions and 297 deletions
|
|
@ -111,16 +111,49 @@ daemon_start_process :: proc(workspace: string) -> (Daemon_Process, int, bool) {
|
|||
return child, port, true
|
||||
}
|
||||
|
||||
// The daemon is its own Gradle project; the workspace is sent later over the
|
||||
// protocol. Locate the daemon project relative to the environment or the
|
||||
// editor executable so any folder can be opened as a workspace.
|
||||
daemon_project_dir :: proc() -> (string, bool) {
|
||||
env := os.get_env("NATIVE_EDITOR_DAEMON_DIR", context.temp_allocator)
|
||||
if len(env) > 0 && os.is_dir(env) {
|
||||
return env, true
|
||||
}
|
||||
if os.is_file("daemon/build.gradle.kts") {
|
||||
return "daemon", true
|
||||
}
|
||||
exe, exe_err := os.get_executable_path(context.temp_allocator)
|
||||
if exe_err == nil {
|
||||
dir := exe
|
||||
for _ in 0 ..< 5 {
|
||||
parent, _ := os.split_path(dir)
|
||||
if len(parent) == 0 || parent == dir do break
|
||||
dir = strings.trim_suffix(parent, "/")
|
||||
if len(dir) == 0 do break
|
||||
if os.is_file(fmt.tprintf("%s/daemon/build.gradle.kts", dir)) {
|
||||
return fmt.tprintf("%s/daemon", dir), true
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
daemon_start_process_begin :: proc(workspace: string) -> (Daemon_Process, bool) {
|
||||
child := Daemon_Process{}
|
||||
|
||||
project_dir, found := daemon_project_dir()
|
||||
if !found {
|
||||
fmt.println("daemon project not found; set NATIVE_EDITOR_DAEMON_DIR to the daemon directory")
|
||||
return child, false
|
||||
}
|
||||
|
||||
stdout_r, stdout_w, pipe_err := os.pipe()
|
||||
if pipe_err != nil {
|
||||
fmt.println("daemon pipe failed:", pipe_err)
|
||||
return child, false
|
||||
}
|
||||
|
||||
command := []string{"gradle", "-p", workspace, "run", "--quiet"}
|
||||
command := []string{"gradle", "-p", project_dir, "run", "--quiet"}
|
||||
process, start_err := os.process_start(os.Process_Desc{
|
||||
command = command,
|
||||
stdout = stdout_w,
|
||||
|
|
@ -387,7 +420,7 @@ daemon_send_gradle_run :: proc(client: ^Daemon_Client, task: string) -> int {
|
|||
|
||||
daemon_sync_active_buffer :: proc(client: ^Daemon_Client, editor: ^Editor, open: bool) {
|
||||
active := editor_active_buffer(editor)
|
||||
if active == nil do return
|
||||
if active == nil || active.scratch do return
|
||||
|
||||
text := editor_active_text(editor)
|
||||
defer delete(text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue