Fix build bug

This commit is contained in:
LoveSy 2020-11-17 17:58:13 +08:00 committed by 双草酸酯
parent 0ece9b141d
commit 14b85366a1
14 changed files with 77 additions and 241 deletions

View File

@ -23,7 +23,7 @@ allprojects {
templateLibPath = templateRootPath + "/system/lib/" templateLibPath = templateRootPath + "/system/lib/"
templateLib64Path = templateRootPath + "/system/lib64/" templateLib64Path = templateRootPath + "/system/lib64/"
templateEtcPath = templateRootPath + "/system/etc/" templateEtcPath = templateRootPath + "/system/etc/"
hiddenApiStubJarFilePath = project(":hiddenapi-stubs").projectDir.absolutePath + "/libs/framework-stub.jar" hiddenApiStubJarFilePath = project(":hiddenapi-stubs").buildDir.absolutePath + "/libs/framework-stub.jar"
} }
repositories { repositories {
google() google()

View File

@ -1,57 +1,33 @@
import org.gradle.internal.os.OperatingSystem apply plugin: 'com.android.application'
apply plugin: 'java-library'
dependencies { repositories {
implementation fileTree(dir: 'libs', include: ['*.jar']) jcenter()
} }
sourceCompatibility = "7" android {
targetCompatibility = "7" compileSdkVersion androidCompileSdkVersion.toInteger()
ndkVersion androidCompileNdkVersion
}
task findDx { afterEvaluate {
if (OperatingSystem.current().isWindows()){ android.applicationVariants.all { variant ->
return true def variantNameCapped = variant.name.capitalize()
def variantNameLowered = variant.name.toLowerCase()
task("copyDex${variantNameCapped}", type: Copy) {
dependsOn "assemble${variantNameCapped}"
def dexOutPath = "${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}"
from (dexOutPath){
rename("classes.dex", "eddalvikdx.dex")
} }
doLast { destinationDir file(templateRootPath + "system/framework/")
new ByteArrayOutputStream().withStream { os -> outputs.upToDateWhen { false }
exec {
commandLine "which", "dx"
standardOutput os
} }
rootProject.ext.dxPath = os.toString() task("makeJar${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") {
dependsOn "assemble${variantNameCapped}"
from "${buildDir}/intermediates/javac/${variantNameLowered}/classes"
baseName "dalvikdx"
outputs.file(archivePath)
} }
} }
} }
task makeDex(type: Exec) {
dependsOn jar
dependsOn findDx
def dexName = "classes.dex"
workingDir jar.destinationDir
if (OperatingSystem.current().isWindows()) {
executable "dx.bat"
args "--dex", "--output", dexName, "${jar.archiveName}"
} else {
executable "bash"
args rootProject.ext.dxPath.trim(), "--dex", "--output", dexName, "${jar.archiveName}"
}
}
task dex(type: Copy) {
dependsOn makeDex
from (jar.destinationDir) {
include "classes.dex"
rename "classes.dex", "eddalvikdx.dex"
}
destinationDir new File(projectDir, "dex")
}
task dexInJar(type: Jar) {
dependsOn makeDex
from "${jar.destinationDir}/classes.dex"
destinationDir jar.destinationDir
baseName "eddalvikdx"
onlyIf {
!jar.state.upToDate || !file(archiveName).exists()
}
}

View File

@ -0,0 +1 @@
<manifest package="com.elderdrivers.riru.edxp.eddalvikdx" />

View File

@ -1,47 +1,39 @@
import org.gradle.internal.os.OperatingSystem apply plugin: 'com.android.application'
apply plugin: 'java'
description = "A utility for doing compile or runtime code generation targeting Android's Dalvik VM" description = "A utility for doing compile or runtime code generation targeting Android's Dalvik VM"
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
repositories { repositories {
jcenter() jcenter()
} }
android {
compileSdkVersion androidCompileSdkVersion.toInteger()
ndkVersion androidCompileNdkVersion
}
dependencies { dependencies {
compileOnly project(':dalvikdx') compileOnly files(project(":dalvikdx").tasks.getByName("makeJarRelease").outputs)
} }
task makeDex(type: Exec) { afterEvaluate {
dependsOn jar android.applicationVariants.all { variant ->
def dexName = "classes.dex" def variantNameCapped = variant.name.capitalize()
workingDir jar.destinationDir def variantNameLowered = variant.name.toLowerCase()
if (OperatingSystem.current().isWindows()) {
executable "dx.bat"
args "--dex", "--output", dexName, "${jar.archiveName}"
} else {
executable "bash"
args rootProject.ext.dxPath.trim(), "--dex", "--output", dexName, "${jar.archiveName}"
}
}
task dex(type: Copy) { task("copyDex${variantNameCapped}", type: Copy) {
dependsOn makeDex dependsOn "assemble${variantNameCapped}"
from (jar.destinationDir) { def dexOutPath = "${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}"
include "classes.dex" from (dexOutPath){
rename "classes.dex", "eddexmaker.dex" rename("classes.dex", "eddexmaker.dex")
}
destinationDir file(templateRootPath + "system/framework/")
outputs.upToDateWhen { false }
}
task("makeJar${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") {
dependsOn "assemble${variantNameCapped}"
from "${buildDir}/intermediates/javac/${variantNameLowered}/classes"
baseName "dexmaker"
outputs.file(archivePath)
} }
destinationDir new File(projectDir, "dex")
}
task dexInJar(type: Jar) {
dependsOn makeDex
from "${jar.destinationDir}/classes.dex"
destinationDir jar.destinationDir
baseName "eddexmaker"
onlyIf {
!jar.state.upToDate || !file(archiveName).exists()
} }
} }

View File

@ -0,0 +1 @@
<manifest package="com.elderdrivers.riru.edxp.dexmaker" />

View File

@ -4,7 +4,7 @@ import org.gradle.internal.os.OperatingSystem
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
// Values set here will be overriden by AppVeyor, feel free to modify during development. // Values set here will be overriden by AppVeyor, feel free to modify during development.
def buildVersionName = 'v0.5.0.6' def buildVersionName = 'v0.5.0.8'
def buildVersionCode = 233 def buildVersionCode = 233
if (System.env.APPVEYOR_BUILD_VERSION != null) { if (System.env.APPVEYOR_BUILD_VERSION != null) {
@ -49,8 +49,8 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64' abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
cppFlags "-std=c++17 -ffixed-x18 -Qunused-arguments -frtti" cppFlags "-std=c++17 -ffixed-x18 -Qunused-arguments -frtti -fomit-frame-pointer"
cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti" cFlags "-std=gnu99 -ffixed-x18 -Qunused-arguments -frtti -fomit-frame-pointer"
arguments "-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion", arguments "-DRIRU_MODULE_API_VERSION=$moduleMaxRiruApiVersion",
"-DRIRU_MODULE_VERSION=$buildVersionCode", "-DRIRU_MODULE_VERSION=$buildVersionCode",
"-DRIRU_MODULE_VERSION_NAME:STRING=\"$buildVersionName\"" "-DRIRU_MODULE_VERSION_NAME:STRING=\"$buildVersionName\""
@ -86,62 +86,6 @@ android {
ndkVersion androidCompileNdkVersion ndkVersion androidCompileNdkVersion
} }
task copyDalvikdxDex {
def dexTask = tasks.getByPath(':dalvikdx:dex')
dependsOn dexTask
doLast {
copy {
from dexTask
into jar_dest_dir
}
}
onlyIf {
!dexTask.state.upToDate
}
}
task copyDexmakerDex {
def dexTask = tasks.getByPath(':dexmaker:dex')
dependsOn dexTask
doLast {
copy {
from dexTask
into jar_dest_dir
}
}
onlyIf {
!dexTask.state.upToDate
}
}
task copyDalvikdxJar {
def jarTask = tasks.getByPath(':dalvikdx:dexInJar')
dependsOn jarTask
doLast {
copy {
from jarTask
into jar_dest_dir
}
}
onlyIf {
!jarTask.state.upToDate || !file(jar_dest_dir + jarTask.archiveName).exists()
}
}
task copyDexmakerJar {
def jarTask = tasks.getByPath(':dexmaker:dexInJar')
dependsOn jarTask
doLast {
copy {
from jarTask
into jar_dest_dir
}
}
onlyIf {
!jarTask.state.upToDate || !file(jar_dest_dir + jarTask.archiveName).exists()
}
}
task cleanTemplate(type: Delete) { task cleanTemplate(type: Delete) {
delete file(templateSystemx86Path) delete file(templateSystemx86Path)
} }
@ -161,7 +105,9 @@ afterEvaluate {
def magiskModuleId = property("${backendLowered}" + "_module_id") def magiskModuleId = property("${backendLowered}" + "_module_id")
def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") { def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") {
dependsOn cleanTemplate, copyDalvikdxDex, copyDexmakerDex dependsOn cleanTemplate
dependsOn tasks.getByPath(":dexmaker:copyDex${variantCapped}")
dependsOn tasks.getByPath(":dalvikdx:copyDex${variantCapped}")
dependsOn tasks.getByPath(":edxp-${backendLowered}:copyDex${variantCapped}") dependsOn tasks.getByPath(":edxp-${backendLowered}:copyDex${variantCapped}")
} }

View File

@ -29,7 +29,7 @@ dependencies {
compileOnly project(':hiddenapi-stubs') compileOnly project(':hiddenapi-stubs')
implementation project(':edxp-common') implementation project(':edxp-common')
implementation 'com.swift.sandhook:hooklib:4.2.1' implementation 'com.swift.sandhook:hooklib:4.2.1'
compileOnly project(':dexmaker') compileOnly files(project(":dexmaker").tasks.getByName("makeJarRelease").outputs)
} }
@ -58,8 +58,6 @@ afterEvaluate {
def variantNameCapped = variant.name.capitalize() def variantNameCapped = variant.name.capitalize()
def variantNameLowered = variant.name.toLowerCase() def variantNameLowered = variant.name.toLowerCase()
def myTemplatePath = "${projectDir}/template_override/"
task("copyDex${variantNameCapped}", type: Copy) { task("copyDex${variantNameCapped}", type: Copy) {
dependsOn "assemble${variantNameCapped}" dependsOn "assemble${variantNameCapped}"
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties") dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
@ -68,32 +66,9 @@ afterEvaluate {
rename("classes.dex", "edxp.dex") rename("classes.dex", "edxp.dex")
} }
from "${projectDir}/src/main/resources/" from "${projectDir}/src/main/resources/"
destinationDir file(myTemplatePath + "system/framework/") destinationDir file(templateRootPath + "system/framework/")
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
}
}
}
task("makeAndCopy${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") {
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
def dexOutPath = "${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}"
from (dexOutPath){
rename("classes.dex", "edxp.dex")
}
from "${projectDir}/src/main/resources/"
destinationDir file(myTemplatePath + "system/framework/")
baseName "edxp"
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
include "*.dex"
}
}
outputs.upToDateWhen { false } outputs.upToDateWhen { false }
} }
} }
} }

