-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapted from #197 by gvanem. I squashed the commits from that PR, and added my own on top. We need to remove the link.exe provided by MSYS and Git to make sure they don't interfere with MSVC's link.exe. Also, add a #define for strncasecmp, which is not available on Windows.
- Loading branch information
Showing
3 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,65 @@ | ||
# | ||
# Create 'crustls.lib' and 'src/crustls.h' for Windows using | ||
# 'cl' or 'clang-cl'. | ||
# A GNU Makefile that creates: | ||
# target/release/rustls_ffi.lib -- using 'cargo build' | ||
# target/client.exe | ||
# target/server.exe | ||
# | ||
# for Windows using 'cl' or 'clang-cl'. | ||
# | ||
export CL= | ||
|
||
CRUSTLS_LIB = target/release/crustls.lib | ||
VPATH = tests | ||
|
||
RUSTLS_LIB = target/release/rustls_ffi.lib | ||
|
||
USE_CLANG_CL ?= 0 | ||
|
||
USE_CLANG_CL ?= 1 | ||
green_msg = @echo -e "\e[1;32m$(strip $(1))\e[0m" | ||
|
||
CFLAGS = -nologo -MD -Zi -W3 -O2 -I. -Dssize_t=int -D_CRT_SECURE_NO_WARNINGS | ||
LDFLAGS = -nologo -incremental:no | ||
CARGOFLAGS = --color never --release | ||
CFLAGS = -nologo -MD -Zi -W3 -O2 \ | ||
-I./src \ | ||
-D_WIN32_WINNT=0x601 \ | ||
-Dssize_t=int \ | ||
-D_CRT_SECURE_NO_WARNINGS \ | ||
-D_CRT_NONSTDC_NO_WARNINGS | ||
|
||
LDFLAGS = -nologo -incremental:no -debug | ||
|
||
ifeq ($(USE_CLANG_CL),1) | ||
CC = clang-cl | ||
CFLAGS += -ferror-limit=5 | ||
CFLAGS += -ferror-limit=5 -Wno-pointer-sign | ||
else | ||
CC = cl | ||
endif | ||
|
||
all: crustls.h $(CRUSTLS_LIB) # crustls-demo.exe | ||
all: $(RUSTLS_LIB) target/client.exe target/server.exe | ||
|
||
test: all | ||
crustls-demo.exe httpbin.org /headers | ||
|
||
crustls.h: src/lib.rs | ||
cbindgen --lang C --output $@ | ||
@echo | ||
$(call green_msg, getting 'https://httpbin.org/headers' ...) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
target/client.exe httpbin.org 443 /headers | ||
$(call green_msg, Running 'cargo test') | ||
cargo test | ||
|
||
# | ||
# Currently impossible on Windows since it used epoll API. | ||
# | ||
crustls-demo.exe: main.obj $(CRUSTLS_LIB) | ||
link $(LDFLAGS) -out:$@ $^ | ||
@echo | ||
|
||
$(CRUSTLS_LIB): src/lib.rs Cargo.toml | ||
cargo build $(CARGOFLAGS) | ||
$(RUSTLS_LIB): src/lib.rs Cargo.toml | ||
$(call green_msg, Building '$@') | ||
cargo build --release | ||
@echo | ||
|
||
main.obj: src/main.c crustls.h | ||
%.obj: tests/%.c | ||
$(CC) -Fo$@ -c $< $(CFLAGS) | ||
@echo | ||
|
||
target/%.exe: common.obj %.obj $(RUSTLS_LIB) | ||
$(call link_EXE, $@, $^ advapi32.lib userenv.lib ws2_32.lib) | ||
|
||
clean: | ||
rm -f *.obj target/.rustc_info.json $(CRUSTLS_LIB) crustls.h vc1*.pdb | ||
rm -f *.obj target/.rustc_info.json $(RUSTLS_LIB) vc1*.pdb | ||
rm -fR target/* | ||
rmdir target | ||
|
||
define link_EXE | ||
$(call green_msg, Linking $(1)) | ||
link $(LDFLAGS) -out:$(strip $(1)) $(2) | ||
@echo | ||
endef | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There could be a
export NO_CHECK_CERTIFICATE=1 ; \
here.