diff --git a/.gitignore b/.gitignore index 859ac11b..1534ef1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /.gradle /baksmali/build /dexlib/build -/smali/target +/smali/build /util/build /maven-smali-plugin/target /smali-integration-tests/target diff --git a/settings.gradle b/settings.gradle index 695e3e6c..56639a8b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include 'util', 'dexlib', 'baksmali' \ No newline at end of file +include 'util', 'dexlib', 'baksmali', 'smali' \ No newline at end of file diff --git a/smali/.gitignore b/smali/.gitignore deleted file mode 100644 index ea8c4bf7..00000000 --- a/smali/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/smali/build.gradle b/smali/build.gradle new file mode 100644 index 00000000..1da62084 --- /dev/null +++ b/smali/build.gradle @@ -0,0 +1,78 @@ +configurations { + antlr3 + jflex +} + +ext.antlrSource = 'src/main/antlr3' +ext.antlrOutput = file(new File(buildDir, '/generated-sources/antlr3')) + +ext.jflexSource = "src/main/jflex" +ext.jflexOutput = file(new File(buildDir, '/generated-sources/jflex')) + +ext.testAntlrSource = 'src/test/antlr3' +ext.testAntlrOutput = file(new File(buildDir, '/generated-test-sources/antlr3')) + +sourceSets.main.java.srcDir antlrOutput +sourceSets.main.java.srcDir jflexOutput + +sourceSets.test.java.srcDir testAntlrOutput + +dependencies { + compile project(':util') + compile project(':dexlib') + compile 'org.antlr:antlr-runtime:3.2' + compile 'commons-cli:commons-cli:1.2' + + testCompile 'junit:junit:4.6' + + antlr3 'org.antlr:antlr:3.2' + jflex 'de.jflex:jflex:1.4.3' +} + +task generateAntlrSource { + inputs.dir file(antlrSource) + outputs.dir file(antlrOutput) + doLast { + mkdir(antlrOutput) + + def grammars = fileTree(antlrSource).include('**/*.g') + + ant.java(classname: 'org.antlr.Tool', classpath: configurations.antlr3.asPath, fork: true) { + arg(line: '-fo ' + antlrOutput + '/org/jf/smali') + arg(line: grammars.files.join(" ")) + } + } +} + +task generateTestAntlrSource { + inputs.dir file(testAntlrSource) + outputs.dir file(testAntlrOutput) + doLast { + mkdir(testAntlrOutput) + + def grammars = fileTree(testAntlrSource).include('**/*.g') + + ant.java(classname: 'org.antlr.Tool', classpath: configurations.antlr3.asPath, fork: true) { + arg(line: '-fo ' + testAntlrOutput + '/org/jf/smali') + arg(line: grammars.files.join(" ")) + } + } +} + +task generateJflexSource { + inputs.dir file(jflexSource) + outputs.dir file(jflexOutput) + doLast { + mkdir(jflexOutput) + + def grammars = fileTree(jflexSource).include('**/*.flex') + + ant.java(classname: 'JFlex.Main', classpath: configurations.jflex.asPath, fork: true) { + arg(line: '-d ' + jflexOutput + '/org/jf/smali') + arg(line: grammars.files.join(" ")) + } + } +} + +compileJava.dependsOn generateAntlrSource, generateJflexSource +compileTestJava.dependsOn generateTestAntlrSource diff --git a/smali/pom.xml b/smali/pom.xml deleted file mode 100644 index 030dfaa7..00000000 --- a/smali/pom.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - 4.0.0 - org.jf - smali - ${aversion} - - org.jf - smali-pom - 1.0-SNAPSHOT - - - - - de.jflex - maven-jflex-plugin - 1.4.3 - - - - generate - - - - - - org.antlr - antlr3-maven-plugin - 3.2 - - - smaliLexer - - antlr - - - - org/jf/smali/smaliLexer.g - - - - - smaliParser - - antlr - - - - org/jf/smali/smaliParser.g - - - - - smaliTreeWalker - - antlr - - - - org/jf/smali/smaliTreeWalker.g - - - - - expectedTokensTestGrammar - generate-test-sources - - antlr - - - src/test/antlr3 - target/generated-test-sources/antlr3 - - org/jf/smali/expectedTokensTestGrammar.g - - - - - - - maven-assembly-plugin - - - jar-with-dependencies - - - - org.jf.smali.main - - - - - - package - - single - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.2 - - - add generated test sources - generate-sources - - add-test-source - - - - target/generated-test-sources - - - - - - - com.github.wvengen - proguard-maven-plugin - 2.0.5 - - - package - - proguard - - - - - 4.8 - false - false - ${project.build.finalName}-jar-with-dependencies.jar - ${project.build.finalName}-jar-with-dependencies-small.jar - ${project.build.directory} - - - - - - - - - - - - - ${java.home}/lib/rt.jar - - - - - net.sf.proguard - proguard-base - 4.8 - - - - - - - src/main/resources - true - - - - - - org.antlr - antlr-runtime - 3.2 - - - org.jf - dexlib - ${version} - - - org.jf - util - ${version} - - - commons-cli - commons-cli - 1.2 - - - \ No newline at end of file diff --git a/smali/src/main/antlr3/org/jf/smali/smaliLexer.g b/smali/src/main/antlr3/smaliLexer.g similarity index 100% rename from smali/src/main/antlr3/org/jf/smali/smaliLexer.g rename to smali/src/main/antlr3/smaliLexer.g diff --git a/smali/src/main/antlr3/org/jf/smali/smaliParser.g b/smali/src/main/antlr3/smaliParser.g similarity index 100% rename from smali/src/main/antlr3/org/jf/smali/smaliParser.g rename to smali/src/main/antlr3/smaliParser.g diff --git a/smali/src/main/antlr3/org/jf/smali/smaliTreeWalker.g b/smali/src/main/antlr3/smaliTreeWalker.g similarity index 100% rename from smali/src/main/antlr3/org/jf/smali/smaliTreeWalker.g rename to smali/src/main/antlr3/smaliTreeWalker.g