@@ -42,60 +42,96 @@ gcc=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
4242 $cppflags
4343 $cflags "
4444
45+ function build() {
46+ local f=$1
47+ $gcc -c -o " $f " .o " $f "
48+ }
49+
4550$gcc --verbose
4651
4752set -v -x
4853
4954cp $root /cores/esp8266/libc_replacements.cpp ./
5055
51- $gcc -c libc_replacements.cpp
56+ build libc_replacements.cpp
5257
5358cat << EOF > arduino.c
5459#include <Arduino.h>
5560EOF
5661
57- $gcc -c arduino.c
62+ build arduino.c
5863
5964cat << EOF > coredecls.c
6065#include <coredecls.h>
6166EOF
6267
63- $gcc -c coredecls.c
68+ build coredecls.c
6469
6570cat << EOF > features.c
6671#include <core_esp8266_features.h>
6772EOF
6873
69- $gcc -c features.c
74+ build features.c
7075
7176cat << EOF > sdk.c
7277#include <version.h>
7378EOF
7479
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
7695
7796cat << EOF > iostream.cpp
7897#include <iostream>
79- void foo( ) {
80- std::cout << "hello world";
98+ void test_iostream(bool val ) {
99+ std::cout << (val ? "hello" : " world") << '\n' ;
81100}
82101EOF
83102
84- $gcc -c iostream.cpp
103+ build iostream.cpp
85104
86105cat << EOF > regex.cpp
87106#include <string>
88107#include <regex>
89108
90- bool bar (std::string v) {
109+ bool test_regex (std::string v) {
91110 std::regex r("HELLO", std::regex_constants::ECMAScript | std::regex_constants::icase);
92111 if (std::regex_search(v, r))
93112 return true;
94113 return false;
95114}
96115EOF
97116
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
99135
100136cp " $root /tools/sdk/ld/eagle.flash.1m.ld" " local.eagle.flash.ld.h"
101137preprocess=$" $gcc \
@@ -116,11 +152,11 @@ $preprocess \
116152libs=$" -lhal -lphy -lpp -lnet80211 -llwip6-1460-feat -lwpa \
117153-lcrypto -lmain -lwps -lbearssl -lespnow -lsmartconfig \
118154-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 ' )
120156
121157link=$" $root /tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
122158 -nostdlib
123- -u app_entry
159+ -uapp_entry
124160 -mlongcalls
125161 -L$cache_dir
126162 -L$root /tools/sdk/lib/NONOSDK305
@@ -131,7 +167,6 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
131167 -Wl,--no-check-sections
132168 -Wl,-Map,xtensa.map
133169 -Wl,--gc-sections
134- -Wl,--defsym,app_entry=0xaaaaaaaa
135170 -Wl,--defsym,abort=0xfefefefe
136171 -Wl,--defsym,malloc=0xfefefefe
137172 -Wl,--defsym,free=0xfefefefe
@@ -146,6 +181,4 @@ link=$"$root/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
146181 -Wl,--defsym,_fstat_r=0xfefefefe
147182 -Wl,--start-group $objects $libs -Wl,--end-group"
148183
149- nm=$" $root /tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-nm -C"
150-
151184$link -o xtensa.elf
0 commit comments