diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7f19412f..a0060c1e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -186,6 +186,91 @@ jobs: - run: make -C test examples_mac CFLAGS_EXTRA="${{ matrix.ssl }}" - run: make -C test clean_examples_mac + refprojs: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ssl: ["", -DMG_TLS=MG_TLS_BUILTIN] + name: reference-projects ${{ matrix.ssl }} + steps: + - uses: actions/checkout@v4 + - run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}" + - run: make -C test clean_refprojs + refprojs_win: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + ssl: ["", -DMG_TLS=MG_TLS_BUILTIN] + name: reference-projects_win ${{ matrix.ssl }} + steps: + - uses: actions/checkout@v4 +# - uses: egor-tensin/setup-mingw@v2 +# with: +# platform: x64 + - name: test they build + run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}" + shell: cmd + - name: test they clean + run: make -C test clean_refprojs + shell: cmd + refprojs_mac: + runs-on: macos-latest + env: { HOMEBREW_NO_AUTO_UPDATE: 1 } + strategy: + fail-fast: false + matrix: + ssl: ["", -DMG_TLS=MG_TLS_BUILTIN] + name: reference-projects_mac ${{ matrix.ssl }} + steps: + - uses: actions/checkout@v4 + - run: make -C test refprojs CFLAGS_EXTRA="${{ matrix.ssl }}" + - run: make -C test clean_refprojs + + tutorials: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ssl: ["", -DMG_TLS=MG_TLS_BUILTIN] + name: tutorials ${{ matrix.ssl }} + steps: + - uses: actions/checkout@v4 + - run: sudo apt -y install libmbedtls-dev libpcap-dev + - run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}" + - run: make -C test clean_tutorials + tutorials_win: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + ssl: ["", -DMG_TLS=MG_TLS_BUILTIN] + name: tutorials_win ${{ matrix.ssl }} + steps: + - uses: actions/checkout@v4 +# - uses: egor-tensin/setup-mingw@v2 +# with: +# platform: x64 + - name: test they build + run: make -C test tutorials_win CFLAGS_EXTRA="${{ matrix.ssl }}" + shell: cmd + - name: test they clean + run: make -C test clean_tutorials_win + shell: cmd + tutorials_mac: + runs-on: macos-latest + env: { HOMEBREW_NO_AUTO_UPDATE: 1 } + strategy: + fail-fast: false + matrix: + ssl: ["", -DMG_TLS=MG_TLS_BUILTIN] + name: tutorials_mac ${{ matrix.ssl }} + steps: + - uses: actions/checkout@v4 + - run: make -C test tutorials_mac CFLAGS_EXTRA="${{ matrix.ssl }}" + - run: make -C test clean_tutorials_mac + arduino: runs-on: ubuntu-latest diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 9938752f..18bca05b 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -118,6 +118,60 @@ jobs: - run: make -C test examples_mac - run: make -C test clean_examples_mac + refprojs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: make -C test refprojs + - run: make -C test clean_refprojs + refprojs_win: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 +# - uses: egor-tensin/setup-mingw@v2 +# with: +# platform: x64 + - name: test they build + run: make -C test refprojs + shell: cmd + - name: test they clean + run: make -C test clean_refprojs + shell: cmd + refprojs_mac: + runs-on: macos-latest + env: { HOMEBREW_NO_AUTO_UPDATE: 1 } + steps: + - uses: actions/checkout@v4 + - run: make -C test refprojs + - run: make -C test clean_refprojs + + tutorials: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: make -C test tutorials_essential + - run: make -C test clean_tutorials_essential + tutorials_win: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 +# - uses: egor-tensin/setup-mingw@v2 +# with: +# platform: x64 + - name: test they build + run: make -C test tutorials_win + shell: cmd + - name: test they clean + run: make -C test clean_tutorials_win + shell: cmd + tutorials_mac: + runs-on: macos-latest + env: { HOMEBREW_NO_AUTO_UPDATE: 1 } + steps: + - uses: actions/checkout@v4 + - run: make -C test tutorials_mac + - run: make -C test clean_tutorials_mac + generic_examples: runs-on: ubuntu-latest diff --git a/examples/multi-threaded-12m/README.md b/examples/multi-threaded-12m/README.md deleted file mode 100644 index 363528f4..00000000 --- a/examples/multi-threaded-12m/README.md +++ /dev/null @@ -1 +0,0 @@ -See detailed tutorial at https://mongoose.ws/tutorials/multi-threaded/ diff --git a/examples/multi-threaded-12m/mongoose.c b/examples/multi-threaded-12m/mongoose.c deleted file mode 120000 index 8ef6e62d..00000000 --- a/examples/multi-threaded-12m/mongoose.c +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.c \ No newline at end of file diff --git a/examples/multi-threaded-12m/mongoose.h b/examples/multi-threaded-12m/mongoose.h deleted file mode 120000 index 488ef358..00000000 --- a/examples/multi-threaded-12m/mongoose.h +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.h \ No newline at end of file diff --git a/examples/multi-threaded/README.md b/examples/multi-threaded/README.md deleted file mode 100644 index 363528f4..00000000 --- a/examples/multi-threaded/README.md +++ /dev/null @@ -1 +0,0 @@ -See detailed tutorial at https://mongoose.ws/tutorials/multi-threaded/ diff --git a/examples/multi-threaded/mongoose.c b/examples/multi-threaded/mongoose.c deleted file mode 120000 index 8ef6e62d..00000000 --- a/examples/multi-threaded/mongoose.c +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.c \ No newline at end of file diff --git a/examples/multi-threaded/mongoose.h b/examples/multi-threaded/mongoose.h deleted file mode 120000 index 488ef358..00000000 --- a/examples/multi-threaded/mongoose.h +++ /dev/null @@ -1 +0,0 @@ -../../mongoose.h \ No newline at end of file diff --git a/reference-projects/README.md b/reference-projects/README.md new file mode 100644 index 00000000..36988fec --- /dev/null +++ b/reference-projects/README.md @@ -0,0 +1 @@ +See detailed tutorials at https://mongoose.ws/documentation/#reference-projects \ No newline at end of file diff --git a/reference-projects/windows-macos-linux/web-ui-dashboard/README.md b/reference-projects/windows-macos-linux/web-ui-dashboard/README.md new file mode 100644 index 00000000..48010857 --- /dev/null +++ b/reference-projects/windows-macos-linux/web-ui-dashboard/README.md @@ -0,0 +1,13 @@ +# A complete device dashboard + +This example is a demonstration of how Mongoose Library could be integrated +into an embedded device and provide a complete device dashboard with the +following features: + +- Authentication: login-protected dashboard +- Multiple logins (with possibly different permissions) +- The Web UI can be fully embedded into the firmware binary, then not + needing a filesystem to serve it; so being resilient to FS problems +- All changes are propagated to all connected clients + +See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/ diff --git a/test/Makefile b/test/Makefile index 4853012a..66bcdbc7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -18,6 +18,11 @@ EXAMPLES_QUICK := $(filter-out ../examples/mip-pcap/ ../examples/micropython/, $ EXAMPLES_MAC := $(filter-out ../examples/mip-pcap/ ../examples/mip-tap/ ../examples/micropython/, $(EXAMPLES)) EXAMPLES_WIN := $(dir $(wildcard ../examples/device-dashboard/Makefile) $(wildcard ../examples/file-*/Makefile) $(wildcard ../examples/http-*/Makefile) $(wildcard ../examples/mqtt-*/Makefile) $(wildcard ../examples/websocket-*/Makefile) $(wildcard ../examples/webui-*/Makefile)) EXAMPLES_EMBEDDED := $(filter-out $(wildcard ../examples/zephyr/*/), $(dir $(wildcard ../examples/*/*/Makefile))) +REFPROJS := $(dir $(wildcard ../reference-projects/windows-macos-linux/*/Makefile)) +TUTORIALS := $(dir $(wildcard ../tutorials/*/*/Makefile)) +TUTORIALS_QUICK := $(filter-out ../tutorials/tcpip_stack/pcap/ , $(TUTORIALS)) +TUTORIALS_MAC := TUTORIALS +TUTORIALS_WIN := $(dir $(wildcard ../tutorials/http/file-*/Makefile) $(wildcard ../tutorials/http/http-*/Makefile) $(wildcard ../tutorials/mqtt/mqtt-*/Makefile) $(wildcard ../tutorials/websocket/websocket-*/Makefile) $(wildcard ../tutorials/webui/webui-*/Makefile)) PREFIX ?= /usr/local LIBDIR ?= $(PREFIX)/lib INCLUDEDIR ?= $(PREFIX)/include @@ -65,26 +70,6 @@ mip_tap_test: mip_tap_test.c mongoose.c mongoose.h Makefile $(CC) mip_tap_test.c $(INCS) $(WARN) $(OPTS) $(C_WARN) $(ASAN) -o $@ ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./$@ -examples: - @for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done -clean_examples: - for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done - -examples_essential: - @for X in $(EXAMPLES_QUICK); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done -clean_examples_essential: - for X in $(EXAMPLES_QUICK); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done - -examples_mac: - for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done -clean_examples_mac: - for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done - -examples_win: - $(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) example &) -clean_examples_win: - $(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) clean &) - packed_fs.c: Makefile data/ssi.h fuzz.c data/a.txt data/ca.pem certs/ca.crt certs/server.crt certs/server.key $(CC) $(CFLAGS) pack.c -o pack $(RUN) ./pack Makefile data/ssi.h fuzz.c data/a.txt data/range.txt data/ca.pem certs/ca.crt certs/server.crt certs/server.key certs/client.key certs/client.crt > $@ @@ -197,10 +182,62 @@ mongoose.h: $(HDRS) Makefile cd .. && (cat src/license.h; echo; echo '#ifndef MONGOOSE_H'; echo '#define MONGOOSE_H'; echo; cat src/version.h ; echo; echo '#ifdef __cplusplus'; echo 'extern "C" {'; echo '#endif'; cat src/arch.h src/arch_*.h src/net_ft.h src/net_lwip.h src/net_rl.h src/config.h src/str.h src/queue.h src/fmt.h src/printf.h src/log.h src/timer.h src/fs.h src/util.h src/url.h src/iobuf.h src/base64.h src/md5.h src/sha1.h src/sha256.h src/tls_x25519.h src/tls_aes128.h src/tls_uecc.h src/event.h src/net.h src/http.h src/ssi.h src/tls.h src/tls_mbed.h src/tls_openssl.h src/ws.h src/sntp.h src/mqtt.h src/dns.h src/json.h src/rpc.h src/ota.h src/device.h src/net_builtin.h src/profile.h src/drivers/*.h | sed -e '/keep/! s,#include ".*,,' -e 's,^#pragma once,,'; echo; echo '#ifdef __cplusplus'; echo '}'; echo '#endif'; echo '#endif // MONGOOSE_H')> $@ -clean: clean_examples clean_examples_embedded +clean: clean_examples clean_refprojs clean_tutorials clean_examples_embedded rm -rf $(PROG) *.exe *.o *.dSYM *_test* ut fuzzer *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb slow-unit* _CL_* infer-out data.txt crash-* packed_fs.c pack #find examples -maxdepth 3 -name zephyr -prune -o -name Makefile -print | xargs dirname | xargs -n1 make clean -C + +examples: + @for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_examples: + for X in $(EXAMPLES); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +examples_essential: + @for X in $(EXAMPLES_QUICK); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_examples_essential: + for X in $(EXAMPLES_QUICK); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +examples_mac: + for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_examples_mac: + for X in $(EXAMPLES_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +examples_win: + $(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) example &) +clean_examples_win: + $(foreach X, $(EXAMPLES_WIN), $(MAKE) -C $(X) clean &) + +refprojs: + @for X in $(REFPROJS); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_refprojs: + for X in $(REFPROJS); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +refprojs_win: + $(foreach X, $(REFPROJS), $(MAKE) -C $(X) example.exe &) +clean_refprojs_win: + $(foreach X, $(REFPROJS), $(MAKE) -C $(X) clean &) + +tutorials: + @for X in $(TUTORIALS); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_tutorials: + for X in $(TUTORIALS); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +tutorials_essential: + @for X in $(TUTORIALS_QUICK); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_tutorials_essential: + for X in $(TUTORIALS_QUICK); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +tutorials_mac: + @for X in $(TUTORIALS_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X example || exit 1; done +clean_tutorials_mac: + for X in $(TUTORIALS_MAC); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done + +tutorials_win: + $(foreach X, $(TUTORIALS_WIN), $(MAKE) -C $(X) example &) +clean_tutorials_win: + $(foreach X, $(TUTORIALS_WIN), $(MAKE) -C $(X) clean &) + + examples_embedded: @for X in $(EXAMPLES_EMBEDDED); do test -f $$X/Makefile || continue; $(MAKE) -C $$X build || exit 1; done clean_examples_embedded: diff --git a/examples/multi-threaded-12m/Makefile b/tutorials/core/multi-threaded-12m/Makefile similarity index 100% rename from examples/multi-threaded-12m/Makefile rename to tutorials/core/multi-threaded-12m/Makefile diff --git a/tutorials/core/multi-threaded-12m/README.md b/tutorials/core/multi-threaded-12m/README.md new file mode 100644 index 00000000..4cf13e99 --- /dev/null +++ b/tutorials/core/multi-threaded-12m/README.md @@ -0,0 +1 @@ +See detailed tutorial at https://mongoose.ws/tutorials/core/multi-threaded/ diff --git a/examples/multi-threaded-12m/main.c b/tutorials/core/multi-threaded-12m/main.c similarity index 100% rename from examples/multi-threaded-12m/main.c rename to tutorials/core/multi-threaded-12m/main.c diff --git a/tutorials/core/multi-threaded-12m/mongoose.c b/tutorials/core/multi-threaded-12m/mongoose.c new file mode 120000 index 00000000..5e522bbc --- /dev/null +++ b/tutorials/core/multi-threaded-12m/mongoose.c @@ -0,0 +1 @@ +../../../mongoose.c \ No newline at end of file diff --git a/tutorials/core/multi-threaded-12m/mongoose.h b/tutorials/core/multi-threaded-12m/mongoose.h new file mode 120000 index 00000000..ee4ac823 --- /dev/null +++ b/tutorials/core/multi-threaded-12m/mongoose.h @@ -0,0 +1 @@ +../../../mongoose.h \ No newline at end of file diff --git a/examples/multi-threaded/Makefile b/tutorials/core/multi-threaded/Makefile similarity index 100% rename from examples/multi-threaded/Makefile rename to tutorials/core/multi-threaded/Makefile diff --git a/tutorials/core/multi-threaded/README.md b/tutorials/core/multi-threaded/README.md new file mode 100644 index 00000000..4cf13e99 --- /dev/null +++ b/tutorials/core/multi-threaded/README.md @@ -0,0 +1 @@ +See detailed tutorial at https://mongoose.ws/tutorials/core/multi-threaded/ diff --git a/examples/multi-threaded/main.c b/tutorials/core/multi-threaded/main.c similarity index 100% rename from examples/multi-threaded/main.c rename to tutorials/core/multi-threaded/main.c diff --git a/tutorials/core/multi-threaded/mongoose.c b/tutorials/core/multi-threaded/mongoose.c new file mode 120000 index 00000000..5e522bbc --- /dev/null +++ b/tutorials/core/multi-threaded/mongoose.c @@ -0,0 +1 @@ +../../../mongoose.c \ No newline at end of file diff --git a/tutorials/core/multi-threaded/mongoose.h b/tutorials/core/multi-threaded/mongoose.h new file mode 120000 index 00000000..ee4ac823 --- /dev/null +++ b/tutorials/core/multi-threaded/mongoose.h @@ -0,0 +1 @@ +../../../mongoose.h \ No newline at end of file