mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-07 08:20:18 +00:00
This adds the libqb_http API, which is designed to support HTTP and HTTPS usage from QB64-PE source. The design consists of a single thread which services all the HTTP(s) connections. There are then various libqb_http APIs exposed that allow interacting with this thread to create a new connection, query connection status, read data, or close the connection. Internally the thread makes use of the curl_multi interface to allow a single thread to service multiple HTTP(s) connections in parallel. This means you can _OPENCLIENT() multiple HTTP connection in a row and all of them will be serviced at the same time in whatever order data is available. HTTP is optional and selected via a Makefile setting. A stub is swapped in if HTTP support is not used, which avoids need to add another build flag to libqb.cpp.
56 lines
1.4 KiB
Makefile
56 lines
1.4 KiB
Makefile
|
|
TESTS :=
|
|
|
|
TEST_CFLAGS-y := -I'./tests/c/include' \
|
|
-I$(PATH_LIBQB)/include \
|
|
-g -std=gnu++11
|
|
|
|
TEST_CFLAGS-$(win) += -mconsole -static-libgcc -static-libstdc++
|
|
|
|
TEST_DEF_OBJS := tests/c/test.o
|
|
|
|
# Defines the list of test sets
|
|
TESTS += buffer
|
|
TESTS += http
|
|
|
|
# Describe how to build each test
|
|
buffer.src-y := ./tests/c/buffer.cpp \
|
|
$(PATH_LIBQB)/src/buffer.cpp
|
|
|
|
http.src-y := ./tests/c/http.cpp \
|
|
$(PATH_LIBQB)/src/http.cpp \
|
|
$(PATH_LIBQB)/src/buffer.cpp \
|
|
$(PATH_LIBQB)/src/threading-$(PLATFORM).cpp \
|
|
$(PATH_LIBQB)/src/threading.cpp
|
|
|
|
http.cflags-y := $(CURL_CXXFLAGS)
|
|
http.libs-y := $(CURL_CXXLIBS)
|
|
http.exe-libs-y := $(CURL_EXE_LIBS)
|
|
|
|
http.libs-$(lnx) += -lpthread
|
|
http.libs-$(win) += -lws2_32
|
|
|
|
|
|
TEST_OBJS := $(TEST_DEF_OBJS)
|
|
TEST_OBJS += $(foreach test,$(TESTS),$(filter ./tests/c/%,$($(test)).objs-y))
|
|
|
|
TEST_TESTS :=
|
|
|
|
define TEST_template
|
|
TEST_TESTS += ./tests/exes/cpp/$(1)_test$(EXTENSION)
|
|
tests/exes/cpp/$(1)_test$(EXTENSION): $$(TEST_DEF_OBJS) $$($(1).src-y) $$($(1).exe-libs-y) | tests/exes/cpp
|
|
$$(CXX) $$(TEST_CFLAGS-y) $$($(1).cflags-y) $$^ -o $$@ $$($(1).exe-libs-y) $$($(1).libs-y)
|
|
endef
|
|
|
|
$(foreach test,$(TESTS),$(eval $(call TEST_template,$(test))))
|
|
|
|
CLEAN_LIST += $(TEST_OBJS)
|
|
|
|
tests/exes:
|
|
$(MKDIR) $(call FIXPATH,$@)
|
|
|
|
tests/exes/cpp: | tests/exes
|
|
$(MKDIR) $(call FIXPATH,$@)
|
|
|
|
PHONY += build-tests
|
|
build-tests: $(TEST_DEF_OBJS) $(TEST_TESTS)
|