Skip to content

Commit

Permalink
move examples -> tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
scaprile committed Feb 28, 2025
1 parent 024078a commit cce68f6
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 224 deletions.
91 changes: 3 additions & 88 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,97 +165,12 @@ jobs:
- uses: actions/checkout@v4
- run: make -C test riscv SSL=${{ matrix.ssl }}

examples:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ssl: [-DMG_TLS=MG_TLS_NONE, -DMG_TLS=MG_TLS_BUILTIN]
name: examples ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
- run: sudo apt -y install libpcap-dev
- run: make -C test examples CFLAGS_EXTRA="${{ matrix.ssl }}"
- run: make -C test clean_examples
examples_win:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: examples_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 examples_win CFLAGS_EXTRA="${{ matrix.ssl }}"
shell: cmd
- name: test they clean
run: make -C test clean_examples_win
shell: cmd
examples_mac:
runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
name: examples_mac ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
- 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_win CFLAGS_EXTRA="${{ matrix.ssl }}"
shell: cmd
- name: test they clean
run: make -C test clean_refprojs_win
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]
ssl: [-DMG_TLS=MG_TLS_NONE, -DMG_TLS=MG_TLS_BUILTIN]
name: tutorials ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
Expand All @@ -267,7 +182,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
ssl: [-DMG_TLS=MG_TLS_NONE, -DMG_TLS=MG_TLS_BUILTIN]
name: tutorials_win ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
Expand All @@ -286,7 +201,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ssl: ["", -DMG_TLS=MG_TLS_BUILTIN]
ssl: [-DMG_TLS=MG_TLS_NONE, -DMG_TLS=MG_TLS_BUILTIN]
name: tutorials_mac ${{ matrix.ssl }}
steps:
- uses: actions/checkout@v4
Expand Down
56 changes: 1 addition & 55 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,60 +91,6 @@ jobs:
- uses: actions/checkout@v4
- run: make -C test riscv

examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make -C test examples_essential
- run: make -C test clean_examples_essential
examples_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 examples_win
shell: cmd
- name: test they clean
run: make -C test clean_examples_win
shell: cmd
examples_mac:
runs-on: macos-latest
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
steps:
- uses: actions/checkout@v4
- 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_win
shell: cmd
- name: test they clean
run: make -C test clean_refprojs_win
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:
Expand Down Expand Up @@ -398,7 +344,7 @@ jobs:
with: { fetch-depth: 2 }
- name: baremetal
run: |
if ./test/match_changed_files.sh "^src|tutorials/http/device-dashboard|tutorials/stm32" ; then
if ./test/match_changed_files.sh "^src|tutorials/http/device-dashboard|tutorials/stm32/nucleo-f7.*-make-" ; then
echo GO=1 >> $GITHUB_ENV
sudo apt -y update && sudo apt -y install gcc-arm-none-eabi
fi
Expand Down
24 changes: 0 additions & 24 deletions examples/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions mongoose.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ struct mg_fs {
};

extern struct mg_fs mg_fs_posix; // POSIX open/close/read/write/seek
extern struct mg_fs mg_fs_packed; // Packed FS, see examples/device-dashboard
extern struct mg_fs mg_fs_packed; // see tutorials/core/embedded-filesystem
extern struct mg_fs mg_fs_fat; // FAT FS

