-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,089 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.0.1' | ||
|
||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apply plugin: 'groovy' | ||
|
||
dependencies { | ||
implementation gradleApi() | ||
implementation localGroovy() | ||
} | ||
|
||
sourceCompatibility = "1.8" | ||
targetCompatibility = "1.8" |
26 changes: 26 additions & 0 deletions
26
buildSrc/src/main/groovy/net/idik/lib/cipher/so/extension/CipherSoExt.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.idik.lib.cipher.so.extension | ||
|
||
import org.gradle.api.NamedDomainObjectContainer | ||
import org.gradle.api.Project | ||
|
||
class CipherSoExt { | ||
|
||
NamedDomainObjectContainer<KeyExt> keys | ||
|
||
|
||
CipherSoExt(Project project) { | ||
keys = project.container(KeyExt) | ||
} | ||
|
||
def keys(Closure closure) { | ||
keys.configure closure | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return "CipherSoExt{" + | ||
"keys=" + keys + | ||
'}'; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
buildSrc/src/main/groovy/net/idik/lib/cipher/so/extension/KeyExt.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.idik.lib.cipher.so.extension | ||
|
||
class KeyExt { | ||
String name | ||
String value | ||
|
||
public KeyExt(String name) { | ||
this.name = name | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "KeyExt{" + | ||
"name='" + name + '\'' + | ||
", value='" + value + '\'' + | ||
'}'; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
buildSrc/src/main/groovy/net/idik/lib/cipher/so/plugin/CipherSoPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.idik.lib.cipher.so.plugin | ||
|
||
import net.idik.lib.cipher.so.extension.CipherSoExt | ||
import net.idik.lib.cipher.so.task.GenerateCipherSoHeaderTask | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class CipherSoPlugin implements Plugin<Project> { | ||
|
||
@Override | ||
void apply(Project project) { | ||
|
||
project.extensions.add("cipher", new CipherSoExt(project)) | ||
project.tasks.create("printKey", GenerateCipherSoHeaderTask) | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
buildSrc/src/main/groovy/net/idik/lib/cipher/so/task/GenerateCipherSoHeaderTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.idik.lib.cipher.so.task | ||
|
||
import net.idik.lib.cipher.so.extension.CipherSoExt | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
class GenerateCipherSoHeaderTask extends DefaultTask { | ||
|
||
public static final String TARGET_FILE_NAME = "extension_keys.h" | ||
private File targetFile | ||
|
||
GenerateCipherSoHeaderTask() { | ||
group = 'cipher.so' | ||
targetFile = findTargetNativeFile(project.buildDir) | ||
} | ||
|
||
@TaskAction | ||
void generate() { | ||
def keyContainer = project.cipher as CipherSoExt | ||
def writer = new FileWriter(targetFile) | ||
new SoHeaderBuilder(TARGET_FILE_NAME, keyContainer.keys.asList()).build().each { | ||
writer.append(it) | ||
} | ||
writer.flush() | ||
writer.close() | ||
} | ||
|
||
private File findTargetNativeFile(File rootFile) { | ||
File dir = new File(rootFile, "cipher.so/include/main/cpp") | ||
if (!dir.exists()) { | ||
dir.mkdirs() | ||
} | ||
return new File(dir, TARGET_FILE_NAME) | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
buildSrc/src/main/groovy/net/idik/lib/cipher/so/task/SoHeaderBuilder.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.idik.lib.cipher.so.task | ||
|
||
import net.idik.lib.cipher.so.extension.KeyExt | ||
|
||
class SoHeaderBuilder { | ||
|
||
List<KeyExt> keys | ||
|
||
String fileName | ||
|
||
SoHeaderBuilder(String fileName, List<KeyExt> keys) { | ||
this.fileName = fileName | ||
this.keys = keys | ||
} | ||
|
||
List<String> build() { | ||
List<String> lines = new ArrayList<>() | ||
lines.add("// Auto-Generated By Cipher.so - 林帅斌 [email protected]\n\n") | ||
lines.add("#ifndef CIPHER_EXTENSION_KEY_${fileName.replaceAll("\\.","_").toUpperCase(Locale.US)}\n") | ||
lines.add("#defind CIPHER_EXTENSION_KEY_${fileName.replaceAll("\\.","_").toUpperCase(Locale.US)}\n") | ||
keys.each { | ||
lines.add("const char* KEY_${it.name} = \"${it.value}\";\n") | ||
} | ||
lines.add("\n") | ||
lines.add("#endif //CIPHER_EXTENSION_KEY_${fileName.replaceAll("\\.","_").toUpperCase(Locale.US)}\n") | ||
lines | ||
} | ||
|
||
|
||
} |
1 change: 1 addition & 0 deletions
1
buildSrc/src/main/resources/META-INF/gradle-plugins/cipher.so.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
implementation-class=net.idik.lib.cipher.so.plugin.CipherSoPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx1536m | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Tue Dec 05 19:48:22 CST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip |
Oops, something went wrong.