Skip to content

Commit 4e27a50

Browse files
committed
8.1.2a
1 parent d5cd831 commit 4e27a50

25 files changed

Lines changed: 2197 additions & 1402 deletions

posix-win32/blinky/Makefile

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ VPATH := .
5151
INCLUDES := -I.
5252

5353
C_SRCS := \
54+
main.c \
55+
bsp.c \
5456
blinky.c
5557

5658
DEFINES :=
5759

5860
CPP_SRCS :=
61+
5962
LIB_DIRS :=
6063
LIBS :=
6164
OUTPUT := $(PROJECT)
@@ -65,34 +68,34 @@ OUTPUT := $(PROJECT)
6568
#
6669
TARGET := host
6770

68-
DEFINES :=
71+
DEFINES +=
6972

7073
BIN_DIR := build_$(TARGET)
7174

7275
#-----------------------------------------------------------------------------
7376
# QP framework
7477
#
7578

76-
# location of the QP/C framework (if not provided in an env. variable)
77-
ifeq ($(QP),)
78-
QP := ../../..
79+
# location of the QP framework (if not provided in an env. variable)
80+
ifeq ($(QPC),)
81+
QPC := ../../..
7982
endif
8083

8184
ifeq ($(OS),Windows_NT)
8285

8386
ifdef QV
84-
QP_PORT_DIR := $(QP)/ports/win32-qv
87+
QP_PORT_DIR := $(QPC)/ports/win32-qv
8588
else
86-
QP_PORT_DIR := $(QP)/ports/win32
89+
QP_PORT_DIR := $(QPC)/ports/win32
8790
endif
8891
LIBS += -lws2_32
8992

9093
else
9194

9295
ifdef QV
93-
QP_PORT_DIR := $(QP)/ports/posix-qv
96+
QP_PORT_DIR := $(QPC)/ports/posix-qv
9497
else
95-
QP_PORT_DIR := $(QP)/ports/posix
98+
QP_PORT_DIR := $(QPC)/ports/posix
9699
endif
97100
LIBS += -lpthread
98101

@@ -102,11 +105,11 @@ VPATH += \
102105
$(QP_PORT_DIR)
103106

104107
INCLUDES += \
105-
-I$(QP)/include \
108+
-I$(QPC)/include \
106109
-I$(QP_PORT_DIR)
107110

108111
#-----------------------------------------------------------------------------
109-
# QP/C framework sources
112+
# QP framework sources
110113
#
111114
QP_SRCS := \
112115
qep_hsm.c \
@@ -131,52 +134,61 @@ QS_SRCS := \
131134
qs_port.c
132135

133136
VPATH += \
134-
$(QP)/src/qf \
135-
$(QP)/src/qs $(QP_PORT_DIR)
137+
$(QPC)/src/qf \
138+
$(QPC)/src/qs \
139+
$(QP_PORT_DIR)
136140

137141
INCLUDES += \
138-
-I$(QP)/include \
142+
-I$(QPC)/include \
139143
-I$(QP_PORT_DIR)
140144

141145
# add the QP sources to the build
142146
C_SRCS += $(QP_SRCS)
143147

144148
ifeq (spy, $(CONF)) # Spy configuration
145-
VPATH += $(QP)/src/qs
149+
VPATH += $(QPC)/src/qs
146150
C_SRCS += $(QS_SRCS)
147151
endif
148152

149153
#-----------------------------------------------------------------------------
150-
# GNU toolset:
151-
# NOTE: GNU toolset (MinGW) is included in the QTools collection for Windows, see:
152-
# https://www.state-machine.com/qtools
154+
# GNU GCC toolset for the host:
155+
# NOTE: GNU toolset for Windows (MinGW) is included in the QTools collection
156+
# for Windows, see: https://www.state-machine.com/qtools
157+
#
153158
# It is assumed that %QTOOLS%\bin directory is added to the PATH
154159
#
155160
CC := gcc
156161
CPP := g++
157162
LINK := gcc # for C programs
158163
#LINK := g++ # for C++ programs
159-
COV := gcov -f
160164

161165
#-----------------------------------------------------------------------------
162166
# basic utilities (included in QTools for Windows), see:
163167
# https://www.state-machine.com/qtools
164168
#
165169
ifeq ($(OS),Windows_NT)
170+
TARGET_EXT := .exe
166171
MKDIR := mkdir
167172
RM := rm
168-
TARGET_EXT := .exe
173+
CAT := type
174+
COV := gcov -abcgum
175+
CODE_COV := --coverage -fcondition-coverage # NOTE: required gcc 14 or newer
169176
else ifeq ($(OSTYPE),cygwin)
177+
TARGET_EXT := .exe
170178
MKDIR := mkdir -p
171179
RM := rm -f
172-
TARGET_EXT := .exe
180+
CAT := cat
181+
COV := gcov -b
182+
CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
173183
else
184+
TARGET_EXT :=
174185
MKDIR := mkdir -p
175186
RM := rm -f
176-
TARGET_EXT :=
187+
CAT := cat
188+
COV := gcov -b
189+
CODE_COV := -fprofile-arcs -ftest-coverage # old gcc (version < 14)
177190
endif
178191

179-
180192
##############################################################################
181193
# Typically you should not need to change anything below this line
182194

@@ -187,10 +199,12 @@ ifeq (rel, $(CONF)) # Release configuration ..................................
187199

