forked from NationalSecurityAgency/ghidra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
153 lines (120 loc) · 3.99 KB
/
build.gradle
File metadata and controls
153 lines (120 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
apply plugin: 'eclipse'
eclipse.project.name = 'Features Base'
apply from: "$rootProject.projectDir/gradleScripts/buildHelp.gradle"
apply from: "$rootProject.projectDir/gradleScripts/ghidraScripts.gradle"
apply from: "$rootProject.projectDir/gradleScripts/developerScripts.gradle"
/*
This build file is a bit different than most project build files, as it initializes
tools needed for the system to compile some of the code. Also, this module has
a bit of custom help file generation.
*/
configurations {
javacc
}
dependencies {
compile project(':Utility')
compile project(':Generic')
compile project(':Docking')
compile project(':Graph')
compile project(':SoftwareModeling')
compile project(':DB')
compile project(':Demangler')
compile project(':Help')
compileOnly "junit:junit:4.12"
// These have abstract test classes and stubs needed by this module
testCompile project(':Docking').sourceSets.test.output
testCompile project(':Generic').sourceSets.test.output
testCompile project(':Project').sourceSets.test.output
testCompile project(':SoftwareModeling').sourceSets.test.output
javacc 'net.java.dev.javacc:javacc:5.0'
}
// add in the output of the javacc tasks to the java source
sourceSets {
main {
java {
srcDirs 'build/generated-src/javacc'
}
}
}
task buildCParser(type: JavaExec) {
group 'private'
description " Compiles the JavaCC files for the C parser\n"
def inputFile = "C.jj"
def packagePath = 'ghidra/app/util/cparser/C'
def srcDir = "src/main/javacc/${packagePath}"
inputs.files files("${srcDir}/${inputFile}")
def outputDir = "${projectDir}/build/generated-src/javacc/${packagePath}"
outputs.dir file("${outputDir}")
classpath = configurations.javacc
main = 'javacc'
workingDir = "${srcDir}"
args "-OUTPUT_DIRECTORY=${outputDir}"
// args "-DEBUG_PARSER=true"
args "${inputFile}"
}
task buildCPPParser(type: JavaExec) {
group 'private'
description " Compiles the JavaCC files for the CPP parser\n"
def inputFile = "CPP.jj"
def packagePath = 'ghidra/app/util/cparser/CPP'
def srcDir = "src/main/javacc/${packagePath}"
inputs.files files("${srcDir}/${inputFile}")
def outputDir = "${projectDir}/build/generated-src/javacc/${packagePath}"
outputs.dir file("${outputDir}")
classpath = configurations.javacc
main = 'javacc'
workingDir = "${srcDir}"
args "-OUTPUT_DIRECTORY=${outputDir}"
// args "-DEBUG_PARSER=true"
args "${inputFile}"
}
// A public task to tie together private sub-tasks
task buildJavacc {
dependsOn buildCParser, buildCPPParser
group rootProject.GHIDRA_GROUP
description " Compiles the JavaCC files\n"
}
// Note: this must happen before the standard buildHelp for Base
task generateExtraHelpFiles {
group = 'private'
description " Creates any extra help files for Base not covered by the standard build help system"
def rawTipsFile = file('src/main/resources/ghidra/app/plugin/core/totd/tips.txt')
inputs.file(rawTipsFile)
def htmlTipsFile = file('src/main/help/help/topics/Misc/Tips.htm')
outputs.file(htmlTipsFile)
doLast {
createTipsHelpFile(rawTipsFile, htmlTipsFile)
}
}
def createTipsHelpFile(input, output) {
// transform original contents - wrap each line in <li> tags
def buffy = new StringBuilder()
def rawLines = input.eachLine { line ->
def htmlized = line.replaceAll(/^(.*\w+.*)$/) { fullMatch, text -> "<li>$text</li><br>\n" }
buffy.append(htmlized)
}
// final output - wrap the updated content in the following HTML
def htmlContent = """\
<html>
<head>
<title>Ghidra Tips</title>
<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css" />
</head>
<body>
<h1><a name="Tips"></a>Ghidra Tips of the Day</h1>
<ul>
${buffy.toString()}
</ul>
</body>
</html>
"""
output.text = htmlContent
println '\n\n\nwrote file ' + output + '\n\n\n'
}
/*
Dependency Setup
*/
compileJava.dependsOn buildJavacc
prepDev.dependsOn buildJavacc
// 'indexHelp' is defined in the buildHelp.gradle 'script plugin'
indexHelp.dependsOn generateExtraHelpFiles