diff options
| author | 2015-02-08 21:29:25 -0500 | |
|---|---|---|
| committer | 2015-02-08 21:29:25 -0500 | |
| commit | ed9b5cdfc648e86fd463bfa8d86b94c41671e14c (patch) | |
| tree | 2619bbc7e04dfa3b82f8dfd3b1d31f529766cd4b /build.py | |
| download | enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.tar.gz enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.tar.xz enigma-fork-ed9b5cdfc648e86fd463bfa8d86b94c41671e14c.zip | |
switch all classes to new signature/type system
Diffstat (limited to 'build.py')
| -rw-r--r-- | build.py | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/build.py b/build.py new file mode 100644 index 0000000..4729498 --- /dev/null +++ b/build.py | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | |||
| 2 | import os | ||
| 3 | import sys | ||
| 4 | |||
| 5 | # settings | ||
| 6 | PathSsjb = "../ssjb" | ||
| 7 | Author = "Cuchaz" | ||
| 8 | |||
| 9 | DirBin = "bin" | ||
| 10 | DirLib = "lib" | ||
| 11 | DirBuild = "build" | ||
| 12 | PathLocalMavenRepo = "../maven" | ||
| 13 | |||
| 14 | |||
| 15 | # import ssjb | ||
| 16 | sys.path.insert(0, PathSsjb) | ||
| 17 | import ssjb | ||
| 18 | import ssjb.ivy | ||
| 19 | |||
| 20 | |||
| 21 | ArtifactStandalone = ssjb.ivy.Dep("cuchaz:enigma:0.6b") | ||
| 22 | ArtifactLib = ssjb.ivy.Dep("cuchaz:enigma-lib:0.6b") | ||
| 23 | |||
| 24 | # dependencies | ||
| 25 | ExtraRepos = [ | ||
| 26 | "http://maven.cuchazinteractive.com" | ||
| 27 | ] | ||
| 28 | LibDeps = [ | ||
| 29 | ssjb.ivy.Dep("com.google.guava:guava:17.0"), | ||
| 30 | ssjb.ivy.Dep("org.javassist:javassist:3.18.1-GA"), | ||
| 31 | ssjb.ivy.Dep("org.bitbucket.mstrobel:procyon-decompiler:0.5.28-enigma") | ||
| 32 | ] | ||
| 33 | StandaloneDeps = LibDeps + [ | ||
| 34 | ssjb.ivy.Dep("de.sciss:jsyntaxpane:1.0.0") | ||
| 35 | ] | ||
| 36 | ProguardDep = ssjb.ivy.Dep("net.sf.proguard:proguard-base:5.1") | ||
| 37 | TestDeps = [ | ||
| 38 | ssjb.ivy.Dep("junit:junit:4.12"), | ||
| 39 | ssjb.ivy.Dep("org.hamcrest:hamcrest-all:1.3") | ||
| 40 | ] | ||
| 41 | |||
| 42 | # functions | ||
| 43 | |||
| 44 | def buildTestJar(name, glob): | ||
| 45 | |||
| 46 | pathJar = os.path.join(DirBuild, "%s.jar" % name) | ||
| 47 | pathObfJar = os.path.join(DirBuild, "%s.obf.jar" % name) | ||
| 48 | |||
| 49 | # build the deobf jar | ||
| 50 | with ssjb.file.TempDir("tmp") as dirTemp: | ||
| 51 | ssjb.file.copyTree(dirTemp, DirBin, ssjb.file.find(DirBin, "cuchaz/enigma/inputs/Keep.class")) | ||
| 52 | ssjb.file.copyTree(dirTemp, DirBin, ssjb.file.find(DirBin, glob)) | ||
| 53 | ssjb.jar.makeJar(pathJar, dirTemp) | ||
| 54 | |||
| 55 | # build the obf jar | ||
| 56 | ssjb.callJavaJar( | ||
| 57 | os.path.join(DirLib, "proguard.jar"), | ||
| 58 | ["@proguard.conf", "-injars", pathJar, "-outjars", pathObfJar] | ||
| 59 | ) | ||
| 60 | |||
| 61 | |||
| 62 | def applyReadme(dirTemp): | ||
| 63 | ssjb.file.copy(dirTemp, "license.APL2.txt") | ||
| 64 | ssjb.file.copy(dirTemp, "license.GPL3.txt") | ||
| 65 | ssjb.file.copy(dirTemp, "readme.txt") | ||
| 66 | |||
| 67 | |||
| 68 | def buildStandaloneJar(dirOut): | ||
| 69 | with ssjb.file.TempDir(os.path.join(dirOut, "tmp")) as dirTemp: | ||
| 70 | ssjb.file.copyTree(dirTemp, DirBin, ssjb.file.find(DirBin)) | ||
| 71 | for path in ssjb.ivy.getJarPaths(StandaloneDeps, ExtraRepos): | ||
| 72 | ssjb.jar.unpackJar(dirTemp, path) | ||
| 73 | ssjb.file.delete(os.path.join(dirTemp, "LICENSE.txt")) | ||
| 74 | ssjb.file.delete(os.path.join(dirTemp, "META-INF/maven")) | ||
| 75 | applyReadme(dirTemp) | ||
| 76 | manifest = ssjb.jar.buildManifest( | ||
| 77 | ArtifactStandalone.artifactId, | ||
| 78 | ArtifactStandalone.version, | ||
| 79 | Author, | ||
| 80 | "cuchaz.enigma.Main" | ||
| 81 | ) | ||
| 82 | pathJar = os.path.join(DirBuild, "%s.jar" % ArtifactStandalone.getName()) | ||
| 83 | ssjb.jar.makeJar(pathJar, dirTemp, manifest=manifest) | ||
| 84 | ssjb.ivy.deployJarToLocalMavenRepo(PathLocalMavenRepo, pathJar, ArtifactStandalone) | ||
| 85 | |||
| 86 | def buildLibJar(dirOut): | ||
| 87 | with ssjb.file.TempDir(os.path.join(dirOut, "tmp")) as dirTemp: | ||
| 88 | ssjb.file.copyTree(dirTemp, DirBin, ssjb.file.find(DirBin)) | ||
| 89 | applyReadme(dirTemp) | ||
| 90 | pathJar = os.path.join(DirBuild, "%s.jar" % ArtifactLib.getName()) | ||
| 91 | ssjb.jar.makeJar(pathJar, dirTemp) | ||
| 92 | ssjb.ivy.deployJarToLocalMavenRepo(PathLocalMavenRepo, pathJar, ArtifactLib, deps=LibDeps) | ||
| 93 | |||
| 94 | |||
| 95 | # tasks | ||
| 96 | |||
| 97 | def taskGetDeps(): | ||
| 98 | ssjb.file.mkdir(DirLib) | ||
| 99 | ssjb.ivy.makeLibsJar(os.path.join(DirLib, "deps.jar"), StandaloneDeps, extraRepos=ExtraRepos) | ||
| 100 | ssjb.ivy.makeLibsJar(os.path.join(DirLib, "test-deps.jar"), TestDeps) | ||
| 101 | ssjb.ivy.makeJar(os.path.join(DirLib, "proguard.jar"), ProguardDep) | ||
| 102 | |||
| 103 | def taskBuildTestJars(): | ||
| 104 | buildTestJar("testLoneClass", "cuchaz/enigma/inputs/loneClass/*.class") | ||
| 105 | buildTestJar("testConstructors", "cuchaz/enigma/inputs/constructors/*.class") | ||
| 106 | buildTestJar("testInheritanceTree", "cuchaz/enigma/inputs/inheritanceTree/*.class") | ||
| 107 | buildTestJar("testInnerClasses", "cuchaz/enigma/inputs/innerClasses/*.class") | ||
| 108 | buildTestJar("testTranslation", "cuchaz/enigma/inputs/translation/*.class") | ||
| 109 | |||
| 110 | def taskBuild(): | ||
| 111 | ssjb.file.delete(DirBuild) | ||
| 112 | ssjb.file.mkdir(DirBuild) | ||
| 113 | buildStandaloneJar(DirBuild) | ||
| 114 | buildLibJar(DirBuild) | ||
| 115 | |||
| 116 | ssjb.registerTask("getDeps", taskGetDeps) | ||
| 117 | ssjb.registerTask("buildTestJars", taskBuildTestJars) | ||
| 118 | ssjb.registerTask("build", taskBuild) | ||
| 119 | ssjb.run() | ||
| 120 | |||