-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
171 lines (147 loc) · 5.41 KB
/
build.xml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<project default="default">
<!--
1) Download this jar from http://groovy-lang.org/download.html
2) Update the classpath to match where you put it!
-->
<taskdef name="groovy"
classpath="C:\Users\mpand\Downloads\groovy-2.4.14\embeddable\groovy-all-2.4.14.jar"
classname="org.codehaus.groovy.ant.Groovy"/>
<property name="spiffs.file" value="spiffs.bin"/>
<property name="spiffs.dir" value="data"/>
<!--
Download this jar from https://github.com/littleyoda/EspStackTraceDecoder
if you want the stack trace tool to work. Update this property to point to it!
-->
<property name="stack.jar" value="C:\Users\mpand\Downloads\EspStackTraceDecoder.jar"/>
<echo> ${eclipse_home} </echo>
<groovy>
String getProperty(Properties props, String key, int level) {
def value = null
value = props.getProperty(key);
if (value != null) {
// Get the index of the first constant, if any
def beginIndex = 0;
def startName = value.indexOf('${', beginIndex);
while (startName != -1) {
if (level+1 > 5) {
// Exceeded MAX_SUBST_DEPTH
// Return the value as is
return value;
}
def endName = value.indexOf('}', startName + 1);
if (endName == -1) {
// Terminating symbol not found
// Return the value as is
return value;
}
def constName = value.substring(startName+2, endName);
def constValue = getProperty(props, constName, level+1);
if (constValue == null) {
// Property name not found
// Return the value as is
return value;
}
// Insert the constant value into the
// original property value
def newValue = (startName>0)
? value.substring(0, startName) : "";
newValue += constValue;
// Start checking for constants at this index
beginIndex = newValue.length();
// Append the remainder of the value
newValue += value.substring(endName+1);
value = newValue;
// Look for the next constant
startName = value.indexOf('${', beginIndex);
}
}
// Return the value as is
return value;
}
def props = new Properties()
props['eclipse_home'] = properties['eclipse_home']
props['project_loc'] = properties['project_loc']
new File(properties['project_loc'] + './.settings/org.eclipse.cdt.core.prefs').eachLine { line ->
if ((matcher = line =~ /.*\/([AJ].+)\/value=(.+)$/)) {
def val = matcher[0][2];
if (val != null) {
val = val.replace('\\:', ':');
}
props[matcher[0][1]] = val;
}
}
props.each{ k, v ->
properties[k] = getProperty(props, k, 0)
}
properties['A.BUILD.SPIFFS_SIZE'] = Integer.parseInt(properties['A.BUILD.SPIFFS_END'].substring(2),16) - Integer.parseInt(properties['A.BUILD.SPIFFS_START'].substring(2), 16)
</groovy>
<target name="stack">
<java jar="${stack.jar}" fork="true">
<arg value="${A.COMPILER.PATH}/xtensa-lx106-elf-addr2line"/>
<arg value="${project_loc}/Release/${project_name}.elf"/>
<arg value="${project_loc}/dump.txt"/>
</java>
</target>
<target name="erase flash">
<exec executable="${A.TOOLS.ESPTOOL.PATH}/${A.TOOLS.ESPTOOL.CMD}">
<arg value="-cd"/>
<arg value="${A.UPLOAD.RESETMETHOD}"/>
<arg value="-cb"/>
<arg value="${A.UPLOAD.SPEED}"/>
<arg value="-cp"/>
<arg value="${A.SERIAL.PORT}"/>
<arg value="-ce"/>
</exec>
</target>
<target name="OTA spiff upload" if="A.NETWORK.PORT">
<exec executable="${A.TOOLS.ESPTOOL.NETWORK_CMD}">
<arg value="${A.RUNTIME.PLATFORM.PATH}/tools/espota.py"/>
<arg value="-i"/>
<arg value="${A.SERIAL.PORT}"/>
<arg value="-p"/>
<arg value="${A.NETWORK.PORT}"/>
<arg value="-s"/>
<arg value="-f"/>
<arg value="${project_loc}/${spiffs.file}"/>
</exec>
</target>
<target name="wired spiff upload" unless="A.NETWORK.PORT">
<exec executable="${A.TOOLS.ESPTOOL.PATH}/${A.TOOLS.ESPTOOL.CMD}">
<arg value="-cd"/>
<arg value="${A.UPLOAD.RESETMETHOD}"/>
<arg value="-cb"/>
<arg value="${A.UPLOAD.SPEED}"/>
<arg value="-cp"/>
<arg value="${A.SERIAL.PORT}"/>
<arg value="-ca"/>
<arg value="${A.BUILD.SPIFFS_START}"/>
<arg value="-cf"/>
<arg value="${project_loc}/${spiffs.file}"/>
</exec>
</target>
<target name="spiff upload" depends="wired spiff upload,OTA spiff upload">
</target>
<target name="mkspiffs">
<echo message="-p ${A.BUILD.SPIFFS_PAGESIZE} -b ${A.BUILD.SPIFFS_BLOCKSIZE} -s ${A.BUILD.SPIFFS_SIZE}"></echo>
<exec executable="${A.TOOLS.MKSPIFFS.PATH}/${A.TOOLS.MKSPIFFS.CMD}">
<arg value="-d"/>
<arg value="5"/>
<arg value="-c"/>
<arg value="${project_loc}/${spiffs.dir}"/>
<arg value="-p"/>
<arg value="${A.BUILD.SPIFFS_PAGESIZE}"/>
<arg value="-b"/>
<arg value="${A.BUILD.SPIFFS_BLOCKSIZE}"/>
<arg value="-s"/>
<arg value="${A.BUILD.SPIFFS_SIZE}"/>
<arg value="${spiffs.file}"/>
</exec>
</target>
<target name="showspiffs">
<exec executable="${A.TOOLS.MKSPIFFS.PATH}/${A.TOOLS.MKSPIFFS.CMD}">
<arg value="-i"/>
<arg value="${spiffs.file}"/>
</exec>
</target>
<target name="default" depends="mkspiffs,spiff upload"/>
</project>