summaryrefslogtreecommitdiff
path: root/build.py
diff options
context:
space:
mode:
authorGravatar jeff2015-02-08 21:29:25 -0500
committerGravatar jeff2015-02-08 21:29:25 -0500
commited9b5cdfc648e86fd463bfa8d86b94c41671e14c (patch)
tree2619bbc7e04dfa3b82f8dfd3b1d31f529766cd4b /build.py
downloadenigma-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.py120
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
2import os
3import sys
4
5# settings
6PathSsjb = "../ssjb"
7Author = "Cuchaz"
8
9DirBin = "bin"
10DirLib = "lib"
11DirBuild = "build"
12PathLocalMavenRepo = "../maven"
13
14
15# import ssjb
16sys.path.insert(0, PathSsjb)
17import ssjb
18import ssjb.ivy
19
20
21ArtifactStandalone = ssjb.ivy.Dep("cuchaz:enigma:0.6b")
22ArtifactLib = ssjb.ivy.Dep("cuchaz:enigma-lib:0.6b")
23
24# dependencies
25ExtraRepos = [
26 "http://maven.cuchazinteractive.com"
27]
28LibDeps = [
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]
33StandaloneDeps = LibDeps + [
34 ssjb.ivy.Dep("de.sciss:jsyntaxpane:1.0.0")
35]
36ProguardDep = ssjb.ivy.Dep("net.sf.proguard:proguard-base:5.1")
37TestDeps = [
38 ssjb.ivy.Dep("junit:junit:4.12"),
39 ssjb.ivy.Dep("org.hamcrest:hamcrest-all:1.3")
40]
41
42# functions
43
44def 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
62def 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
68def 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
86def 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
97def 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
103def 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
110def taskBuild():
111 ssjb.file.delete(DirBuild)
112 ssjb.file.mkdir(DirBuild)
113 buildStandaloneJar(DirBuild)
114 buildLibJar(DirBuild)
115
116ssjb.registerTask("getDeps", taskGetDeps)
117ssjb.registerTask("buildTestJars", taskBuildTestJars)
118ssjb.registerTask("build", taskBuild)
119ssjb.run()
120