Commit 21362d420f

21362d420f67ce0958c1264cb05d261097c5389e

parent: a47582d5c7

Unsigned

Wraient <wraient.911@gmail.com> · 2025-01-22 16:43 UTC

Life update: Platform specific code only compilies for specific platform.

Layout: unified · split

Build/release −27
@@ -1,24 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# Function to comment/uncomment lines in internal/player.go
4function toggle_winio_import() {
5 local action="$1"
6 local file="internal/player.go"
7
8 if [ "$action" == "comment" ]; then
9 # Comment out the go-winio import line
10 sed -i 's|^\(\s*"github.com/Microsoft/go-winio"\)|// \1|' "$file"
11 # Comment out the usage of winio.DialPipe
12 sed -i 's|^\(.*conn, err = winio.DialPipe.*\)|// \1|' "$file"
13 elif [ "$action" == "uncomment" ]; then
14 # Uncomment the go-winio import line
15 sed -i 's|// \(\s*"github.com/Microsoft/go-winio"\)|\1|' "$file"
16 # Uncomment the usage of winio.DialPipe
17 sed -i 's|^// \(.*conn, err = winio.DialPipe.*\)|\1|' "$file"
18 fi
19}
20
21
22# Ask for version number 3# Ask for version number
23read -p "Enter the version number: " version 4read -p "Enter the version number: " version
24release_folder="releases/curd-$version" 5release_folder="releases/curd-$version"
@@ -36,10 +17,6 @@ sed -i "s/^AppVersion=.*/AppVersion=$version/" "$installer_script"
36sed -i "s|Source: \".*curd.exe\"|Source: \"Z:$windows_folder/curd.exe\"|" "$installer_script" 17sed -i "s|Source: \".*curd.exe\"|Source: \"Z:$windows_folder/curd.exe\"|" "$installer_script"
37# sed -i "s|Source: \".*mpv.exe\"|Source: \"Z:$windows_folder/mpv.exe\"|" "$installer_script" 18# sed -i "s|Source: \".*mpv.exe\"|Source: \"Z:$windows_folder/mpv.exe\"|" "$installer_script"
38 19
39# Comment out winio-related lines for Linux build
40echo "Commenting out go-winio lines for Linux build..."
41toggle_winio_import "comment"
42
43# Build Linux binary 20# Build Linux binary
44echo "Building Linux binary..." 21echo "Building Linux binary..."
45bash Build/buildlinux 22bash Build/buildlinux
@@ -52,10 +29,6 @@ else
52 exit 1 29 exit 1
53fi 30fi
54 31
55# Uncomment winio-related lines after Linux build
56echo "Uncommenting go-winio lines..."
57toggle_winio_import "uncomment"
58
59# Build Windows binary 32# Build Windows binary
60echo "Building Windows binary..." 33echo "Building Windows binary..."
61bash Build/buildwindows 34bash Build/buildwindows
internal/player.go +1 −11
@@ -5,12 +5,10 @@ import (
5 "crypto/rand" 5 "crypto/rand"
6 "encoding/json" 6 "encoding/json"
7 "fmt" 7 "fmt"
8 "net"
9 "os" 8 "os"
10 "os/exec" 9 "os/exec"
11 "path/filepath" 10 "path/filepath"
12 "runtime" 11 "runtime"
13 "github.com/Microsoft/go-winio"
14) 12)
15var logFile = "debug.log" 13var logFile = "debug.log"
16 14
@@ -94,15 +92,7 @@ func joinArgs(args []string) string {
94} 92}
95 93
96func MPVSendCommand(ipcSocketPath string, command []interface{}) (interface{}, error) { 94func MPVSendCommand(ipcSocketPath string, command []interface{}) (interface{}, error) {
97 var conn net.Conn 95 conn, err := connectToPipe(ipcSocketPath)
98 var err error
99
100 if runtime.GOOS == "windows" {
101 // Use named pipe for Windows
102 conn, err = winio.DialPipe(ipcSocketPath, nil)
103 } else {
104 conn, err = net.Dial("unix", ipcSocketPath)
105 }
106 if err != nil { 96 if err != nil {
107 return nil, err 97 return nil, err
108 } 98 }
internal/unix_ipc.go added +16
@@ -0,0 +1,16 @@
1//go:build !windows
2// +build !windows
3
4package internal
5
6import (
7 "net"
8)
9
10func connectToPipe(ipcSocketPath string) (net.Conn, error) {
11 conn, err := net.Dial("unix", ipcSocketPath)
12 if err != nil {
13 return nil, err
14 }
15 return conn, nil
16}\ No newline at end of file
internal/windows_ipc.go added +18
@@ -0,0 +1,18 @@
1//go:build windows
2// +build windows
3
4package internal
5
6import (
7 "net"
8
9 "github.com/Microsoft/go-winio"
10)
11
12func connectToPipe(ipcSocketPath string) (net.Conn, error) {
13 conn, err := winio.DialPipe(ipcSocketPath, nil)
14 if err != nil {
15 return nil, err
16 }
17 return conn, nil
18}