Skip to content

Commit 79288f1

Browse files
committed
Adding mingw to testing tcp apps.
Signed-off-by: Dusan Cervenka <[email protected]>
1 parent 1c74c75 commit 79288f1

File tree

15 files changed

+68
-28
lines changed

15 files changed

+68
-28
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
steps:
5050
- checkout
5151
- run: powershell.exe .\install_dependencies.ps1
52-
- run: powershell.exe .\mingw64\bin\mingw32-make erpcgen
52+
- run: .\mingw64\bin\mingw32-make all
53+
- run: .\mingw64\opt\bin\python3.exe .\test\run_unit_tests.py
5354
# - store_artifacts:
5455
# path: ./Release/MINGW64/erpcgen/erpcgen.exe
5556
build-windows-VS:

erpc_c/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ SOURCES += $(ERPC_C_ROOT)/infra/erpc_arbitrated_client_manager.cpp \
6363
$(ERPC_C_ROOT)/infra/erpc_pre_post_action.cpp \
6464
$(ERPC_C_ROOT)/port/erpc_port_stdlib.cpp \
6565
$(ERPC_C_ROOT)/port/erpc_threading_pthreads.cpp \
66-
$(ERPC_C_ROOT)/port/erpc_serial.cpp \
6766
$(ERPC_C_ROOT)/setup/erpc_arbitrated_client_setup.cpp \
6867
$(ERPC_C_ROOT)/setup/erpc_client_setup.cpp \
6968
$(ERPC_C_ROOT)/setup/erpc_setup_mbf_dynamic.cpp \
@@ -72,8 +71,11 @@ SOURCES += $(ERPC_C_ROOT)/infra/erpc_arbitrated_client_manager.cpp \
7271
$(ERPC_C_ROOT)/setup/erpc_setup_serial.cpp \
7372
$(ERPC_C_ROOT)/setup/erpc_setup_tcp.cpp \
7473
$(ERPC_C_ROOT)/transports/erpc_inter_thread_buffer_transport.cpp \
75-
$(ERPC_C_ROOT)/transports/erpc_serial_transport.cpp \
7674
$(ERPC_C_ROOT)/transports/erpc_tcp_transport.cpp
75+
ifeq "$(is_mingw)" ""
76+
SOURCES += $(ERPC_C_ROOT)/transports/erpc_serial_transport.cpp \
77+
$(ERPC_C_ROOT)/port/erpc_serial.cpp
78+
endif
7779

7880
HEADERS += $(ERPC_C_ROOT)/config/erpc_config.h \
7981
$(ERPC_C_ROOT)/infra/erpc_arbitrated_client_manager.hpp \

erpc_c/port/erpc_config_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#if !defined(ERPC_HAS_POSIX)
2323
// Detect Linux, BSD, Cygwin, and Mac OS X.
2424
#if defined(__linux__) || defined(__GNU__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
25-
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) || defined(__MACH__)
25+
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) || defined(__MACH__) || \
26+
defined(__MINGW32__)
2627
#define ERPC_HAS_POSIX (1)
2728
#else
2829
#define ERPC_HAS_POSIX (0)

erpc_c/port/erpc_port_stdlib.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
using namespace std;
1717

18+
#if !defined(__MINGW32__)
1819
void *operator new(size_t count) THROW_BADALLOC
1920
{
2021
void *p = erpc_malloc(count);
@@ -62,6 +63,7 @@ void operator delete[](void *ptr, std::size_t count) THROW NOEXCEPT
6263
(void)count;
6364
erpc_free(ptr);
6465
}
66+
#endif
6567