View File

@ -28,7 +28,7 @@ android {
dependencies { dependencies {
compileOnly project(':hiddenapi-stubs') compileOnly project(':hiddenapi-stubs')
implementation project(':edxp-common') implementation project(':edxp-common')
compileOnly project(':dexmaker') compileOnly files(project(":dexmaker").tasks.getByName("makeJarRelease").outputs)
} }
@ -57,8 +57,6 @@ afterEvaluate {
def variantNameCapped = variant.name.capitalize() def variantNameCapped = variant.name.capitalize()
def variantNameLowered = variant.name.toLowerCase() def variantNameLowered = variant.name.toLowerCase()
def myTemplatePath = "${projectDir}/template_override/"
task("copyDex${variantNameCapped}", type: Copy) { task("copyDex${variantNameCapped}", type: Copy) {
dependsOn "assemble${variantNameCapped}" dependsOn "assemble${variantNameCapped}"
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties") dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
@ -67,30 +65,7 @@ afterEvaluate {
rename("classes.dex", "edxp.dex") rename("classes.dex", "edxp.dex")
} }
from "${projectDir}/src/main/resources/" from "${projectDir}/src/main/resources/"
destinationDir file(myTemplatePath + "system/framework/") destinationDir file(templateRootPath + "system/framework/")
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
include "*.dex"
}
}
}
task("makeAndCopy${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") {
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
def dexOutPath = variant.name.contains("release") ?
"${buildDir}/intermediates/transforms/dexMerger/${variantNameLowered}/0/" :
"${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}/out/"
from dexOutPath, "${projectDir}/src/main/resources/"
destinationDir file(myTemplatePath + "system/framework/")
baseName "edxp"
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
}
}
outputs.upToDateWhen { false } outputs.upToDateWhen { false }
} }
} }

