mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-06 13:37:34 +08:00
Merge pull request #2074 from cesanta/standex
Standardize examples and make them Windows friendly
This commit is contained in:
commit
87fe912d8d
@ -21,12 +21,14 @@ endif
|
|||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
$(RUN) ./$(PROG) $(ARGS)
|
$(RUN) ./$(PROG) $(ARGS)
|
||||||
|
|
||||||
|
ifneq ($(OS),Windows_NT)
|
||||||
# Before embedding files, gzip them to save space
|
# Before embedding files, gzip them to save space
|
||||||
packed_fs.c: $(shell find web_root -type f) Makefile
|
packed_fs.c: $(shell find web_root -type f) Makefile
|
||||||
rm -rf tmp/web_root && mkdir tmp && cp -r web_root tmp/
|
rm -rf tmp/web_root && mkdir tmp && cp -r web_root tmp/
|
||||||
find tmp -type f | xargs -n1 gzip
|
find tmp -type f | xargs -n1 gzip
|
||||||
$(CC) ../../test/pack.c -o pack
|
$(CC) ../../test/pack.c -o pack
|
||||||
cd tmp && ../pack `find web_root -type f` > ../$@
|
cd tmp && ../pack `find web_root -type f` > ../$@
|
||||||
|
endif
|
||||||
|
|
||||||
$(PROG): $(SOURCES)
|
$(PROG): $(SOURCES)
|
||||||
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
|
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
|
||||||
|
@ -9,19 +9,21 @@ following features:
|
|||||||
- Web UI is fully embedded into the server/firmware binary, and does not
|
- Web UI is fully embedded into the server/firmware binary, and does not
|
||||||
need a filesystem to serve it. UI is resilient to FS problems
|
need a filesystem to serve it. UI is resilient to FS problems
|
||||||
- Administrators can change server settings
|
- Administrators can change server settings
|
||||||
- All changes are propagates to all connected clients
|
- All changes are propagated to all connected clients
|
||||||
- A device is connected to the external MQTT server
|
- The device is connected to the external MQTT server
|
||||||
- Logged in clients can send/receive messages to a device which get
|
- Logged in clients can send/receive messages via MQTT
|
||||||
forwarded to MQTT
|
|
||||||
|
|
||||||
# Screenshots
|
## Screenshots
|
||||||
|
|
||||||
This is a login screen that prompts for user/password
|
This is a login screen that prompts for user/password
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
# Main dashboard
|
## Main dashboard
|
||||||
|
|
||||||
A main dashboard page shows and interactive MQTT console
|
The main dashboard page shows the interactive MQTT console
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
See a detailed tutorial at https://mongoose.ws/tutorials/device-dashboard/
|
||||||
|
@ -13,23 +13,25 @@ ifeq ($(OS),Windows_NT)
|
|||||||
CFLAGS += -lws2_32 # Link against Winsock library
|
CFLAGS += -lws2_32 # Link against Winsock library
|
||||||
DELETE = cmd /C del /Q /F /S # Command prompt command to delete files
|
DELETE = cmd /C del /Q /F /S # Command prompt command to delete files
|
||||||
OUT ?= -o $(PROG) # Build output
|
OUT ?= -o $(PROG) # Build output
|
||||||
|
PACK = pack.exe
|
||||||
else
|
else
|
||||||
# Mac, Linux
|
# Mac, Linux
|
||||||
PROG ?= example
|
PROG ?= example
|
||||||
DELETE = rm -rf
|
DELETE = rm -rf
|
||||||
OUT ?= -o $(PROG)
|
OUT ?= -o $(PROG)
|
||||||
|
PACK = ./pack
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
$(RUN) ./$(PROG) $(ARGS)
|
$(RUN) ./$(PROG) $(ARGS)
|
||||||
|
|
||||||
$(PROG): $(SOURCES) $(FILES_TO_EMBED)
|
$(PROG): $(SOURCES) $(FILES_TO_EMBED)
|
||||||
$(CC) ../../test/pack.c -o pack
|
$(CC) ../../test/pack.c -o $(PACK)
|
||||||
./pack $(FILES_TO_EMBED) > packed_fs.c
|
$(PACK) $(FILES_TO_EMBED) > packed_fs.c
|
||||||
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
|
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(DELETE) $(PROG) *.dSYM pack
|
$(DELETE) $(PROG) *.dSYM $(PACK)
|
||||||
|
|
||||||
.PHONY: compress expand gzipped plain all
|
.PHONY: compress expand gzipped plain all
|
||||||
|
|
||||||
|
@ -1,41 +1,38 @@
|
|||||||
PROG ?= example
|
SOURCES = main.c mongoose.c # Source code files
|
||||||
ROOT ?= $(realpath $(CURDIR)/../..)
|
CFLAGS = -W -Wall -Wextra -g -I. # Build options
|
||||||
CFLAGS ?= -DMG_ENABLE_LINES $(EXTRA_CFLAGS)
|
|
||||||
LIN = docker run -it --rm -v $(ROOT):$(ROOT) -w $(CURDIR) mdashnet/cc2
|
|
||||||
SSL = ?
|
|
||||||
|
|
||||||
|
# Mongoose build options. See https://mongoose.ws/documentation/#build-options
|
||||||
|
CFLAGS_MONGOOSE += -DMG_ENABLE_LINES=1
|
||||||
|
|
||||||
|
SSL = ?
|
||||||
ifeq "$(SSL)" "MBEDTLS"
|
ifeq "$(SSL)" "MBEDTLS"
|
||||||
CFLAGS += -DMG_ENABLE_MBEDTLS=1 -lmbedtls -lmbedcrypto -lmbedx509
|
CFLAGS += -lmbedtls -lmbedcrypto -lmbedx509
|
||||||
|
CFLAGS_MONGOOSE += -DMG_ENABLE_MBEDTLS=1
|
||||||
|
endif
|
||||||
|
ifeq "$(SSL)" "OPENSSL"
|
||||||
|
CFLAGS += -lssl -lcrypto
|
||||||
|
CFLAGS_MONGOOSE += -DMG_ENABLE_OPENSSL=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq "$(SSL)" "OPENSSL"
|
ifeq ($(OS),Windows_NT)
|
||||||
CFLAGS += -DMG_ENABLE_OPENSSL=1 -lssl -lcrypto
|
# Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe
|
||||||
|
PROG ?= example.exe # Use .exe suffix for the binary
|
||||||
|
CC = gcc # Use MinGW gcc compiler
|
||||||
|
CFLAGS += -lws2_32 # Link against Winsock library
|
||||||
|
DELETE = cmd /C del /Q /F /S # Command prompt command to delete files
|
||||||
|
OUT ?= -o $(PROG) # Build output
|
||||||
|
else
|
||||||
|
# Mac, Linux
|
||||||
|
PROG ?= example
|
||||||
|
DELETE = rm -rf
|
||||||
|
OUT ?= -o $(PROG)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
$(RUN) ./$(PROG) $(ARGS)
|
$(RUN) ./$(PROG) $(ARGS)
|
||||||
|
|
||||||
$(PROG): main.c
|
$(PROG): $(SOURCES)
|
||||||
$(CC) ../../mongoose.c -I../.. -W -Wall $(CFLAGS) -o $(PROG) main.c
|
$(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
|
||||||
|
|
||||||
linux: all
|
|
||||||
linux: CFLAGS += -O2 -g -fsanitize=address,undefined,shift,null,return,bounds,alignment,object-size,bool,enum -static-libasan
|
|
||||||
linux: CC = $(LIN) cc
|
|
||||||
linux: RUN = $(LIN)
|
|
||||||
|
|
||||||
|
|
||||||
ROOT ?= $(realpath $(CURDIR)/../..)
|
|
||||||
DOCKER = docker run -it --rm -e Tmp=. -e WINEDEBUG=-all -v $(ROOT):$(ROOT) -w $(CURDIR)
|
|
||||||
WDEFS = -DMG_ENABLE_MBEDTLS -DMG_ENABLE_LINES -Imbedtls/include -Imbedtls/library $(EXTRA)
|
|
||||||
WFLAGS = /nologo -O2 -I. -I../.. ws2_32.lib advapi32.lib /link /out:$(PROG).exe
|
|
||||||
WSRCS = ../../mongoose.c main.c mbedtls/library/*.c
|
|
||||||
$(PROG).exe: main.c mbedtls
|
|
||||||
$(DOCKER) mdashnet/vc2017 wine cl $(WSRCS) $(WDEFS) $(WFLAGS)
|
|
||||||
vc2017: ARGS = https://cesanta.com
|
|
||||||
vc2017: $(PROG).exe
|
|
||||||
$(DOCKER) mdashnet/vc2017 wine $(PROG).exe $(ARGS)
|
|
||||||
mbedtls:
|
|
||||||
git clone --depth 1 -b v3.1.0 https://github.com/ARMmbed/mbedtls
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(PROG) _CL* *.o *.dSYM *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb mbedtls
|
$(DELETE) $(PROG) *.o *.obj *.exe *.dSYM
|
||||||
|
1
examples/http-client/mongoose.c
Symbolic link
1
examples/http-client/mongoose.c
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../mongoose.c
|
1
examples/http-client/mongoose.h
Symbolic link
1
examples/http-client/mongoose.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../mongoose.h
|
Loading…
Reference in New Issue
Block a user