Skip to content

Commit

Permalink
Fix compilation errors caused by prefab_bypass.gradle.
Browse files Browse the repository at this point in the history
  • Loading branch information
caikelun committed Jan 6, 2025
1 parent 4d647d2 commit e9cb1b7
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 52 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ByteHook

![](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)
![](https://img.shields.io/badge/release-1.1.0-red.svg?style=flat)
![](https://img.shields.io/badge/release-1.1.1-red.svg?style=flat)
![](https://img.shields.io/badge/Android-4.1%20--%2015-blue.svg?style=flat)
![](https://img.shields.io/badge/arch-armeabi--v7a%20%7C%20arm64--v8a%20%7C%20x86%20%7C%20x86__64-blue.svg?style=flat)

Expand Down Expand Up @@ -47,7 +47,7 @@ android {
}
dependencies {
implementation 'com.bytedance:bytehook:1.1.0'
implementation 'com.bytedance:bytehook:1.1.1'
}
```

Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ByteHook

![](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)
![](https://img.shields.io/badge/release-1.1.0-red.svg?style=flat)
![](https://img.shields.io/badge/release-1.1.1-red.svg?style=flat)
![](https://img.shields.io/badge/Android-4.1%20--%2015-blue.svg?style=flat)
![](https://img.shields.io/badge/arch-armeabi--v7a%20%7C%20arm64--v8a%20%7C%20x86%20%7C%20x86__64-blue.svg?style=flat)

Expand Down Expand Up @@ -47,7 +47,7 @@ android {
}
dependencies {
implementation 'com.bytedance:bytehook:1.1.0'
implementation 'com.bytedance:bytehook:1.1.1'
}
```

Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ ext {
ndkVersion = "23.2.8568313"
cmakeVersion = "3.30.5"
shadowhookVersion = "1.1.1"
// abiFilters = "armeabi-v7a,arm64-v8a,x86,x86_64"
abiFilters = "armeabi-v7a,arm64-v8a,x86,x86_64"
useASAN = false
dependencyOnLocalLibrary = true

POM_GROUP_ID = "com.bytedance"
POM_ARTIFACT_ID = "bytehook"
POM_VERSION_NAME = "1.1.0"
POM_VERSION_NAME = "1.1.1"

POM_NAME = "bytehook"
POM_DESCRIPTION = "ByteHook is an Android PLT hook library which supports armeabi-v7a, arm64-v8a, x86 and x86_64."
Expand Down
2 changes: 1 addition & 1 deletion bytehook/src/main/cpp/include/bytehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include <stdbool.h>
#include <stdint.h>

#define BYTEHOOK_VERSION "1.1.0"
#define BYTEHOOK_VERSION "1.1.1"

#define BYTEHOOK_STATUS_CODE_OK 0
#define BYTEHOOK_STATUS_CODE_UNINIT 1
Expand Down
2 changes: 1 addition & 1 deletion bytehook_sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dependencies {
if (rootProject.ext.dependencyOnLocalLibrary) {
implementation project(':bytehook')
} else {
implementation 'com.bytedance:bytehook:1.1.0'
implementation 'com.bytedance:bytehook:' + rootProject.ext.POM_VERSION_NAME
}
implementation project(':bytehook_systest')
}
Expand Down
2 changes: 1 addition & 1 deletion bytehook_systest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dependencies {
if (rootProject.ext.dependencyOnLocalLibrary) {
implementation project(':bytehook')
} else {
implementation 'com.bytedance:bytehook:1.1.0'
implementation 'com.bytedance:bytehook:' + rootProject.ext.POM_VERSION_NAME
}
}
apply from: rootProject.file('gradle/prefab_bypass.gradle')
77 changes: 34 additions & 43 deletions gradle/prefab_bypass.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,43 @@

project.afterEvaluate {
def archList = ["x86", "x86_64"]
for(arch in archList) {
def abiName = "$arch"
def dirName = "android.$arch"
tasks."configureCMakeDebug[$arch]".doFirst {
def prefabPackageFiles = abi.variant.prefabPackages.files
for (File file : prefabPackageFiles) {
def libsDir = findFirstLibsSubdirectory(file)
def libsArchDir = new File(libsDir, dirName)
if (!libsArchDir.exists()) {
libsArchDir.mkdirs()
def abiJsonFile = new File(libsArchDir, "abi.json")
def abiContent = "{\n" +
" \"abi\": \"$abiName\",\n" +
" \"api\": 16,\n" +
" \"ndk\": 23,\n" +
" \"stl\": \"none\",\n" +
" \"static\": false\n" +
"}"
abiJsonFile.write(abiContent)
def dummySoFile = new File(libsArchDir, "libshadowhook.so")
dummySoFile.createNewFile()
}
}
}
tasks."configureCMakeRelWithDebInfo[$arch]".doFirst {
def prefabPackageFiles = abi.variant.prefabPackages.files
for (File file : prefabPackageFiles) {
def libsDir = findFirstLibsSubdirectory(file)
def libsArchDir = new File(libsDir, dirName)
if (!libsArchDir.exists()) {
libsArchDir.mkdirs()
def abiJsonFile = new File(libsArchDir, "abi.json")
def abiContent = "{\n" +
" \"abi\": \"$abiName\",\n" +
" \"api\": 16,\n" +
" \"ndk\": 23,\n" +
" \"stl\": \"none\",\n" +
" \"static\": false\n" +
"}"
abiJsonFile.write(abiContent)
def dummySoFile = new File(libsArchDir, "libshadowhook.so")
dummySoFile.createNewFile()

// Helper function to configure prefab for a specific task
def configurePrefabForTask = { taskName, arch, dirName, abiName ->
def task = tasks.findByName("${taskName}[$arch]")
if (task != null) {
task.doFirst {
def prefabPackageFiles = abi.variant.prefabPackages.files
for (File file : prefabPackageFiles) {
def libsDir = findFirstLibsSubdirectory(file)
def libsArchDir = new File(libsDir, dirName)
if (!libsArchDir.exists()) {
libsArchDir.mkdirs()
def abiJsonFile = new File(libsArchDir, "abi.json")
def abiContent = """
{
"abi": "$abiName",
"api": 16,
"ndk": 23,
"stl": "none",
"static": false
}""".stripIndent()
abiJsonFile.write(abiContent)
def dummySoFile = new File(libsArchDir, "libshadowhook.so")
dummySoFile.createNewFile()
}
}
}
}
}

// Configure tasks for each architecture
for(arch in archList) {
def abiName = "$arch"
def dirName = "android.$arch"
configurePrefabForTask("configureCMakeDebug", arch, dirName, abiName)
configurePrefabForTask("configureCMakeRelWithDebInfo", arch, dirName, abiName)
}
}

def findFirstLibsSubdirectory(File baseDir) {
Expand All @@ -84,4 +75,4 @@ def findFirstLibsSubdirectory(File baseDir) {
}
}
return result
}
}

0 comments on commit e9cb1b7

Please sign in to comment.