Create hello-platform for Linux (#13)

Co-authored-by: Михаил Капелько <kornerr@gmail.com>
This commit is contained in:
kornerr authored and Михаил Капелько committed 2026-11-02 21:40:55 +01:00
1 parent 45ca185094
commit 614392c921
23 files changed
+4720 -7

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash -e
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
T=$SDIR/step
TARGET=hello-platform
STEP=0
source $T/buildLinux $TARGET
source $T/packageLinux $TARGET hello-platform
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash -e
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
T=$SDIR/step
STEP=0
source $T/runLinux hello-platform hello-platform
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash -e
TARGET=$1
STEP=$((STEP+1))
echo -e "\n> > > > Step №$STEP. Build '$TARGET' for Linux"
cd $SDIR/../ver-linux
swift build
@@ -4,4 +4,4 @@ TARGET=$1
STEP=$((STEP+1))
echo -e "\n> > > > Step №$STEP. Generate Dialect for '$TARGET'"
$SDIR/../../../../dialect/util/run-generator --file=$SDIR/../dialect.yml
$SDIR/../../../util/run-generator --file=$SDIR/../dialect.yml
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash -e
TARGET=$1
APP_NAME=$2
STEP=$((STEP+1))
echo -e "\n> > > > Step №$STEP. Make '$APP_NAME' Linux package for '$TARGET'"
APP_DIR="$SDIR/../ver-linux"
DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}"
BIN_DIR="$HOME/.local/bin"
APP_ID=org.opengamestudio.$TARGET
mkdir -p "$BIN_DIR" "$DATA_DIR/applications" "$DATA_DIR/icons/hicolor/1024x1024/apps"
cp "$APP_DIR/.build/debug/$TARGET" "$BIN_DIR/$TARGET"
cp "$SDIR/../../../res/AppIcon.png" \
"$DATA_DIR/icons/hicolor/1024x1024/apps/$APP_ID.png"
# Use an absolute executable path: graphical sessions may omit ~/.local/bin.
DESKTOP_FILE="$DATA_DIR/applications/$APP_ID.desktop"
cp "$SDIR/../../../res/linux-app.desktop" "$DESKTOP_FILE"
sed -i \
-e "s|%APP_NAME%|$APP_NAME|g" \
-e "s|%APP_EXEC%|$BIN_DIR/$TARGET|g" \
-e "s|%APP_ID%|$APP_ID|g" \
"$DESKTOP_FILE"
# Update icon cache for new icon to be visible
gtk-update-icon-cache --force --ignore-theme-index "$DATA_DIR/icons/hicolor"
update-desktop-database "$DATA_DIR/applications"
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash -e
TARGET=$1
APP_NAME=$2
STEP=$((STEP+1))
echo -e "\n> > > > Step №$STEP. Run Linux app for '$TARGET'"
gtk-launch "org.opengamestudio.$TARGET"
@@ -0,0 +1,19 @@
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "hello-platform",
dependencies: [
.package(url: "https://github.com/moreSwift/swift-cross-ui", branch: "v0.10.0")
],
targets: [
.executableTarget(
name: "hello-platform",
dependencies: [
.product(name: "GtkBackend", package: "swift-cross-ui"),
.product(name: "SwiftCrossUI", package: "swift-cross-ui")
],
path: "src"
)
]
)
@@ -0,0 +1,17 @@
import GtkBackend
import SwiftCrossUI
@main
struct HPApp: App {
var backend: GtkBackend {
GtkBackend(appIdentifier: "org.opengamestudio.hello-platform")
}
let delegate = HPAppDelegate()
var body: some Scene {
WindowGroup("Hello platform") {
HPView(delegate.hpVM)
}
}
}
@@ -0,0 +1,11 @@
import SwiftCrossUI
final class HPAppDelegate {
let hp = HPComponent()
let hpVM = HPVM()
init() {
otherSetupConsoleLogging(hp.ctrl, "HP")
hp.setup()
}
}
+1
View File
@@ -0,0 +1 @@
../../ver-mac/src/dialect.swift
+1
View File
@@ -0,0 +1 @@
../../../../../components/hp/linux/hp.swift
+1
View File
@@ -0,0 +1 @@
../../../../../components/hp/linux/hpVM.swift
@@ -0,0 +1 @@
../../../../../../components/hp/linux/view/HPView.swift
+1
View File
@@ -0,0 +1 @@
../../../../../components/other/other.swift