Skip to content

Commit

Permalink
Updates to KorGE 5.0.0 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz authored Sep 29, 2023
1 parent 2236b1b commit 4646acb
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 237 deletions.
60 changes: 16 additions & 44 deletions .github/workflows/deploy-js.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
# Deploy JS game to GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: [ "main", "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
env:
JAVA_DISTRIBUTION: zulu
JAVA_VERSION: 11

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Buid JS bundle
run: |
./gradlew jsBrowserProductionWebpack
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
- { uses: actions/checkout@v4 }
- { name: Set up JDK, uses: actions/setup-java@v3, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } }
- { name: Prepare Gradle, uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc } # v2.8.0
- { name: Buid JS bundle, run: ./gradlew jsBrowserProductionWebpack }
- name: Deploy 🚀 to GitHub Pages
uses: JamesIves/[email protected]
with:
# Upload entire repository
path: './build/distributions'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: github-pages # The branch the action should deploy to.
FOLDER: build/distributions # The folder the action should deploy.
CLEAN: true # Automatically remove deleted files from the deploy branch
17 changes: 8 additions & 9 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ name: Testing
on:
push

env:
JAVA_DISTRIBUTION: zulu
JAVA_VERSION: 11

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew jvmTest
- { uses: actions/checkout@v4 }
- { name: Set up JDK, uses: actions/setup-java@v3, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } }
- { name: Prepare Gradle, uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc } # v2.8.0
- { name: Build with Gradle, run: ./gradlew jvmTest }
13 changes: 0 additions & 13 deletions Dockerfile

This file was deleted.

142 changes: 1 addition & 141 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,145 +5,5 @@ You can open this project in IntelliJ IDEA by opening the folder or the build.gr

You can find this template at GitHub: <https://github.com/korlibs/korge-hello-world>

For Windows, change all the `./gradlew` for `gradlew.bat`.

You should use Gradle 5.5 or greater and Java 8 or greater.

Tasks related to specific targets, might not be available if the target is not enabled, make sure that the required targets are enabled/not commented out in the `korge {}` section inside `build.gradle.kts`.

## Compiling for the JVM (Desktop)

Inside IntelliJ you can go to the `src/commonMain/kotlin/main.kt` file and press the green ▶️ icon
that appears to the left of the `suspend fun main()` line.

Using gradle tasks on the terminal:

```bash
./gradlew runJvm # Runs the program
./gradlew packageJvmFatJar # Creates a FAT Jar with the program
./gradlew packageJvmFatJarProguard # Creates a FAT Jar with the program and applies Proguard to reduce the size
```

Fat JARs are stored in the `/build/libs` folder.

## Compiling for the Web

Using gradle tasks on the terminal:

```bash
./gradlew jsWeb # Outputs to /build/web
./gradlew jsWebMin # Outputs to /build/web-min (applying Dead Code Elimination)
./gradlew jsWebMinWebpack # Outputs to /build/web-min-webpack (minimizing and grouping into a single bundle.js file)
./gradlew runJs # Outputs to /build/web, creates a small http server and opens a browser
```

You can use any HTTP server to serve the files in your browser.
For example using: `npm -g install http-server` and then executing `hs build/web`.

You can also use `./gradlew -t jsWeb` to continuously building the JS sources and running `hs build/web` in another terminal.
Here you can find a `testJs.sh` script doing exactly this for convenience.

You can run your tests using Node.JS by calling `jsTest` or in a headless chrome with `jsTestChrome`.

## Compiling for Native Desktop (Windows, Linux and macOS)

Using gradle tasks on the terminal:

```bash
./gradlew linkDebugExecutableMacosX64 # Outputs to /build/bin/macosX64/mainDebugExecutable/main.kexe
./gradlew linkDebugExecutableLinuxX64 # Outputs to /build/bin/linuxX64/mainDebugExecutable/main.kexe
./gradlew linkDebugExecutableMingwX64 # Outputs to /build/bin/mingwX64/mainDebugExecutable/main.exe
```

