Skip to content

Commit

Permalink
Fix: fix build on windows (#2)
Browse files Browse the repository at this point in the history
* Fix: fix build on windows

* Fix: use invariantSeparatorsPath instead

* Fix: revert bump version
  • Loading branch information
Kr328 authored Nov 21, 2022
1 parent 7bc3f26 commit 08eba06
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object ZygoteLoaderDecorator {
val nativeLibs = artifacts.get(InternalArtifactType.MERGED_NATIVE_LIBS)
val dex = artifacts.getAll(InternalMultipleArtifactType.DEX).map { it.single() }

dependsOn(flattenAssets, generateInitialPackages, generateModuleProp, packing)
dependsOn(packing)

destinationDir = buildDir.resolve("intermediates/merged_magisk/${variant.name}")

Expand All @@ -103,9 +103,9 @@ object ZygoteLoaderDecorator {
fromKtx(dex) {
include("classes.dex")
}
fromKtx(flattenAssets.get().destinationDir.asFile.resolve("assets"))
fromKtx(generateInitialPackages.get().destinationDir)
fromKtx(generateModuleProp.get().destinationDir)
fromKtx(flattenAssets.flatMap { it.destinationDir.dir("assets") })
fromKtx(generateInitialPackages.flatMap { it.destinationDir })
fromKtx(generateModuleProp.flatMap { it.destinationDir })
}

val generateChecksum = tasks.registerKtx(
Expand All @@ -122,19 +122,19 @@ object ZygoteLoaderDecorator {
"generateCustomize$capitalized",
CustomizeTask::class,
) {
dependsOn(mergeMagisk, generateChecksum)
dependsOn(mergeMagisk)

destinationDir.set(buildDir.resolve("generated/customize_sh/${variant.name}"))

customizeFiles.set(mergeMagisk.get().destinationDir.resolve("customize.d"))
checksumFiles.set(generateChecksum.get().destinationDir.get().asFile.resolve("customize.d"))
checksumFiles.set(generateChecksum.flatMap { it.destinationDir.dir("customize.d") })
}

val packagingMagisk = tasks.registerKtx(
"packageMagisk$capitalized",
Zip::class
) {
dependsOn(mergeMagisk, generateCustomize)
dependsOn(mergeMagisk)

val destinationDir = buildDir.resolve("outputs/magisk")
.resolve("${variant.flavorName}")
Expand All @@ -151,8 +151,8 @@ object ZygoteLoaderDecorator {
isPreserveFileTimestamps = false

fromKtx(mergeMagisk.get().destinationDir)
fromKtx(generateCustomize.get().destinationDir)
fromKtx(generateChecksum.get().destinationDir)
fromKtx(generateCustomize.flatMap { it.destinationDir })
fromKtx(generateChecksum.flatMap { it.destinationDir })
}

tasks.getByName("assemble$capitalized").dependsOn(packagingMagisk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class ChecksumTask : DefaultTask() {

val script = root.walk()
.filter { it.isFile }
.map { it.relativeTo(root).path }
.map { it.relativeTo(root).invariantSeparatorsPath }
.filterNot { it.startsWith("META-INF") }
.sorted()
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ abstract class CustomizeTask : DefaultTask() {
val customizes = customizeFiles.get().asFile.listFiles()?.toList() ?: emptyList()
val checksums = checksumFiles.get().asFile.listFiles()?.toList() ?: emptyList()

val files = (customizes + checksums).sortedBy { it.name }
val files = (customizes + checksums).map { it.name }.sorted()

val customizeText = buildString {
appendLine("# Generated by ZygoteLoader. DO NOT EDIT.")
appendLine()
files.forEach {
appendLine("[ -f \"\$MODPATH/customize.d/${it.name}\" ] || abort \"! Part '${it.name}' not found\"")
appendLine(". \"\$MODPATH/customize.d/${it.name}\"")
appendLine("[ -f \"\$MODPATH/customize.d/$it\" ] || abort \"! Part '$it' not found\"")
appendLine(". \"\$MODPATH/customize.d/$it\"")
}
appendLine()
appendLine("rm -rf \"\$MODPATH/customize.d\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.kr328.gradle.zygote.tasks

import com.github.kr328.gradle.zygote.util.fromKtx
import com.github.kr328.gradle.zygote.util.syncKtx
import org.apache.tools.ant.filters.FixCrLfFilter
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.tasks.InputDirectory
Expand Down Expand Up @@ -31,6 +32,13 @@ abstract class FlattenTask : DefaultTask() {
.forEach { jar ->
from(project.zipTree(jar))
}

val crlf: Map<String, *> = mapOf("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
eachFile {
if (it.relativePath.startsWith("assets/META-INF") || it.name.endsWith(".sh")) {
it.filter(crlf, FixCrLfFilter::class.java)
}
}
}
}
}
2 changes: 1 addition & 1 deletion runtime/src/main/assets/customize.d/11-enforce-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

[ "$ARCH" != "arm" ] && [ "$ARCH" != "arm64" ] && [ "$ARCH" != "x86" ] && [ "$ARCH" != "x64" ] && abort "! Unsupported platform: $ARCH"

ui_print "- Device arch: $ARCH"
ui_print "- Device arch: $ARCH"

0 comments on commit 08eba06

Please sign in to comment.