188200
BIN_DIR := build_rel
189201
# gcc options:
190-
CFLAGS := -c -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
202+
CFLAGS := -c -fno-pie -std=c11 -pedantic \
203+
-Wall -Wextra -Wpedantic -Wsign-conversion \
191204
-O3 $(INCLUDES) $(DEFINES) $(DEF) -DNDEBUG
192205

193-
CPPFLAGS := -c -fno-pie -std=c++11 -pedantic -Wall -Wextra \
206+
CPPFLAGS := -c -g -fno-pie -std=c++17 -pedantic \
207+
-Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
194208
-fno-rtti -fno-exceptions \
195209
-O3 $(INCLUDES) $(DEFINES) $(DEF) -DNDEBUG
196210

@@ -199,10 +213,12 @@ else ifeq (spy, $(CONF)) # Spy configuration ................................
199213
BIN_DIR := build_spy
200214

201215
# gcc options:
202-
CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
216+
CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
217+
-Wall -Wextra -Wpedantic -Wsign-conversion \
203218
-O $(INCLUDES) $(DEFINES) $(DEF) -DQ_SPY
204219

205-
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
220+
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic \
221+
-Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
206222
-fno-rtti -fno-exceptions \
207223
-O $(INCLUDES) $(DEFINES) -DQ_SPY
208224

@@ -211,23 +227,25 @@ else # default Debug configuration .........................................
211227
BIN_DIR := build
212228

213229
# gcc options:
214-
CFLAGS := -c -g -fno-pie -std=c11 -pedantic -Wall -Wextra -W \
230+
CFLAGS := -c -g -fno-pie -std=c11 -pedantic \
231+
-Wall -Wextra -Wpedantic -Wsign-conversion \
215232
-O $(INCLUDES) $(DEFINES) $(DEF)
216233

217-
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic -Wall -Wextra \
234+
CPPFLAGS := -c -g -fno-pie -std=c++11 -pedantic \
235+
-Wall -Wextra -Wpedantic -Wsign-conversion -Wold-style-cast \
218236
-fno-rtti -fno-exceptions \
219237
-O $(INCLUDES) $(DEFINES) $(DEF)
220238

221239
endif # .....................................................................
222240

223-
ifndef GCC_OLD
224-
LINKFLAGS := -no-pie
241+
ifdef GCOV
242+
CFLAGS += $(CODE_COV)
243+
CPPFLAGS += $(CODE_COV)
244+
LINKFLAGS := $(CODE_COV)
225245
endif
226246

227-
ifdef GCOV
228-
CFLAGS += -fprofile-arcs -ftest-coverage
229-
CPPFLAGS += -fprofile-arcs -ftest-coverage
230-
LINKFLAGS += -lgcov --coverage
247+
ifndef GCC_OLD
248+
LINKFLAGS += -no-pie
231249
endif
232250

233251
#-----------------------------------------------------------------------------
@@ -247,7 +265,6 @@ endif
247265

248266
#-----------------------------------------------------------------------------
249267
# rules
250-
#
251268

252269
.PHONY: clean show
253270

@@ -256,7 +273,7 @@ all: $(TARGET_EXE)
256273
ifeq (spy, $(CONF))
257274

258275
$(TARGET_EXE) : $(C_OBJS_EXT) $(CPP_OBJS_EXT)
259-
$(CC) $(CFLAGS) $(QP)/src/qs/qstamp.c -o $(BIN_DIR)/qstamp.o
276+
$(CC) $(CFLAGS) $(QPC)/src/qs/qstamp.c -o $(BIN_DIR)/qstamp.o
260277
$(LINK) $(LINKFLAGS) $(LIB_DIRS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
261278

262279
else
@@ -281,12 +298,12 @@ $(BIN_DIR)/%.o : %.cpp
281298
# create BIN_DIR and include dependencies only if needed
282299
ifneq ($(MAKECMDGOALS),clean)
283300
ifneq ($(MAKECMDGOALS),show)
284-
ifneq ($(MAKECMDGOALS),debug)
301+
ifneq ($(MAKECMDGOALS),debug)
285302
ifeq ("$(wildcard $(BIN_DIR))","")
286303
$(shell $(MKDIR) $(BIN_DIR))
287304
endif
288305
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
289-
endif
306+
endif
290307
endif
291308
endif
292309

posix-win32/blinky/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Example: Blinky Console
22

3-
![Blinky on Win32](blinky_win.png)
3+
![Blinky on Win32](blinky_con.gif)
44

55
This example corresponds to the QM Tutorial at:
66

77
https://www.state-machine.com/qm/gs_tut.html
88

9+
The following files comprise the project:
910

10-
Specifically the files are as follows:
11+
- the `blinky_console.qm` model file, from which all other
12+
files are generated:
1113

12-
```
13-
blinky.qm - the QM model for the Blinky active object
14-
blinky.c - the generated code for the Blinky application
15-
Makefile - the makefile to build Blinky on Windows/Linux/macOS
16-
```
14+
- `blinky.c` - the generated code for the Blinky application
15+
- `bsp.h` - the generated code for the Board Support Package
16+
- `bsp.c` - the generated code for the Board Support Package
17+
- `main.c` - the generated code for the main function
18+
- `Makefile` - the generated makefile to build Blinky on Windows/Linux/macOS
19+
20+
## Blinky State Machine and Code
21+
22+
![Blinky state machine and code](blinky_smc.png)

0 commit comments

Comments
 (0)