rustls-ffi 0.9.2

Rustls bindings for non-Rust languages
Documentation
#
# 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=

VPATH = tests

RUSTLS_LIB = target/release/rustls_ffi.lib

USE_CLANG_CL ?= 0

green_msg = @echo -e "\e[1;32m$(strip $(1))\e[0m"

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 -Wno-pointer-sign
else
  CC = cl
endif

all: $(RUSTLS_LIB) target/client.exe target/server.exe

test: all
	$(call green_msg, getting 'https://httpbin.org/headers' ...)
	target/client.exe httpbin.org 443 /headers
	$(call green_msg, Running 'cargo test')
	cargo test

$(RUSTLS_LIB): src/lib.rs Cargo.toml
	$(call green_msg, Building '$@')
	RUSTFLAGS="--print native-static-libs" cargo build --release
	@echo

%.obj: tests/%.c
	$(CC) -Fo$@ -c $< $(CFLAGS)
	@echo

target/%.exe: common.obj %.obj $(RUSTLS_LIB)
	$(call link_EXE, $@, $^ advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib)

clean:
	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