6668
void *erpc_malloc(size_t size)
6769
{

erpc_c/transports/erpc_tcp_transport.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,34 @@
1313
#include <string>
1414

1515
extern "C" {
16+
// Set this to 1 to enable debug logging.
17+
// TODO fix issue with the transport not working on Linux if debug logging is disabled.
18+
//#define TCP_TRANSPORT_DEBUG_LOG (1)
19+
20+
#if TCP_TRANSPORT_DEBUG_LOG
1621
#if ERPC_HAS_POSIX
22+
#if defined(__MINGW32__)
23+
#error Missing implementation for mingw.
24+
#endif
1725
#include <err.h>
1826
#endif
27+
#endif
1928
#include <errno.h>
2029
#if defined(__MINGW32__)
21-
#include <winsock2.h>
2230
#include <ws2tcpip.h>
2331
#include <ws2def.h>
2432
#else
2533
#include <netdb.h>
2634
#include <netinet/tcp.h>
35+
#include <sys/socket.h>
2736
#endif
2837
#include <signal.h>
29-
#include <sys/socket.h>
3038
#include <sys/types.h>
3139
#include <unistd.h>
3240
}
3341

3442
using namespace erpc;
3543

36-
// Set this to 1 to enable debug logging.
37-
// TODO fix issue with the transport not working on Linux if debug logging is disabled.
38-
//#define TCP_TRANSPORT_DEBUG_LOG (1)
39-
4044
#if TCP_TRANSPORT_DEBUG_LOG
4145
#define TCP_DEBUG_PRINT(_fmt_, ...) printf(_fmt_, ##__VA_ARGS__)
4246
#define TCP_DEBUG_ERR(_msg_) err(errno, _msg_)

erpc_c/transports/erpc_tcp_transport.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#ifndef _EMBEDDED_RPC__TCP_TRANSPORT_H_
1010
#define _EMBEDDED_RPC__TCP_TRANSPORT_H_
1111

12-
#include "erpc_framed_transport.hpp"
13-
#include "erpc_threading.h"
14-
1512
#if defined(__MINGW32__)
1613
#include <winsock2.h>
1714
#endif
1815

16+
#include "erpc_framed_transport.hpp"
17+
#include "erpc_threading.h"
18+
1919
/*!
2020
* @addtogroup tcp_transport
2121
* @{

erpcgen/src/templates/c_common_functions.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
{% if empty(crc16) == false %}
2828
// for mdk/keil do not forgett add "--muldefweak" for linker
2929
extern const uint32_t erpc_generated_crc;
30+
#if defined(__MINGW32__)
31+
__declspec( selectany )
32+
#else
3033
#pragma weak erpc_generated_crc
34+
#endif
3135
extern const uint32_t erpc_generated_crc = {$crc16};
3236
{% endif -- empty(crc16) == false %}
3337
{% enddef --checkCrc %}
@@ -38,7 +42,11 @@ extern const uint32_t erpc_generated_crc = {$crc16};
3842

3943
// Constant variable definitions
4044
{% for c in consts %}
45+
#if defined(__MINGW32__)
46+
__declspec( selectany )
47+
#else
4148
#pragma weak {$c.name}
49+
#endif
4250
extern const {$c.typeAndName} = {$c.value};
4351
{% endfor -- consts %}
4452
{% endif %}

mk/common.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ else
7575
# Set to 1 if running on Linux.
7676
is_linux := $(and $(findstring Linux,$(os_name)),1)
7777

78-
is_mingw := $(and $(findstring MSYS_NT,$(os_name)),1)
78+
# Set to 1 if running on Windows under Mingw.
79+
is_mingw := $(and $(findstring MINGW,$(os_name)),1)
80+
ifeq "$(is_mingw)" ""
81+
is_mingw := $(and $(findstring MSYS_NT,$(os_name)),1)
82+
endif
7983
endif
8084

8185
ifeq "$(is_mingw)" "1"

mk/flags.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ else
6868
CXXFLAGS += -g3 -O0 -DDEBUG -DYYDEBUG=1
6969
endif
7070

71-
ifneq "$(is_mingw)" "1"
72-
LIBRARIES += -lc
73-
endif
74-
7571
ifneq "$(is_cygwin)" "1"
7672
LIBRARIES += -lstdc++
7773
endif
@@ -81,3 +77,9 @@ ifeq "$(is_linux)" "1"
8177
endif
8278

8379
LIBRARIES += -lm
80+
81+
ifeq "$(is_mingw)" "1"
82+
LIBRARIES += -pthread -lws2_32
83+
else
84+
LIBRARIES += -lc
85+
endif

mk/targets.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ $(MAKE_TARGET): $(OBJECTS_ALL)
122122
@$(call printmessage,link,Linking, $(APP_NAME))
123123
$(at)$(LD) $(LDFLAGS) \
124124
$(OBJECTS_ALL) \
125-
$(LIBRARIES) \
126-
-o $@
125+
-o $@ \
126+
$(LIBRARIES)
127127
@echo "Output binary:" ; echo " $(APP_NAME)"
128128

129129
endif

0 commit comments

Comments
 (0)