forked from aws/aws-iot-device-sdk-embedded-C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (100 loc) · 3.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#This target is to ensure accidental execution of Makefile as a bash script will not execute commands like rm in unexpected directories and exit gracefully.
.prevent_execution:
exit 0
#Set this to @ to keep the makefile quiet
ifndef SILENCE
SILENCE = @
endif
CC = gcc
RM = rm
DEBUG =
#--- Inputs ----#
COMPONENT_NAME = IotSdkC
ALL_TARGETS := build-cpputest
ALL_TARGETS_CLEAN :=
CPPUTEST_USE_EXTENSIONS = Y
CPP_PLATFORM = Gcc
CPPUTEST_CFLAGS += -std=gnu99
CPPUTEST_LDFLAGS += -lpthread
CPPUTEST_CFLAGS += -D__USE_BSD
CPPUTEST_USE_GCOV = Y
#IoT client directory
IOT_CLIENT_DIR = .
APP_DIR = $(IOT_CLIENT_DIR)/tests/unit
APP_NAME = aws_iot_sdk_unit_tests
APP_SRC_FILES = $(shell find $(APP_DIR)/src -name '*.cpp')
APP_SRC_FILES += $(shell find $(APP_DIR)/src -name '*.c')
APP_INCLUDE_DIRS = -I $(APP_DIR)/include
CPPUTEST_DIR = $(IOT_CLIENT_DIR)/external_libs/CppUTest
# Provide paths for CppUTest to run Unit Tests otherwise build will fail
ifndef CPPUTEST_INCLUDE
CPPUTEST_INCLUDE = $(CPPUTEST_DIR)/include
endif
ifndef CPPUTEST_BUILD_LIB
CPPUTEST_BUILD_LIB = $(CPPUTEST_DIR)
endif
CPPUTEST_LDFLAGS += -ldl $(CPPUTEST_BUILD_LIB)/libCppUTest.a
PLATFORM_DIR = $(IOT_CLIENT_DIR)/platform/linux
#MbedTLS directory
TEMP_MBEDTLS_SRC_DIR = $(APP_DIR)/tls_mock
TLS_LIB_DIR = $(TEMP_MBEDTLS_SRC_DIR)
TLS_INCLUDE_DIR = -I $(TEMP_MBEDTLS_SRC_DIR)
# Logging level control
#LOG_FLAGS += -DENABLE_IOT_DEBUG
#LOG_FLAGS += -DENABLE_IOT_TRACE
#LOG_FLAGS += -DENABLE_IOT_INFO
#LOG_FLAGS += -DENABLE_IOT_WARN
#LOG_FLAGS += -DENABLE_IOT_ERROR
COMPILER_FLAGS += $(LOG_FLAGS)
EXTERNAL_LIBS += -L$(CPPUTEST_BUILD_LIB)
#IoT client directory
PLATFORM_COMMON_DIR = $(PLATFORM_DIR)/common
IOT_INCLUDE_DIRS = -I $(PLATFORM_COMMON_DIR)
IOT_INCLUDE_DIRS += -I $(IOT_CLIENT_DIR)/include
IOT_INCLUDE_DIRS += -I $(IOT_CLIENT_DIR)/external_libs/jsmn
IOT_SRC_FILES += $(shell find $(PLATFORM_COMMON_DIR)/ -name '*.c')
IOT_SRC_FILES += $(shell find $(IOT_CLIENT_DIR)/src/ -name '*.c')
IOT_SRC_FILES += $(shell find $(IOT_CLIENT_DIR)/external_libs/jsmn/ -name '*.c')
#Aggregate all include and src directories
INCLUDE_DIRS += $(IOT_INCLUDE_DIRS)
INCLUDE_DIRS += $(APP_INCLUDE_DIRS)
INCLUDE_DIRS += $(TLS_INCLUDE_DIR)
INCLUDE_DIRS += $(CPPUTEST_INCLUDE)
TEST_SRC_DIRS = $(APP_DIR)/src
SRC_FILES += $(APP_SRC_FILES)
SRC_FILES += $(IOT_SRC_FILES)
COMPILER_FLAGS += -g
COMPILER_FLAGS += $(LOG_FLAGS)
PRE_MAKE_CMDS = cd $(CPPUTEST_DIR) &&
PRE_MAKE_CMDS += cmake CMakeLists.txt &&
PRE_MAKE_CMDS += make &&
PRE_MAKE_CMDS += cd - &&
PRE_MAKE_CMDS += pwd &&
PRE_MAKE_CMDS += cp -f $(CPPUTEST_DIR)/src/CppUTest/libCppUTest.a $(CPPUTEST_DIR)/libCppUTest.a &&
PRE_MAKE_CMDS += cp -f $(CPPUTEST_DIR)/src/CppUTestExt/libCppUTestExt.a $(CPPUTEST_DIR)/libCppUTestExt.a
# Using TLS Mock for running Unit Tests
MOCKS_SRC += $(APP_DIR)/tls_mock/aws_iot_tests_unit_mock_tls_params.c
MOCKS_SRC += $(APP_DIR)/tls_mock/aws_iot_tests_unit_mock_tls.c
ISYSTEM_HEADERS += $(IOT_ISYSTEM_HEADERS)
CPPUTEST_CPPFLAGS += $(ISYSTEM_HEADERS)
CPPUTEST_CPPFLAGS += $(LOG_FLAGS)
LCOV_EXCLUDE_PATTERN = "tests/unit/*"
LCOV_EXCLUDE_PATTERN += "tests/integration/*"
LCOV_EXCLUDE_PATTERN += "external_libs/*"
#use this section for running a specific group of tests, comment this to run all
#ONLY FOR TESTING PURPOSE
#COMMAND_LINE_ARGUMENTS += -g CommonTests
#COMMAND_LINE_ARGUMENTS += -v
build-cpputest:
$(PRE_MAKE_CMDS)
include CppUTestMakefileWorker.mk
.PHONY: run-unit-tests
run-unit-tests: $(ALL_TARGETS)
@echo $(ALL_TARGETS)
.PHONY: clean
clean:
$(MAKE) -C $(CPPUTEST_DIR) clean
$(RM) -rf build_output
$(RM) -rf gcov
$(RM) -rf objs
$(RM) -rf testLibs