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 @@
11#!/bin/bash
22
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
223# Ask for version number
234read -p "Enter the version number: " version
245release_folder="releases/curd-$version"
@@ -36,10 +17,6 @@ sed -i "s/^AppVersion=.*/AppVersion=$version/" "$installer_script"
3617sed -i "s|Source: \".*curd.exe\"|Source: \"Z:$windows_folder/curd.exe\"|" "$installer_script"
3718# sed -i "s|Source: \".*mpv.exe\"|Source: \"Z:$windows_folder/mpv.exe\"|" "$installer_script"
3819
39# Comment out winio-related lines for Linux build
40echo "Commenting out go-winio lines for Linux build..."
41toggle_winio_import "comment"
42
4320# Build Linux binary
4421echo "Building Linux binary..."
4522bash Build/buildlinux
@@ -52,10 +29,6 @@ else
5229 exit 1
5330fi
5431
55# Uncomment winio-related lines after Linux build
56echo "Uncommenting go-winio lines..."
57toggle_winio_import "uncomment"
58
5932# Build Windows binary
6033echo "Building Windows binary..."
6134bash Build/buildwindows
internal/player.go +1 −11
@@ -5,12 +5,10 @@ import (
55 "crypto/rand"
66 "encoding/json"
77 "fmt"
8 "net"
98 "os"
109 "os/exec"
1110 "path/filepath"
1211 "runtime"
13 "github.com/Microsoft/go-winio"
1412)
1513var logFile = "debug.log"
1614
@@ -94,15 +92,7 @@ func joinArgs(args []string) string {
9492}
9593
9694func MPVSendCommand(ipcSocketPath string, command []interface{}) (interface{}, error) {
97 var conn net.Conn
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 }
95 conn, err := connectToPipe(ipcSocketPath)
10696 if err != nil {
10797 return nil, err
10898 }
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}