Reorganize source tree and build assets
This commit is contained in:
@@ -40,7 +40,7 @@ sudo apt install golang gcc libgl1-mesa-dev xorg-dev
|
|||||||
Windows:
|
Windows:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
.\scripts\build-windows.ps1
|
.\scripts\build-windows.bat
|
||||||
```
|
```
|
||||||
|
|
||||||
The binary is written to:
|
The binary is written to:
|
||||||
@@ -64,8 +64,9 @@ dist/linux/pysentry
|
|||||||
|
|
||||||
Linux using Docker:
|
Linux using Docker:
|
||||||
|
|
||||||
```powershell
|
```bash
|
||||||
.\scripts\build-linux-docker.ps1
|
chmod +x ./scripts/build-linux-docker.sh
|
||||||
|
./scripts/build-linux-docker.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
The binary is copied to:
|
The binary is copied to:
|
||||||
@@ -157,11 +158,13 @@ Changing `jobs_dir` saves the current job list to the new directory.
|
|||||||
## Project Layout
|
## Project Layout
|
||||||
|
|
||||||
- `cmd/pysentry` starts the desktop app.
|
- `cmd/pysentry` starts the desktop app.
|
||||||
- `internal/app` contains the GUI.
|
- `src/gui` contains the GUI.
|
||||||
- `internal/core` contains YAML storage, command execution, scheduling, and log cleanup.
|
- `src/core` contains YAML storage, command execution, scheduling, and log cleanup.
|
||||||
- `assets` contains app icons.
|
- `assets` contains app icons.
|
||||||
- `scripts` contains build helpers.
|
- `scripts` contains build helpers.
|
||||||
|
|
||||||
|
Build outputs are written to `dist/`. The old local `bin/` directory is not used.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
PySentry keeps the direct dependency list intentionally small:
|
PySentry keeps the direct dependency list intentionally small:
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 996 KiB After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||||
|
<rect width="256" height="256" rx="52" fill="#005562"/>
|
||||||
|
<path d="M128 32 204 64v58c0 50-29 82-76 104-47-22-76-54-76-104V64z" fill="none" stroke="#ffffff" stroke-width="20" stroke-linejoin="round"/>
|
||||||
|
<path d="M128 76v55l42-32" fill="none" stroke="#ffffff" stroke-width="20" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<circle cx="128" cy="132" r="14" fill="#ffffff"/>
|
||||||
|
<path d="M77 154l26 22-26 22" fill="none" stroke="#ffb31a" stroke-width="18" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M125 198h36" fill="none" stroke="#ffb31a" stroke-width="18" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 673 B |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/pysentry/pysentry/internal/app"
|
import "github.com/pysentry/pysentry/src/gui"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app.Run()
|
gui.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 996 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 94 KiB |
@@ -1 +1 @@
|
|||||||
IDI_ICON1 ICON "packaging/windows/pysentry.ico"
|
IDI_ICON1 ICON "assets/pysentry.ico"
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
param(
|
|
||||||
[string]$Output = "dist\linux\pysentry"
|
|
||||||
)
|
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
docker build -f Dockerfile.linux -t pysentry-linux-builder .
|
|
||||||
$containerId = docker create pysentry-linux-builder
|
|
||||||
New-Item -ItemType Directory -Force -Path (Split-Path $Output) | Out-Null
|
|
||||||
docker cp "${containerId}:/out/pysentry" $Output
|
|
||||||
docker rm $containerId | Out-Null
|
|
||||||
|
|
||||||
Write-Host "Built $Output"
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
output="${1:-dist/linux/pysentry}"
|
||||||
|
|
||||||
|
docker build -f Dockerfile.linux -t pysentry-linux-builder .
|
||||||
|
container_id="$(docker create pysentry-linux-builder)"
|
||||||
|
mkdir -p "$(dirname "$output")"
|
||||||
|
docker cp "${container_id}:/out/pysentry" "$output"
|
||||||
|
docker rm "$container_id" >/dev/null
|
||||||
|
rm -rf "$(dirname "$output")/assets"
|
||||||
|
cp -R assets "$(dirname "$output")/assets"
|
||||||
|
|
||||||
|
echo "Built $output"
|
||||||
@@ -9,5 +9,7 @@ export GOOS=linux
|
|||||||
export GOARCH=amd64
|
export GOARCH=amd64
|
||||||
|
|
||||||
go build -trimpath -ldflags "-s -w" -o "$output" ./cmd/pysentry
|
go build -trimpath -ldflags "-s -w" -o "$output" ./cmd/pysentry
|
||||||
|
rm -rf "$(dirname "$output")/assets"
|
||||||
|
cp -R assets "$(dirname "$output")/assets"
|
||||||
|
|
||||||
echo "Built $output"
|
echo "Built $output"
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
set "OUTPUT=%~1"
|
||||||
|
if "%OUTPUT%"=="" set "OUTPUT=dist\windows\pysentry.exe"
|
||||||
|
|
||||||
|
set "GOEXE=%ProgramFiles%\Go\bin\go.exe"
|
||||||
|
if not exist "%GOEXE%" set "GOEXE=go"
|
||||||
|
|
||||||
|
if exist "C:\msys64\ucrt64\bin" set "PATH=C:\msys64\ucrt64\bin;%PATH%"
|
||||||
|
|
||||||
|
set "CGO_ENABLED=1"
|
||||||
|
set "GOOS=windows"
|
||||||
|
set "GOARCH=amd64"
|
||||||
|
|
||||||
|
for %%I in ("%OUTPUT%") do set "OUTDIR=%%~dpI"
|
||||||
|
if not exist "%OUTDIR%" mkdir "%OUTDIR%"
|
||||||
|
|
||||||
|
where windres.exe >nul 2>nul
|
||||||
|
if %ERRORLEVEL%==0 (
|
||||||
|
windres.exe -O coff -o cmd\pysentry\rsrc_windows_amd64.syso packaging\windows\pysentry.rc
|
||||||
|
)
|
||||||
|
|
||||||
|
"%GOEXE%" build -trimpath -ldflags "-s -w" -o "%OUTPUT%" .\cmd\pysentry
|
||||||
|
if errorlevel 1 exit /b 1
|
||||||
|
|
||||||
|
xcopy /E /I /Y assets "%OUTDIR%assets" >nul
|
||||||
|
|
||||||
|
echo Built %OUTPUT%
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
param(
|
|
||||||
[string]$Output = "dist\windows\pysentry.exe"
|
|
||||||
)
|
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
$go = "${env:ProgramFiles}\Go\bin\go.exe"
|
|
||||||
if (-not (Test-Path $go)) {
|
|
||||||
$go = "go"
|
|
||||||
}
|
|
||||||
|
|
||||||
$msys2Bin = "C:\msys64\ucrt64\bin"
|
|
||||||
if (Test-Path $msys2Bin) {
|
|
||||||
$env:Path = "$msys2Bin;$env:Path"
|
|
||||||
}
|
|
||||||
|
|
||||||
$env:CGO_ENABLED = "1"
|
|
||||||
$env:GOOS = "windows"
|
|
||||||
$env:GOARCH = "amd64"
|
|
||||||
|
|
||||||
New-Item -ItemType Directory -Force -Path (Split-Path $Output) | Out-Null
|
|
||||||
|
|
||||||
$windres = Get-Command windres.exe -ErrorAction SilentlyContinue
|
|
||||||
if ($windres) {
|
|
||||||
& $windres.Source -O coff -o .\cmd\pysentry\rsrc_windows_amd64.syso .\packaging\windows\pysentry.rc
|
|
||||||
}
|
|
||||||
|
|
||||||
& $go build -trimpath -ldflags "-s -w" -o $Output .\cmd\pysentry
|
|
||||||
|
|
||||||
Write-Host "Built $Output"
|
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package app
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pysentry/pysentry/internal/core"
|
"github.com/pysentry/pysentry/src/core"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
@@ -26,9 +27,6 @@ const noFolder = "No folder"
|
|||||||
type job = core.Job
|
type job = core.Job
|
||||||
type event = core.RunRecord
|
type event = core.RunRecord
|
||||||
|
|
||||||
//go:embed assets/pysentry-icon.png
|
|
||||||
var iconBytes []byte
|
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
a := app.NewWithID(appID)
|
a := app.NewWithID(appID)
|
||||||
a.SetIcon(loadAppIcon())
|
a.SetIcon(loadAppIcon())
|
||||||
@@ -41,7 +39,19 @@ func Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadAppIcon() fyne.Resource {
|
func loadAppIcon() fyne.Resource {
|
||||||
return fyne.NewStaticResource("pysentry-icon.png", iconBytes)
|
candidates := []string{}
|
||||||
|
if executable, err := os.Executable(); err == nil {
|
||||||
|
candidates = append(candidates, filepath.Join(filepath.Dir(executable), "assets", "pysentry-icon.png"))
|
||||||
|
}
|
||||||
|
if workingDir, err := os.Getwd(); err == nil {
|
||||||
|
candidates = append(candidates, filepath.Join(workingDir, "assets", "pysentry-icon.png"))
|
||||||
|
}
|
||||||
|
for _, path := range candidates {
|
||||||
|
if resource, err := fyne.LoadResourceFromPath(path); err == nil {
|
||||||
|
return resource
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return theme.ComputerIcon()
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureSystemTray(a fyne.App, w fyne.Window) {
|
func configureSystemTray(a fyne.App, w fyne.Window) {
|
||||||
@@ -630,10 +640,12 @@ func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObje
|
|||||||
}
|
}
|
||||||
|
|
||||||
func chooseFolder(w fyne.Window, target *widget.Entry) {
|
func chooseFolder(w fyne.Window, target *widget.Entry) {
|
||||||
dialog.ShowFolderOpen(func(uri fyne.ListableURI, err error) {
|
folderDialog := dialog.NewFolderOpen(func(uri fyne.ListableURI, err error) {
|
||||||
if err != nil || uri == nil {
|
if err != nil || uri == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
target.SetText(uri.Path())
|
target.SetText(uri.Path())
|
||||||
}, w)
|
}, w)
|
||||||
|
folderDialog.Resize(fyne.NewSize(900, 640))
|
||||||
|
folderDialog.Show()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user