Note that windows executables doesn't have icons bundled.
You can use [ResourceHacker](http://www.angusj.com/resourcehacker/) to add an icon to the executable for the moment.
Later this will be done automatically.

### Cross-Compiling for Linux/Windows

If you have docker installed, you can generate native executables for linux and windows
using the cross-compiling gradle wrappers:

```bash
./gradlew_linux linkDebugExecutableLinuxX64 # Outputs to /build/web
./gradlew_win linkDebugExecutableMingwX64 # Outputs to /build/web
```

### Generating MacOS `.app`

```bash
./gradlew packageMacosX64AppDebug # Outputs to /build/unnamed-debug.app
```

You can change `Debug` for `Release` in all the tasks to generate Release executables.

You can use the `strip` tool from your toolchain (or in the case of windows found in the ``~/.konan` toolchain)
to further reduce Debug and Release executables size by removing debug information (in some cases this will shrink the EXE size by 50%).

In windows this exe is at: `%USERPROFILE%\.konan\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1\bin\strip.exe`.

### Linux notes

Since linux doesn't provide standard multimedia libraries out of the box,
you will need to have installed the following packages: `freeglut3-dev` and `libopenal-dev`.

In ubuntu you can use `apt-get`: `sudo apt-get -y install freeglut3-dev libopenal-dev`.

## Compiling for Android

You will need to have installed the Android SDK in the default path for your operating system
or to provide the `ANDROID_SDK` environment variable. The easiest way is to install Android Studio.

Using gradle tasks on the terminal:

### Native Android (JVM)

```bash
./gradlew installAndroidDebug # Installs an APK in all the connected devices
./gradlew runAndroidEmulatorDebug # Runs the application in an emulator
```

Triggering these tasks, it generates a separate android project into `build/platforms/android`.
You can open it in `Android Studio` for debugging and additional tasks. The KorGE plugin just
delegates gradle tasks to that gradle project.

### Apache Cordova (JS)

```bash
./gradlew compileCordovaAndroid # Just compiles cordova from Android
./gradlew runCordovaAndroid # Runs the application (dce'd, minimized and webpacked) in an Android device
./gradlew runCordovaAndroidNoMinimized # Runs the application in Android without minimizing (so you can use `chrome://inspect` to debug the application easier)
```



## Compiling for iOS

You will need XCode and to download the iOS SDKs using Xcode.

Using gradle tasks on the terminal:

### Native iOS (Kotlin/Native) + Objective-C

Note that the necessary bridges are built using Objective-C instead of Swift, so the application
won't include Swift's runtime.

```bash
./gradlew iosBuildSimulatorDebug # Creates an APP file
./gradlew installIosSimulatorDebug # Installs an APP file in the simulator
./gradlew runIosSimulatorDebug # Runs the APP in the simulator

```

These tasks generate a xcode project in `build/platforms/ios`, so you can also open the project
with XCode and do additional tasks there.

It uses [XCodeGen](https://github.com/yonaskolb/XcodeGen) for the project generation
and [ios-deploy](https://github.com/ios-control/ios-deploy) for deploying to real devices.

## JS-game deployment to GitHub Pages
- Go to [settings page](../../settings) and enable GitHub Pages
- Choose branch `github-pages` and select folder `/ (root)`
- After that you can use link:
[link to JS-game](../../deployments/activity_log?environment=github-pages), click "View Deployment"
- When you push to main or master branch, - deployment process will start again with GitHub Actions.
You can find the KorGE documentation here: <https://docs.korge.org/korge/>
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
org.gradle.jvmargs=-Xmx4g
kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion=2
android.useAndroidX=true
org.gradle.warning.mode=none
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[plugins]
korge = { id = "com.soywiz.korge", version = "4.0.7" }
korge = { id = "com.soywiz.korge", version = "5.0.0" }
#korge = { id = "com.soywiz.korge", version = "999.0.0.999" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion gradlew11

This file was deleted.

1 change: 0 additions & 1 deletion gradlew8

This file was deleted.

9 changes: 0 additions & 9 deletions gradlew_linux

This file was deleted.

10 changes: 0 additions & 10 deletions gradlew_win

This file was deleted.

2 changes: 0 additions & 2 deletions gradlew_wine

This file was deleted.

20 changes: 15 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
pluginManagement { repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() } }
pluginManagement {
repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() }
}

// @TODO: Why can't we just use libs here? We can't even use a TOML parser since it is gradle internal, and we cannot load a library in a reasonably way here.
plugins {
//id("com.soywiz.kproject.settings") version "0.0.1-SNAPSHOT"
id("com.soywiz.kproject.settings") version "0.3.1"
}
val libsTomlFile = File("gradle/libs.versions.toml").readText()
var plugins = false
var version = ""
for (line in libsTomlFile.lines().map { it.trim() }) {
if (line.startsWith("#")) continue
if (line.startsWith("[plugins]")) plugins = true
if (plugins && line.startsWith("korge") && Regex("^korge\\s*=.*").containsMatchIn(line)) version = Regex("version\\s*=\\s*\"(.*?)\"").find(line)?.groupValues?.get(1) ?: error("Can't find korge version")
}
if (version.isEmpty()) error("Can't find korge version in $libsTomlFile")

kproject("./deps")
id("com.soywiz.korge.settings") version version
}

0 comments on commit 4646acb

Please sign in to comment.