@@ -42,60 +42,96 @@ gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
42
42
$cppflags
43
43
$cflags "
44
44
45
+ function build() {
46
+ local f=$1
47
+ $gcc -c -o " $f " .o " $f "
48
+ }
49
+
45
50
$gcc --verbose
46
51
47
52
set -v -x
48
53
49
54
cp $root /cores/esp8266/libc_replacements.cpp ./
50
55
51
- $gcc -c libc_replacements.cpp
56
+ build libc_replacements.cpp
52
57
53
58
cat << EOF > arduino.c
54
59
#include <Arduino.h>
55
60
EOF
56
61
57
- $gcc -c arduino.c
62
+ build arduino.c
58
63
59
64
cat << EOF > coredecls.c
60
65
#include <coredecls.h>
61
66
EOF
62
67
63
- $gcc -c coredecls.c
68
+ build coredecls.c
64
69
65
70
cat << EOF > features.c
66
71
#include <core_esp8266_features.h>
67
72
EOF
68
73
69
- $gcc -c features.c
74
+ build features.c
70
75
71
76
cat << EOF > sdk.c
72
77
#include <version.h>
73
78
EOF
74
79
75
- $gcc -c sdk.c
80
+ build sdk.c
81
+
82
+ cat << EOF > cmath.cpp
83
+ #include <cmath>
84
+
85
+ bool test_remainder(float x) {
86
+ return fabs(std::remainder((float)15.123456, x) - (float)0.123456) < 1e-5;
87
+ }
88
+
89
+ bool test_remainder(double x) {
90
+ return std::fabs(std::remainder((double)10.123456, x) - (double)0.123456) < 1e-5;
91
+ }
92
+ EOF
93
+
94
+ build cmath.cpp
76
95
77
96
cat << EOF > iostream.cpp
78
97
#include <iostream>
79
- void foo( ) {
80
- std::cout << "hello world";
98
+ void test_iostream(bool val ) {
99
+ std::cout << (val ? "hello" : " world") << '\n' ;
81
100
}
82
101
EOF
83
102
84
- $gcc -c iostream.cpp
103
+ build iostream.cpp
85
104
86
105
cat << EOF > regex.cpp
87
106
#include <string>
88
107
#include <regex>
89
108
90
- bool bar (std::string v) {
109
+ bool test_regex (std::string v) {
91
110
std::regex r("HELLO", std::regex_constants::ECMAScript | std::regex_constants::icase);
92
111
if (std::regex_search(v, r))
93
112
return true;
94
113
return false;
95
114
}
96
115
EOF
97
116
98
- $gcc -c regex.cpp
117
+ build regex.cpp
118
+
119
+ cat << EOF > app_entry.cpp
120
+ #include <string>
121
+
122
+ bool test_remainder(float);
123
+ bool test_remainder(double);
124
+ bool test_regex(std::string);
125
+ void test_iostream(bool);
126
+
127
+ extern "C" void app_entry() {
128
+ test_iostream(test_remainder(1.23f));
129
+ test_iostream(test_remainder(4.56));
130
+ test_iostream(test_regex("hello world"));
131
+ }
132
+ EOF
133
+
134
+ build app_entry.cpp
99
135
100
136
cp " $root /tools/sdk/ld/eagle.flash.1m.ld" " local.eagle.flash.ld.h"
101
137
preprocess=$" $gcc \
@@ -116,11 +152,11 @@ $preprocess \
116
152
libs=$" -lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \
117
153
-lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \
118
154
-lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc"
119
- objects=" libc_replacements.o arduino.o coredecls.o features.o sdk.o iostream.o "
155
+ objects=$( find . -name ' *.o ' -printf ' %f ' )
120
156
121
157
link=$" $root /tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
122
158
-nostdlib
123
- -u app_entry
159
+ -uapp_entry
124
160
-mlongcalls
125
161
-L$cache_dir
126
162
-L$root /tools/sdk/lib/NONOSDK305
@@ -131,7 +167,6 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
131
167
-Wl,--no-check-sections
132
168
-Wl,-Map,xtensa.map
133
169
-Wl,--gc-sections
134
- -Wl,--defsym,app_entry=0xaaaaaaaa
135
170
-Wl,--defsym,abort=0xfefefefe
136
171
-Wl,--defsym,malloc=0xfefefefe
137
172
-Wl,--defsym,free=0xfefefefe
@@ -146,6 +181,4 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
146
181
-Wl,--defsym,_fstat_r=0xfefefefe
147
182
-Wl,--start-group $objects $libs -Wl,--end-group"
148
183
149
- nm=$" $root /tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-nm -C"
150
-
151
184
$link -o xtensa.elf
0 commit comments