Skip to content

Commit

Permalink
add windows building dir
Browse files Browse the repository at this point in the history
  • Loading branch information
lalawue committed Oct 2, 2022
1 parent 8214ca5 commit b11ab09
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ src/*.o
extension/lua/*.o
extension/mdns_utils/*.o
.vscode/
win/out/
!win/openssl/README.md
win/openssl/
73 changes: 0 additions & 73 deletions Makefile.msys2

This file was deleted.

46 changes: 46 additions & 0 deletions win/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# About

this is windows building dir under MSYS2.

you can edit `build.sh` for further configuration.


## Building

under MSYS2 bash shell, just

```sh
$ sh build.sh
```

if you need OpenSSL, read OpenSSL section to copy required resoureces.


## Runing

Win+R open cmd.exe, run server

```sh
> run.bat out\tls_test_reconnect.exe -s
```

Win+R open another cmd.exe, run client side

```sh
> run.bat out\tls_test_reconnect.exe -c
```

and you can test `out\tls_test_rwdata.exe`.


## OpenSSL

the project contains an pre-compiled OpenSSL bundle under Win10, you can get it from release page.

or you can install lastest OpenSSL from [https://slproweb.com/products/Win32OpenSSL.html](https://slproweb.com/products/Win32OpenSSL.html),

after install to `C:\Program Files\OpenSSL-Win64`, copy lib and headers to `openssl/` dir

- copy `libcrypto` and `libssl` into `openssl/lib/` dir, link to short name.
- copy `include/` header dir into `openssl/` dir.
64 changes: 64 additions & 0 deletions win/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# build script under MSYS2
#

CC=gcc
CPP=g++

CFLAGS=' -Wall -std=c99 -Wdeprecated-declarations -D_POSIX_C_SOURCE=200112L -DWEPOLL_EXPRIMENT'
CPPFLAGS=' -Wall -Wdeprecated-declarations -Wno-deprecated'

OPENSSL_DIR='include'
MNET_LIBNAME='mnet.dll'

DEBUG=' -g'
RELEASE=' -O2'
LIBS=' -lWs2_32 -lmnet -Lbuild'

LIB_SRCS=" ../src/*.c ../extension/mdns_utils/mdns_utils.c"
E_SRCS=" ../examples/*.c"
T_SRCS=" ../test/*.c"

OE_SRCS="../examples/openssl/*.c"
OL_SRCS="../extension/openssl/*.c"
OT_SRCS="../test/openssl/*.c"

CPP_SRCS="../test/*.cpp ../examples/*.cpp"

DIRS="../src/ ../extension/openssl/"
INCS="-I../src/ -I../extension/openssl/"

O_INCS="-Iopenssl/include"
O_DIRS="-Lopenssl/lib -Lout"
O_LIBS=" -lssl -lcrypto"

OUT="out"

# build
#
sh clean.sh

# lib
#echo $CC $RELEASE $CFLAGS $INCS -o $OUT/$MNET_LIBNAME $LIB_SRCS -lWs2_32 -shared -fPIC
#$CC $RELEASE $CFLAGS $INCS -o $OUT/$MNET_LIBNAME $LIB_SRCS -lWs2_32 -shared -fPIC

# pull
#echo $CC $DEBUG $CFLAGS $INCS -o $OUT/ntp.out $E_SRCS $LIBS -DEXAMPLE_NTP
#$CC $DEBUG $CFLAGS $INCS -o $OUT/ntp.out $E_SRCS $LIBS -DEXAMPLE_NTP

#echo $CC $DEBUG $CFLAGS $INCS -o $OUT/echo_svr_pull_style.out $E_SRCS $LIBS -DEXAMPLE_ECHO_SVR_PULL_STYLE
#$CC $DEBUG $CFLAGS $INCS -o $OUT/echo_svr_pull_style.out $E_SRCS $LIBS -DEXAMPLE_ECHO_SVR_PULL_STYLE

# callback
#echo $CPP $DEBUG $CPPFLAGS $INCS --std=c++0x -o $OUT/echo_cnt.out $CPP_SRCS $LIBS -DEXAMPLE_ECHO_CNT
#$CPP $DEBUG $CPPFLAGS $INCS --std=c++0x -o $OUT/echo_cnt.out $CPP_SRCS $LIBS -DEXAMPLE_ECHO_CNT

# openssl
echo $CC $RELEASE $CFLAGS $INCS $O_INCS $O_DIRS -o $OUT/$MNET_LIBNAME $LIB_SRCS $OL_SRCS -lWs2_32 -shared -fPIC $O_LIBS
$CC $RELEASE $CFLAGS $INCS $O_INCS $O_DIRS -o $OUT/$MNET_LIBNAME $LIB_SRCS $OL_SRCS -lWs2_32 -shared -fPIC $O_LIBS

echo $CC $DEBUG $CFLAGS $INCS $O_INCS $O_DIRS -o $OUT/tls_test_reconnect $OT_SRCS $O_LIBS -lmnet -DMNET_TLS_TEST_RECONNECT_PULL_STYLE
$CC $DEBUG $CFLAGS $INCS $O_INCS $O_DIRS -o $OUT/tls_test_reconnect $OT_SRCS $O_LIBS -lmnet -DMNET_TLS_TEST_RECONNECT_PULL_STYLE

echo $CC $DEBUG $CFLAGS $INCS $O_INCS $O_DIRS -o $OUT/tls_test_rwdata $OT_SRCS $O_LIBS -lmnet -DMNET_TLS_TEST_RWDATA_PULL_STYLE
$CC $DEBUG $CFLAGS $INCS $O_INCS $O_DIRS -o $OUT/tls_test_rwdata $OT_SRCS $O_LIBS -lmnet -DMNET_TLS_TEST_RWDATA_PULL_STYLE
10 changes: 10 additions & 0 deletions win/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# clean dir
echo === clean dir ===
echo rm -rf out
rm -rf out
echo mkdir -p out
mkdir -p out
echo rm -rf examples
rm -rf examples
echo === clean end ===
3 changes: 3 additions & 0 deletions win/openssl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- copy `libcrypto` and `libssl` into `openssl/lib/` dir, link to short name.
- copy `include/` header dir into `openssl/` dir.

8 changes: 8 additions & 0 deletions win/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rem
rem

echo off
PATH=%PATH%;openssl\lib\;bulid\;
RD /S /Q examples
XCOPY ..\examples .\examples /Y /E /I /Q
%*

0 comments on commit b11ab09

Please sign in to comment.