@@ -23,11 +23,12 @@ lto=${lto:-false}
23
23
# Default to linux building if nothing else set
24
24
host=${host:- linux}
25
25
EXE=" "
26
+ MKSPIFFSTGT=" linux"
26
27
case " $host " in
27
28
linux) HOST=" x86_64-linux-gnu" ; AHOST=" x86_64-pc-linux-gnu" ; EXT=" .x86_64" ;;
28
- win32) HOST=" i686-w64-mingw32" ; AHOST=" i686-mingw32" ; EXT=" .win32" ; EXE=" .exe" ;;
29
- win64) HOST=" x86_64-w64-mingw32" ; AHOST=" x86_64-mingw32" ; EXT=" .win64" ; EXE=" .exe" ;;
30
- osx) HOST=" x86_64-apple-darwin14" ; AHOST=" x86_64-apple-darwin" ; EXT=" .osx" ;;
29
+ win32) HOST=" i686-w64-mingw32" ; AHOST=" i686-mingw32" ; EXT=" .win32" ; EXE=" .exe" ; MKSPIFFSTGT= ' windows ' ; ;
30
+ win64) HOST=" x86_64-w64-mingw32" ; AHOST=" x86_64-mingw32" ; EXT=" .win64" ; EXE=" .exe" ; MKSPIFFSTGT= ' windows ' ; ;
31
+ osx) HOST=" x86_64-apple-darwin14" ; AHOST=" x86_64-apple-darwin" ; EXT=" .osx" ; MKSPIFFSTGT= ' osx ' ; ;
31
32
arm64) HOST=" aarch64-linux-gnu" ; AHOST=" aarch64-linux-gnu" ; EXT=" .arm64" ;;
32
33
rpi) HOST=" arm-linux-gnueabihf" ; AHOST=" arm-linux-gnueabihf" ; EXT=" .rpi" ;;
33
34
* ) echo " Specify host as linux, win32, win64, osx, arm64, or rpi" ; exit 2;;
@@ -39,7 +40,7 @@ cleangit ()
39
40
echo " cleaning $1 "
40
41
cd dl/$1
41
42
git reset --hard HEAD
42
- git clean -f -d
43
+ git clean -f -d >& /dev/null
43
44
)}
44
45
45
46
clean ()
@@ -49,8 +50,62 @@ clean()
49
50
cleangit gcc-xtensa
50
51
cleangit newlib-xtensa
51
52
cleangit lx106-hal
53
+ cleangit mkspiffs
54
+ cleangit esptool
52
55
}
53
56
57
+ distclean ()
58
+ {
59
+ clean
60
+ rm -rf * .json * .tar.gz * .zip xtensa-lx106-elf.*
61
+ }
62
+
63
+ # Put an artifact in a target dir describing what was built
64
+ markrevinfo ()
65
+ {(
66
+ git rev-parse HEAD
67
+ git remote -v
68
+ uname -a
69
+ git diff
70
+ )}
71
+
72
+
73
+ maketool ()
74
+ {
75
+ if [ ! -r arena/jobdone-${tool} ]; then
76
+ echo " -------- ${tool} "
77
+ ( rm -rf arena/${tool} ;
78
+ cp -a dl/${tool} arena/${tool} ;
79
+ pushd arena/${tool} ;
80
+ TARGET_OS=${MKSPIFFSTGT} CC=${HOST} -gcc CXX=${HOST} -g++ STRIP=${HOST} -strip \
81
+ make clean ${tool}${EXE} BUILD_CONFIG_NAME=" -arduino-esp8266" ${extra_opts} ;
82
+ markrevinfo >& build-rev-info
83
+ popd ;
84
+ mkdir -p ${install} /${tool} ;
85
+ cp -a arena/${tool} /${tool}${EXE} arena/${tool} /build-rev-info ${install} /${tool} /.;
86
+ pushd arena/${tool} && name=${tool} -$( git rev-parse --short HEAD) && popd ;
87
+ pushd ${install} ;
88
+ tarball=${HOST} -$name .${tarext} ;
89
+ ${tarcmd} ${taropts} ../${tarball} ${tool} ;
90
+ popd ;
91
+ makejson;
92
+ touch arena/jobdone-${tool} ;
93
+ ) >& $log .${tool} .log
94
+ fi
95
+ }
96
+
97
+ makejson ()
98
+ {
99
+ tarballsize=$( stat -c%s ${tarball} )
100
+ tarballsha256=$( sha256sum ${tarball} | cut -f1 -d" " )
101
+ ( echo ' {' &&
102
+ echo ' "host": "' $AHOST ' ",' &&
103
+ echo ' "url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/' ${rel} -${subrel} ' /' ${tarball} ' ",' &&
104
+ echo ' "archiveFileName": "' ${tarball} ' ",' &&
105
+ echo ' "checksum": "SHA-256:' ${tarballsha256} ' ",' &&
106
+ echo ' "size": "' ${tarballsize} ' "' &&
107
+ echo ' }' ) > ${tarball} .json
108
+ }
54
109
55
110
install ()
56
111
{
@@ -80,27 +135,9 @@ install()
80
135
git=$( git rev-parse --short HEAD)
81
136
ver=${rel} -${git} -${subrel}
82
137
pkgfile=${arduino} /package/package_esp8266com_index.template.json
83
- (cat << EOF
84
- import glob
85
- import json
86
- import os
87
- with open("$pkgfile ") as f:
88
- data = json.load(f)
89
- for i in range(0, len(data["packages"][0]["platforms"][0]["toolsDependencies"])):
90
- if data["packages"][0]["platforms"][0]["toolsDependencies"][i]["name"] == "xtensa-lx106-elf-gcc":
91
- data["packages"][0]["platforms"][0]["toolsDependencies"][i]["version"] = "$ver "
92
- for i in range(0, len(data["packages"][0]["tools"])):
93
- if data["packages"][0]["tools"][i]["name"] == "xtensa-lx106-elf-gcc":
94
- data["packages"][0]["tools"][i]["version"] = "$ver "
95
- data["packages"][0]["tools"][i]["systems"] = []
96
- for j in glob.glob("*xtensa-lx106-elf*"+"$git "+"*json"):
97
- with open(j) as s:
98
- part = json.load(s)
99
- data["packages"][0]["tools"][i]["systems"].append(part)
100
- print json.dumps(data, indent=3, separators=(',',': '))
101
- EOF
102
- ) | python > $pkgfile .new
103
- mv -f ${pkgfile} .new ${pkgfile}
138
+ ./patch_json.py --pkgfile " ${pkgfile} " --tool xtensa-lx106-elf-gcc --ver " ${ver} " --glob ' *xtensa-lx106-elf*.json'
139
+ ./patch_json.py --pkgfile " ${pkgfile} " --tool esptool --ver " ${ver} " --glob ' *esptool*json'
140
+ ./patch_json.py --pkgfile " ${pkgfile} " --tool mkspiffs --ver " ${ver} " --glob ' *mkspiffs*json'
104
141
echo " Install done"
105
142
}
106
143
@@ -141,6 +178,17 @@ configurenewlibinstall+=${configurenewlibcom}
141
178
configurenewlib=" --prefix=${install} "
142
179
configurenewlib+=${configurenewlibcom}
143
180
181
+
182
+ if [ " ${EXE} " == " " ]; then
183
+ tarext=" tar.gz"
184
+ tarcmd=" tar"
185
+ taropts=" zcf"
186
+ else
187
+ tarext=" zip"
188
+ tarcmd=" zip"
189
+ taropts=" -rq"
190
+ fi
191
+
144
192
if $lto ; then
145
193
export CFLAGS_FOR_TARGET=' -mlongcalls -flto -Wl,-flto -Os -g'
146
194
export CXXFLAGS_FOR_TARGET=' -mlongcalls -flto -Wl,-flto -Os -g'
@@ -157,16 +205,14 @@ export LD_LIBRARY_PATH="${installnative}/lib"
157
205
158
206
case " $1 " in
159
207
clean) clean; exit 0;;
208
+ distclean) distclean; exit 0;;
160
209
build) : ;;
161
210
install) install; exit 0;;
162
- * ) echo " need 'clean', 'build', or 'install'" ; exit 1;;
211
+ * ) echo " need 'clean', 'distclean', ' build', or 'install'" ; exit 1;;
163
212
esac
164
213
165
-
166
- echo " Building GCC-$gcc "
167
- echo " For architecture: $host "
168
-
169
-
214
+ echo " -----------------------------------------------------------------------------"
215
+ echo " Building GCC-${gcc} for architecture ${host} and release ${rel} -${subrel} "
170
216
171
217
echo " -------- Checking for required tools"
172
218
MISS=0
@@ -185,10 +231,13 @@ if [ ! -r arena/downloaded ]; then
185
231
test -d binutils-gdb-xtensa || git clone ${gitopt} https://github.com/earlephilhower/binutils-gdb-xtensa.git
186
232
test -d gcc-xtensa || git clone https://github.com/earlephilhower/gcc-xtensa.git
187
233
test -d newlib-xtensa || git clone ${gitopt} https://github.com/earlephilhower/newlib-xtensa.git
188
- test -d lx106-hal || git clone ${gitopt} https://github.com/earlephilhower/lx106-hal.git
234
+ test -d lx106-hal || git clone https://github.com/earlephilhower/lx106-hal.git
235
+ test -d mkspiffs || git clone https://github.com/earlephilhower/mkspiffs.git
236
+ test -d esptool || git clone https://github.com/earlephilhower/esptool-ck.git esptool
189
237
)
190
238
191
239
( cd dl/gcc-xtensa && git reset --hard && git checkout ${xtensa_branch} )
240
+ ( cd dl/mkspiffs && git submodule update )
192
241
193
242
# download and put tools directly in gcc directory
194
243
# let gcc's configure deal with them in place
@@ -226,15 +275,15 @@ if [ ! -r arena/patched ]; then
226
275
227
276
for p in patches/gcc-* .patch patches/gcc${gcc} /gcc-* .patch; do
228
277
test -r " $p " || continue
229
- (cd dl/gcc-xtensa; echo " ---- $p :" ; patch -p1 < ../../$p )
278
+ (cd dl/gcc-xtensa; echo " ---- $p :" ; patch -s - p1 < ../../$p )
230
279
done
231
280
for p in patches/bin-* .patch; do
232
281
test -r " $p " || continue
233
- (cd dl/binutils-gdb-xtensa; echo " ---- $p :" ; patch -p1 < ../../$p )
282
+ (cd dl/binutils-gdb-xtensa; echo " ---- $p :" ; patch -s - p1 < ../../$p )
234
283
done
235
284
for p in patches/lib-* .patch; do
236
285
test -r " $p " || continue
237
- (cd dl/newlib-xtensa; echo " ---- $p : " ; patch -p1 < ../../$p )
286
+ (cd dl/newlib-xtensa; echo " ---- $p : " ; patch -s - p1 < ../../$p )
238
287
done
239
288
240
289
# dirty-force HAL definition to binutils and gcc
259
308
touch arena/patched
260
309
fi
261
310
262
-
263
311
# configure build install binutils
264
312
if [ ! -r arena/binutils/jobdone ]; then
265
313
echo " -------- gdb+binutils"
@@ -292,7 +340,6 @@ if [ ! -r arena/gcc/jobdone-newlib ]; then
292
340
touch arena/gcc/jobdone-newlib
293
341
fi
294
342
295
-
296
343
if [ ! -r arena/gcc/jobdone-stage2 ]; then
297
344
echo " -------- gcc-stage2"
298
345
# stage 2 (build libstdc++)
324
371
echo " -------- Stripping binaries"
325
372
(${HOST} -strip ${install} /bin/* ${install} /libexec/gcc/xtensa-lx106-elf/* /c* ${install} /libexec/gcc/xtensa-lx106-elf/* /lto1 || true) >& $log .16.strip.log
326
373
327
- echo " -------- applying post"
374
+ echo " -------- Applying post"
328
375
for sh in post/${gcc} * .sh; do
329
376
[ -x " $sh " ] && $sh ${EXT}
330
377
done
331
378
332
- echo " -------- creating package tgz"
333
- if [ " $EXE " == " .exe" ]; then
334
- tarball=$HOST .xtensa-lx106-elf-$( git rev-parse --short HEAD) .zip
335
- (rm -rf pkg && mkdir pkg && cd pkg && cp -a ../xtensa-lx106-elf${EXT} xtensa-lx106-elf && zip -rq ../${tarball} xtensa-lx106-elf/)
336
- else
337
- tarball=$HOST .xtensa-lx106-elf-$( git rev-parse --short HEAD) .tar.gz
338
- (rm -rf pkg && mkdir pkg && cd pkg && cp -a ../xtensa-lx106-elf${EXT} xtensa-lx106-elf && tar zcf ../${tarball} xtensa-lx106-elf/)
339
- fi
340
- tarballsize=$( stat -c%s ${tarball} )
341
- tarballsha256=$( sha256sum ${tarball} | cut -f1 -d" " )
342
- ( echo ' {' &&
343
- echo ' "host": "' $AHOST ' ",' &&
344
- echo ' "url": "https://github.com/earlephilhower/esp-quick-toolchain/releases/download/' ${rel} -${subrel} ' /' ${tarball} ' ",' &&
345
- echo ' "archiveFileName": "' ${tarball} ' ",' &&
346
- echo ' "checksum": "SHA-256:' ${tarballsha256} ' ",' &&
347
- echo ' "size": "' ${tarballsize} ' "' &&
348
- echo ' }' ) > ${tarball} .json
349
- rm -rf pkg
379
+ echo " -------- Creating package tgz"
380
+ markrevinfo >& build-rev-info
381
+ tarball=$HOST .xtensa-lx106-elf-$( git rev-parse --short HEAD) .${tarext}
382
+ (rm -rf pkg && mkdir pkg && markrevinfo > pkg/build-rev-info && cd pkg && cp -a ../xtensa-lx106-elf${EXT} xtensa-lx106-elf && ${tarcmd} ${taropts} ../${tarball} xtensa-lx106-elf/)
383
+ makejson
384
+
385
+ tool=mkspiffs CPPFLAGS=" -DSPIFFS_USE_MAGIC_LENGTH=0 -DSPIFFS_ALIGNED_OBJECT_INDEX_TABLES=1" maketool
386
+
387
+ tool=esptool extra_opts=' ' maketool
350
388
351
389
echo " all done (${install} )"
352
390
rm -f ${unfinished}
0 commit comments