// File descriptor
Expand Down Expand Up @@ -2832,7 +2832,7 @@ struct mg_tcpip_spi {
// timestamp in milliseconds since connection init time.
//
// Test (run in two separate terminals):
// make -C examples/http-server/ CFLAGS_EXTRA=-DMG_ENABLE_PROFILE=1
// make -C tutorials/http/http-server/ CFLAGS_EXTRA=-DMG_ENABLE_PROFILE=1
// curl localhost:8000
// Output:
// 1ea1f1e7 2 net.c:150:mg_close_conn 3 profile:
Expand Down
2 changes: 1 addition & 1 deletion src/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct mg_fs {
};

extern struct mg_fs mg_fs_posix; // POSIX open/close/read/write/seek
extern struct mg_fs mg_fs_packed; // Packed FS, see examples/device-dashboard
extern struct mg_fs mg_fs_packed; // see tutorials/core/embedded-filesystem
extern struct mg_fs mg_fs_fat; // FAT FS

// File descriptor
Expand Down
2 changes: 1 addition & 1 deletion src/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// timestamp in milliseconds since connection init time.
//
// Test (run in two separate terminals):
// make -C examples/http-server/ CFLAGS_EXTRA=-DMG_ENABLE_PROFILE=1
// make -C tutorials/http/http-server/ CFLAGS_EXTRA=-DMG_ENABLE_PROFILE=1
// curl localhost:8000
// Output:
// 1ea1f1e7 2 net.c:150:mg_close_conn 3 profile:
Expand Down
57 changes: 12 additions & 45 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@ VCFLAGS = /nologo /W3 /O2 /MD /I. $(DEFS) $(TFLAGS)
IPV6 ?= 1
ASAN ?= -fsanitize=address,undefined,alignment -fno-sanitize-recover=all -fno-omit-frame-pointer -fno-common
ASAN_OPTIONS ?= detect_leaks=1
EXAMPLES := $(dir $(wildcard ../examples/*/Makefile))
EXAMPLES_QUICK := $(filter-out ../examples/micropython/, $(EXAMPLES))
EXAMPLES_MAC := $(filter-out ../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/pcap-driver/, $(TUTORIALS))
TUTORIALS_MAC := $(filter-out ../tutorials/tcpip/pcap-driver/ ../tutorials/tcpip/tap-driver/, $(TUTORIALS))
TUTORIALS_QUICK := $(filter-out ../tutorials/micropython/ ../tutorials/tcpip/pcap-driver/, $(TUTORIALS))
TUTORIALS_MAC := $(filter-out ../tutorials/micropython/ ../tutorials/tcpip/pcap-driver/ ../tutorials/tcpip/tap-driver/, $(TUTORIALS))
TUTORIALS_WIN := $(dir $(wildcard ../tutorials/http/file-*/Makefile) $(wildcard ../tutorials/http/http-*/Makefile) $(wildcard ../tutorials/mqtt/*/Makefile) $(wildcard ../tutorials/websocket/*/Makefile) $(wildcard ../tutorials/webui/*/Makefile))
# This does not included ESP32, ESP8266, Microchip; all examples that are directly placed under an OS tutorial. Arduino might be caught due to links
TUTORIALS_EMBEDDED := $(filter-out $(wildcard ../tutorials/zephyr/*/), $(dir $(wildcard ../tutorials/*/*/Makefile)))
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
Expand All @@ -32,7 +29,7 @@ COMMON_CFLAGS ?= $(C_WARN) $(WARN) $(INCS) $(DEFS) -DMG_ENABLE_IPV6=$(IPV6) $(TF
CFLAGS ?= $(OPTS) $(ASAN) $(COMMON_CFLAGS)
VALGRIND_CFLAGS ?= $(OPTS) $(COMMON_CFLAGS)
VALGRIND_RUN ?= valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --show-leak-kinds=all --leak-resolution=high --track-origins=yes --error-exitcode=1 --exit-on-first-error=yes --fair-sched=yes
.PHONY: clean_examples examples mip_test test valgrind
.PHONY: clean_tutorials tutorials mip_test test valgrind

ifeq "$(findstring ++,$(CC))" ""
# $(CC) does not end with ++, i.e. we're using C. Apply C flags
Expand Down Expand Up @@ -84,7 +81,7 @@ endif
all:
$(MAKE) -C ../tutorials/http/http-server

tall: mg_prefix unamalgamated test mip_test arm examples vc98 vc17 vc22 mingw mingw++ fuzz
tall: mg_prefix unamalgamated test mip_test arm tutorials vc98 vc17 vc22 mingw mingw++ fuzz

mip_test: mip_test.c mongoose.c mongoose.h packed_fs.c Makefile
$(CC) mip_test.c packed_fs.c $(CFLAGS) $(LDFLAGS) -o $@
Expand Down Expand Up @@ -212,41 +209,11 @@ 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/tls_chacha20.h src/tls_rsa.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/flash.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_refprojs clean_tutorials clean_examples_embedded
clean: clean_tutorials clean_tutorials_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
#find tutorials -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:
Expand All @@ -268,8 +235,8 @@ 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:
for X in $(EXAMPLES_EMBEDDED); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done
tutorials_embedded:
@for X in $(TUTORIALS_EMBEDDED); do test -f $$X/Makefile || continue; $(MAKE) -C $$X build || exit 1; done
clean_tutorials_embedded:
for X in $(TUTORIALS_EMBEDDED); do test -f $$X/Makefile || continue; $(MAKE) -C $$X clean || exit 1; done

2 changes: 1 addition & 1 deletion test/cube/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROOT ?= $(realpath $(CURDIR)/../..)
PROJECTS ?= $(wildcard ../../examples/stm32/nucleo-*-cube-*)
PROJECTS ?= $(wildcard ../../tutorials/stm32/nucleo-*-cube-*)
TARGET ?= Debug
DOCKER = docker run --rm -v $(ROOT):$(ROOT) -v $(CURDIR):/root -w $(CURDIR)
IMAGE ?= scaprile/cubeozone
Expand Down
2 changes: 1 addition & 1 deletion test/esp-idf/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROOT ?= $(realpath $(CURDIR)/../..)
PROJECTS ?= $(wildcard ../../examples/esp32/*)
PROJECTS ?= ../../tutorials/http/device-dashboard/esp32/ ../../tutorials/micropython/esp32/ ../../tutorials/http/uart-bridge/esp32/
TARGET ?= Debug
DOCKER = docker run --rm -v $(ROOT):$(ROOT) -v $(CURDIR):/root -w $(CURDIR)
IMAGE ?= espressif/idf
Expand Down
2 changes: 1 addition & 1 deletion test/gcc+make/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECTS ?= $(wildcard ../../examples/*/*-make-*)
PROJECTS ?= $(wildcard ../../tutorials/*/*-make-*)

all: $(PROJECTS)
echo
Expand Down
2 changes: 1 addition & 1 deletion test/keil/Clean
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Do NOT use parenthesis on Windows project dir names
PROJECTS ?= $(wildcard ../../examples/stm32/nucleo-*-keil-*)
PROJECTS ?= $(wildcard ../../tutorials/stm32/nucleo-*-keil-*)

MAKEFILEPATH := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
BATPATH := $(subst /,\,$(MAKEFILEPATH))
Expand Down
2 changes: 1 addition & 1 deletion test/keil/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Do NOT use parenthesis on Windows project dir names
PROJECTS ?= $(wildcard ../../examples/stm32/nucleo-*-keil-*)
PROJECTS ?= $(wildcard ../../tutorials/stm32/nucleo-*-keil-*)
TARGET ?= "Target 1"

all: $(PROJECTS)
Expand Down
2 changes: 1 addition & 1 deletion test/pico-sdk/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECTS ?= $(wildcard ../../examples/pico-sdk/*-picosdk-*)
PROJECTS ?= $(wildcard ../../tutorials/pico-sdk/*-picosdk-*)
SDK_PATH ?= $(realpath $(PWD))/pico-sdk
SDK_VERSION ?= 2.1.0

Expand Down
2 changes: 1 addition & 1 deletion test/xpresso/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROOT ?= $(realpath $(CURDIR)/../..)
PROJECTS ?= $(wildcard ../../examples/nxp/*-xpresso-*)
PROJECTS ?= $(wildcard ../../tutorials/nxp/*-xpresso-*)
TARGET ?= Debug
DOCKER = docker run --rm -v $(ROOT):$(ROOT) -v $(CURDIR):/root -w $(CURDIR)
IMAGE ?= scaprile/xpresso
Expand Down
2 changes: 1 addition & 1 deletion test/zephyr/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ROOT ?= $(realpath $(CURDIR)/../..)
ZEPHYR_DIR ?= $(ROOT)/examples/zephyr/zephyrproject
ZEPHYR_DIR ?= $(ROOT)/tutorials/zephyr/zephyrproject
DOCKER ?= docker run --rm -v $(ROOT):$(ROOT) -w $(CURDIR)/wizard
IMAGE ?= zephyrprojectrtos/ci
REVNO ?= --mr v3.7-branch
Expand Down
Loading

0 comments on commit cce68f6

Please sign in to comment.