View File

@ -28,7 +28,7 @@ android {
dependencies { dependencies {
compileOnly project(':hiddenapi-stubs') compileOnly project(':hiddenapi-stubs')
implementation project(':edxp-common') implementation project(':edxp-common')
compileOnly project(':dexmaker') compileOnly files(project(":dexmaker").tasks.getByName("makeJarRelease").outputs)
} }
@ -57,8 +57,6 @@ afterEvaluate {
def variantNameCapped = variant.name.capitalize() def variantNameCapped = variant.name.capitalize()
def variantNameLowered = variant.name.toLowerCase() def variantNameLowered = variant.name.toLowerCase()
def myTemplatePath = "${projectDir}/template_override/"
task("copyDex${variantNameCapped}", type: Copy) { task("copyDex${variantNameCapped}", type: Copy) {
dependsOn "assemble${variantNameCapped}" dependsOn "assemble${variantNameCapped}"
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties") dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
@ -67,31 +65,9 @@ afterEvaluate {
rename("classes.dex", "edxp.dex") rename("classes.dex", "edxp.dex")
} }
from "${projectDir}/src/main/resources/" from "${projectDir}/src/main/resources/"
destinationDir file(myTemplatePath + "system/framework/") destinationDir file(templateRootPath + "system/framework/")
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
}
}
}
task("makeAndCopy${variantNameCapped}", type: Jar, dependsOn: "assemble${variantNameCapped}") {
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
def dexOutPath = variant.name.contains("release") ?
"${buildDir}/intermediates/transforms/dexMerger/${variantNameLowered}/0/" :
"${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}/out/"
from dexOutPath, "${projectDir}/src/main/resources/"
destinationDir file(myTemplatePath + "system/framework/")
baseName "edxp"
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
include "*.dex"
}
}
outputs.upToDateWhen { false } outputs.upToDateWhen { false }
} }
} }
} }

