Compare commits
2 Commits
3b366cbbae
...
f2c4c05b27
| Author | SHA1 | Date | |
|---|---|---|---|
| f2c4c05b27 | |||
| fc3a0d026f |
29
log.go
29
log.go
@@ -4,22 +4,23 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
logText *widget.Entry
|
logText *widget.Entry
|
||||||
logBuffer []string
|
logBuffer []string
|
||||||
logMaxLines int
|
logMaxLines int
|
||||||
}
|
}
|
||||||
|
|
||||||
var globalLogger *Logger;
|
var globalLogger *Logger
|
||||||
|
|
||||||
func InitLogger(text *widget.Entry, maxLines int) {
|
func InitLogger(text *widget.Entry, maxLines int) {
|
||||||
globalLogger = &Logger{
|
globalLogger = &Logger{
|
||||||
logText: text,
|
logText: text,
|
||||||
logMaxLines: maxLines,
|
logMaxLines: maxLines,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Log(line string) {
|
func Log(line string) {
|
||||||
@@ -32,9 +33,11 @@ func Log(line string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) log(line string) {
|
func (l *Logger) log(line string) {
|
||||||
l.logBuffer = append(l.logBuffer, line)
|
fyne.Do(func() {
|
||||||
if len(l.logBuffer) > l.logMaxLines {
|
l.logBuffer = append(l.logBuffer, line)
|
||||||
l.logBuffer = l.logBuffer[1:]
|
if len(l.logBuffer) > l.logMaxLines {
|
||||||
}
|
l.logBuffer = l.logBuffer[1:]
|
||||||
l.logText.SetText(strings.Join(l.logBuffer, "\n"))
|
}
|
||||||
}
|
l.logText.SetText(strings.Join(l.logBuffer, "\n"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,38 +1,26 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"enginePath": "/home/yann/Apps/UE_5.5/",
|
"enginePath": "D:/Devel/UE_5.7",
|
||||||
"projectPath": "/home/yann/Projects/unreal/NpcChatbot/",
|
"projectPath": "E:/unreal/AeroSyncFS/",
|
||||||
"projectName": "NpcChatbot",
|
|
||||||
"engineVersion": "5.5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enginePath": "/home/yann/Apps/UE_5.5/",
|
|
||||||
"projectPath": "/home/yann/Projects/unreal/jsbsim/UnrealEngine/",
|
|
||||||
"projectName": "UEReferenceApp",
|
|
||||||
"engineVersion": "5.5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enginePath": "/home/yann/Apps/UE_5.5/",
|
|
||||||
"projectPath": "/run/media/yann/Devel/Unreal/AeroSyncUFS",
|
|
||||||
"projectName": "MiniFS",
|
"projectName": "MiniFS",
|
||||||
"engineVersion": "5.5"
|
"engineVersion": "5.7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"enginePath": "/home/yann/Apps/UE_5.5/",
|
"enginePath": "D:/Devel/UE_5.7",
|
||||||
"projectPath": "/run/media/yann/Devel/Unreal/CyberneticRequiem",
|
"projectPath": "E:/unreal/CyberneticRequiem/",
|
||||||
"projectName": "CyberneticRequiem",
|
"projectName": "CyberneticRequiem",
|
||||||
"engineVersion": "5.5"
|
"engineVersion": "5.7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"enginePath": "/home/yann/Apps/UE_5.5/",
|
"enginePath": "D:/Devel/UE_5.5",
|
||||||
"projectPath": "/run/media/yann/Devel/Unreal/DVRSimulator",
|
"projectPath": "E:/unreal/DVRSimulator/",
|
||||||
"projectName": "DVRSimulator",
|
"projectName": "DVRSimulator",
|
||||||
"engineVersion": "5.5"
|
"engineVersion": "5.5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"enginePath": "/home/yann/Apps/UE_5.5/",
|
"enginePath": "D:/Devel/UE_5.5",
|
||||||
"projectPath": "/run/media/yann/Devel/Unreal/GunSpinningVR",
|
"projectPath": "E:/novelab/unreal/SNCF_Regiolis",
|
||||||
"projectName": "GSPVR",
|
"projectName": "SNCF_Regiolis",
|
||||||
"engineVersion": "5.5"
|
"engineVersion": "5.5"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
2
ui.go
2
ui.go
@@ -28,7 +28,7 @@ func NewProjectRow(project Project) fyne.CanvasObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
icon := canvas.NewImageFromResource(projectIcon)
|
icon := canvas.NewImageFromResource(projectIcon)
|
||||||
icon.SetMinSize(fyne.NewSize(48, 48))
|
icon.SetMinSize(fyne.NewSize(64, 64))
|
||||||
|
|
||||||
nameLabel := widget.NewLabel(projectName + " / Unreal Engine " + project.Version)
|
nameLabel := widget.NewLabel(projectName + " / Unreal Engine " + project.Version)
|
||||||
nameLabel.Alignment = fyne.TextAlignLeading
|
nameLabel.Alignment = fyne.TextAlignLeading
|
||||||
|
|||||||
76
utils.go
76
utils.go
@@ -71,33 +71,66 @@ func CleanUnrealProject(project Project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GenerateUnrealSolution(project Project) {
|
func GenerateUnrealSolution(project Project) {
|
||||||
var buildCmd string
|
var cmd *exec.Cmd
|
||||||
|
|
||||||
|
projectFile := project.ProjectPath + "/" + project.ProjectName + ".uproject"
|
||||||
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
buildCmd = project.EnginePath + "/Engine/Build/BatchFiles/Linux/GenerateProjectFiles.sh"
|
buildCmd := project.EnginePath + "/Engine/Build/BatchFiles/Linux/GenerateProjectFiles.sh"
|
||||||
|
cmd = exec.Command(buildCmd, projectFile, "-game")
|
||||||
|
|
||||||
case "darwin":
|
case "darwin":
|
||||||
buildCmd = project.EnginePath + "/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh"
|
buildCmd := project.EnginePath + "/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh"
|
||||||
|
cmd = exec.Command(buildCmd, projectFile, "-game")
|
||||||
|
|
||||||
|
case "windows":
|
||||||
|
ubtPath := project.EnginePath + "\\Engine\\Binaries\\DotNET\\UnrealBuildTool\\UnrealBuildTool.dll"
|
||||||
|
cmd = exec.Command(
|
||||||
|
"dotnet", ubtPath,
|
||||||
|
"-projectfiles",
|
||||||
|
"-project="+projectFile,
|
||||||
|
"-game",
|
||||||
|
"-progress",
|
||||||
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Println("Generate Project is not yet supported on Windows")
|
fmt.Println("Generate Project is not supported on this platform:", runtime.GOOS)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
projectCmd := project.ProjectPath + "/" + project.ProjectName + ".uproject"
|
|
||||||
cmd := exec.Command(buildCmd, projectCmd, "-game")
|
|
||||||
|
|
||||||
logToOutput(cmd)
|
logToOutput(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildUnrealSolution(project Project) {
|
func BuildUnrealSolution(project Project) {
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
projectFile := project.ProjectPath + "/" + project.ProjectName + ".uproject"
|
||||||
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
cmd := exec.Command("make", "-C", project.ProjectPath, project.ProjectName)
|
cmd = exec.Command("make", "-C", project.ProjectPath, project.ProjectName)
|
||||||
logToOutput(cmd)
|
|
||||||
|
case "windows":
|
||||||
|
buildBatch := project.EnginePath + "\\Engine\\Build\\BatchFiles\\Build.bat"
|
||||||
|
target := project.ProjectName + "Editor"
|
||||||
|
platform := "Win64"
|
||||||
|
config := "Development"
|
||||||
|
|
||||||
|
cmd = exec.Command(
|
||||||
|
buildBatch,
|
||||||
|
target,
|
||||||
|
platform,
|
||||||
|
config,
|
||||||
|
"-Project="+projectFile,
|
||||||
|
"-WaitMutex",
|
||||||
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fmt.Println("Build Project is not yet supported on Windows")
|
fmt.Println("Build Project is not yet supported on this platform:", runtime.GOOS)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logToOutput(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunUnrealProject(project Project) {
|
func RunUnrealProject(project Project) {
|
||||||
@@ -133,18 +166,27 @@ func logToOutput(cmd *exec.Cmd) {
|
|||||||
fmt.Println("Error while loading command")
|
fmt.Println("Error while loading command")
|
||||||
}
|
}
|
||||||
|
|
||||||
readPipe := func(reader io.ReadCloser) {
|
readPipe := func(reader io.ReadCloser, prefix string) {
|
||||||
scanner := bufio.NewScanner(reader)
|
scanner := bufio.NewScanner(reader)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
Log(line)
|
if prefix != "" {
|
||||||
|
Log(prefix + line)
|
||||||
|
} else {
|
||||||
|
Log(line)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go readPipe(stdout)
|
go readPipe(stdout, "")
|
||||||
go readPipe(stderr)
|
go readPipe(stderr, "[ERR] ")
|
||||||
|
|
||||||
if err := cmd.Wait(); err != nil {
|
// attendre la fin dans une goroutine => pas de blocage de l'UI
|
||||||
fmt.Println("Error")
|
go func() {
|
||||||
}
|
if err := cmd.Wait(); err != nil {
|
||||||
|
Log("[FAIL] " + err.Error())
|
||||||
|
} else {
|
||||||
|
Log("[DONE] Process finished")
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user