Skip to content

Commit

Permalink
Meow ~
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiinaSekiu committed Jul 25, 2024
1 parent cc92d22 commit f0d5fc5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
36 changes: 23 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ buildscript {

buildConfig {
packageName("moe.sekiu.minilpa")
buildConfigField("IS_PACKAGED", gradle.startParameter.taskNames.firstOrNull() == "jpackage" || project.switchProperty("is-package"))
buildConfigField("IS_PACKAGED",
(gradle.startParameter.taskNames.firstOrNull() == "jpackage" || project.switchProperty("is-package"))
&& project.findProperty("type") != "app-image"
)
buildConfigField("VERSION", "$version")
}

Expand Down Expand Up @@ -142,7 +145,10 @@ task("setupResources")
if (!skip)
{
val lpacLatestBuildTime = latestRelease.createdAt.time
if (buildPath.resolve("lpac").notExists() || lpacLatestBuildTime > lpacBuildTime)
if (target == "all" ||
buildPath.resolve("lpac").notExists() ||
buildPath.resolve("lpac").resolve(target).notExists() ||
lpacLatestBuildTime > lpacBuildTime)
{
if (target == "all")
{
Expand All @@ -169,9 +175,6 @@ task("setupResources")
buildConfigField("EUICC_INFO_UPDATE_TIME", eUICCInfoUpdateTimePath.readText().toLong())
}
}



}

task("setupjpackage")
Expand Down Expand Up @@ -212,6 +215,7 @@ tasks.jpackage {
mainJar = archiveFileName
mainClass = application.mainClass.get()
javaOptions = mutableListOf("-Dfile.encoding=UTF-8")
addModules = listOf("java.base", "java.desktop", "java.naming", "jdk.unsupported")

if (project.hasProperty("type"))
{
Expand All @@ -220,26 +224,32 @@ tasks.jpackage {
}

if (project.hasProperty("native-wayland")) javaOptions.add("Dawt.toolkit.name=WLToolkit")
if (type != ImageType.APP_IMAGE)
{
windows {
icon = projectDir.toPath().resolve("src/main/icons/window.ico").pathString
windows {
icon = projectDir.toPath().resolve("src/main/icons/window.ico").pathString
if (type != ImageType.APP_IMAGE)
{
winDirChooser = true
winMenu = true
winMenuGroup = "MiniLPA"
winShortcut = true
winShortcutPrompt = true
}
}

linux {
icon = projectDir.toPath().resolve("src/main/icons/window.png").pathString
linux {
icon = projectDir.toPath().resolve("src/main/icons/window.png").pathString
if (type != ImageType.APP_IMAGE)
{
linuxShortcut = true
linuxMenuGroup = "MiniLPA"
installDir = "/usr/"
}
}

mac {
icon = projectDir.toPath().resolve("src/main/icons/window.icns").pathString
mac {
icon = projectDir.toPath().resolve("src/main/icons/window.icns").pathString
if (type != ImageType.APP_IMAGE)
{
macPackageIdentifier = "moe.sekiu.MiniLPA"
macAppCategory = "MiniLPA"
}
Expand Down
30 changes: 20 additions & 10 deletions scripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param(
[Switch]$NativeExecutable,

[ValidateSet('app-image', 'exe', 'msi', 'rpm', 'deb', 'pkg', 'dmg')]
[String]$NativeExecutableType=$null,
[String]$NativeExecutableType,

[Switch]$NativeWayland,

Expand All @@ -14,9 +14,9 @@ param(

$ErrorActionPreference = 'Stop'

$ProjectPath = Resolve-Path "$PSScriptRoot/../"
$ProjectRootPath = Resolve-Path "$PSScriptRoot/../"

$GradlewPath = Resolve-Path "$ProjectPath/gradlew"
$GradlewPath = Resolve-Path "$ProjectRootPath/gradlew"

if ($IsWindows)
{
Expand Down Expand Up @@ -46,20 +46,21 @@ if ($SkipSetupResources)
}
else
{
& "$PSScriptRoot/Update-Euicc-Manifests.ps1" -CheckExists
& "$PSScriptRoot/Update-Euicc-Info.ps1" -CheckExists
}

if ($GithubToken)
{
$BuildArgument += "-Pgithub-token=$GithubToken"
}

& {
Set-Location $ProjectPath
& $GradlewPath $BuildArgument --info --stacktrace
}
Push-Location $ProjectRootPath
& $GradlewPath $BuildArgument --info --stacktrace
Pop-Location

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

$DistFolderPath = "$ProjectPath/build/dist/"
$DistFolderPath = "$ProjectRootPath/build/dist/"

$OS = if ($IsWindows) { 'Windows' }
elseif ($IsLinux) { 'Linux' }
Expand All @@ -78,4 +79,13 @@ if ($NativeWayland)
$Name += '-Wayland'
}

Get-ChildItem -Path $DistFolderPath -File -Filter 'MiniLPA*' | ForEach-Object { Move-Item -Path $_.FullName -Destination "$DistFolderPath$Name$($_.Extension)" -Force }
if ($NativeExecutableType -eq 'app-image')
{
$AppImageFolderPath = "$DistFolderPath/MiniLPA"
Compress-Archive -Path "$AppImageFolderPath/*" -DestinationPath "$DistFolderPath/$Name.zip" -Force
Remove-Item -Path $AppImageFolderPath -Recurse -Force
}
else
{
Get-ChildItem -Path $DistFolderPath -File -Filter 'MiniLPA*' | ForEach-Object { Move-Item -Path $_.FullName -Destination "$DistFolderPath$Name$($_.Extension)" -Force }
}
File renamed without changes.
3 changes: 3 additions & 0 deletions src/main/kotlin/moe/sekiu/minilpa/CatMagic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package moe.sekiu.minilpa
import java.lang.invoke.MethodHandles
import sun.misc.Unsafe

/**
* Meow ~
*/
object CatMagic
{
val usf = with(Unsafe::class.java.getDeclaredField("theUnsafe"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/moe/sekiu/minilpa/model/Manifest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sealed class Manifest<T : Any>

fun loadManifests()
{
if (EumManifest.loadManifest() || CIManifest.loadManifest())
if (EumManifest.loadManifest() or CIManifest.loadManifest())
{
setting.update { `euicc-info-update-time` = BuildConfig.EUICC_INFO_UPDATE_TIME }
}
Expand Down

0 comments on commit f0d5fc5

Please sign in to comment.