View File

@ -1,2 +1,2 @@
androidCompileSdkVersion=30 androidCompileSdkVersion=30
androidCompileNdkVersion=22.0.6917172 rc1 androidCompileNdkVersion=22.0.6917172

View File

@ -1 +1,2 @@
/build /build
/libs

View File

@ -1,23 +1,15 @@
import com.android.builder.core.BuilderConstants
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion androidCompileSdkVersion.toInteger() compileSdkVersion androidCompileSdkVersion.toInteger()
ndkVersion androidCompileNdkVersion
} }
task makeStubJar(type: Jar){ task makeStubJar(type: Jar){
dependsOn assemble dependsOn assemble
baseName 'framework-stub' baseName 'framework-stub'
from("${projectDir}/build/intermediates/javac/release/classes/") from("${buildDir}/intermediates/javac/release/classes/")
into('')
destinationDir file("${projectDir}/libs")
exclude('BuildConfig.class', 'R.class') exclude('BuildConfig.class', 'R.class')
exclude{ it.name.startsWith('R$')} exclude{ it.name.startsWith('R$')}
} outputs.file(archivePath)
afterEvaluate {
tasks.withType(JavaCompile) {
it.finalizedBy(makeStubJar)
}
} }

View File

@ -2,6 +2,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion androidCompileSdkVersion.toInteger() compileSdkVersion androidCompileSdkVersion.toInteger()
ndkVersion androidCompileNdkVersion
defaultConfig { defaultConfig {
minSdkVersion 26 minSdkVersion 26
@ -38,8 +39,8 @@ preBuild.doLast {
} }
dependencies { dependencies {
compileOnly project(':hiddenapi-stubs') compileOnly files(project(":dexmaker").tasks.getByName("makeJarRelease").outputs)
compileOnly project(':dexmaker') compileOnly files(project(":hiddenapi-stubs").tasks.getByName("makeStubJar").outputs)
} }
afterEvaluate { afterEvaluate {