Skip to content

Commit a54a9f4

Browse files
committed
UPD | windows dll support
1 parent 08bed04 commit a54a9f4

95 files changed

Lines changed: 828 additions & 796 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ if (EXISTS "./build/generators/conan_toolchain.cmake")
1414
include(./build/generators/conan_toolchain.cmake)
1515
endif ()
1616

17-
add_compile_options(-fmerge-all-constants -fuse-ld=gold)
17+
if (WIN32)
18+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
19+
endif()
20+
21+
if (CMAKE_COMPILER_IS_GNUCXX)
22+
add_compile_options(-fmerge-all-constants)
23+
endif()
1824

1925
if (NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
2026
message(STATUS "This project has a top-level one called [${CMAKE_PROJECT_NAME}]")
@@ -145,7 +151,7 @@ if (MANAPIHTTP_BUILD_METHOD STREQUAL "conan")
145151

146152
if (MANAPIHTTP_BUILD_TYPE STREQUAL "exe")
147153
# For Testing
148-
find_package(PostgreSQL REQUIRED)
154+
find_package(PostgreSQL)
149155
endif ()
150156
else ()
151157
include(FetchContent)
@@ -572,6 +578,7 @@ string(REPLACE "{{ VAR_MANAPIHTTP_NGHTTP2_DEPENDENCY }}" $<BOOL:${MANAPIHTTP_NGH
572578
string(REPLACE "{{ VAR_MANAPIHTTP_NGHTTP3_DEPENDENCY }}" $<BOOL:${MANAPIHTTP_NGHTTP3_DEPENDENCY}> TEXT "${TEXT}")
573579
string(REPLACE "{{ VAR_MANAPIHTTP_CPPTRACE_DEPENDENCY }}" $<BOOL:${MANAPIHTTP_CPPTRACE_DEPENDENCY}> TEXT "${TEXT}")
574580
string(REPLACE "{{ VAR_MANAPIHTTP_STD_BACKTRACE_DEPENDENCY }}" $<BOOL:${MANAPIHTTP_STD_BACKTRACE_DEPENDENCY}> TEXT "${TEXT}")
581+
string(REPLACE "{{ VAR_MANAPIHTTP_IS_SHARED }}" $<BOOL:${BUILD_SHARED_LIBS}> TEXT "${TEXT}")
575582

576583
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/ManapiParams.hpp" CONTENT "${TEXT}")
577584
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/ManapiParams.hpp")
@@ -939,13 +946,21 @@ endif ()
939946

940947
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
941948

949+
950+
if (WIN32 AND BUILD_SHARED_LIBS)
951+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
952+
add_compile_definitions(MANAPIHTTP_BUILD_SHARED_LIBS)
953+
endif()
954+
942955
set(CMAKE_THREAD_PREFER_PTHREAD ON)
943956
set(THREADS_PREFER_PTHREAD_FLAG ON)
944957

945958
find_package(Threads)
946959
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
947960

948961
if (MANAPIHTTP_BUILD_METHOD STREQUAL "conan")
962+
get_target_property(LIBUV_INCLUDE_DIRECTORIES uv INTERFACE_INCLUDE_DIRECTORIES)
963+
message(STATUS "${LIBUV_INCLUDE_DIRECTORIES}")
949964
target_link_libraries (${PROJECT_NAME} PUBLIC uv)
950965

951966
if (MANAPIHTTP_BUILD_TYPE STREQUAL "exe")

conanfile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from conan import ConanFile
2+
from conan.tools.files import copy
23
from conan.tools.build import check_min_cppstd
34
from conan.tools.cmake import CMake, CMakeDeps, cmake_layout, CMakeToolchain
45
from conan.tools.apple import fix_apple_shared_install_name
56
from conan.errors import ConanInvalidConfiguration
67
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
78

9+
import os
10+
811
class ManapiHttpConan(ConanFile):
912
name = "manapihttp"
1013
description = "Fast http server/client"
@@ -100,6 +103,10 @@ def layout(self):
100103
cmake_layout(self)
101104

102105
def generate(self):
106+
for dep in self.dependencies.values():
107+
print("BINDIR PATH", dep.cpp_info.libdir)
108+
copy(self, "*.dll", dep.cpp_info.libdir, os.path.join(self.build_folder, 'bin'))
109+
103110
VirtualBuildEnv(self).generate()
104111

105112
runenv = VirtualRunEnv(self)

include/ManapiAsync.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,26 @@ namespace manapi {
1616
namespace async {
1717
class mutex_locker;
1818
class cthread;
19-
extern size_t max_stack_depth;
2019

2120
namespace internal {
2221
extern thread_local std::size_t current_stack_cnt;
2322

2423
extern thread_local std::shared_ptr<cthread> current_cthread_;
2524

26-
const std::shared_ptr<threadpool> &ethreadpool_(const std::shared_ptr<cthread> &ctx) MANAPIHTTP_NOEXCEPT;
25+
DLLExportImport const std::shared_ptr<threadpool> &ethreadpool_(const std::shared_ptr<cthread> &ctx) MANAPIHTTP_NOEXCEPT;
2726

28-
const std::shared_ptr<cthread> &current_ () MANAPIHTTP_NOEXCEPT;
27+
DLLExportImport const std::shared_ptr<cthread> &current_ () MANAPIHTTP_NOEXCEPT;
2928

30-
std::size_t current_stack_cnt_crt () MANAPIHTTP_NOEXCEPT;
29+
DLLExportImport std::size_t current_stack_cnt_crt () MANAPIHTTP_NOEXCEPT;
3130

32-
void current_stack_cnt_set (std::size_t cnt) MANAPIHTTP_NOEXCEPT;
31+
DLLExportImport void current_stack_cnt_set (std::size_t cnt) MANAPIHTTP_NOEXCEPT;
32+
33+
DLLExportImport std::size_t max_stack_depth2 () MANAPIHTTP_NOEXCEPT;
34+
35+
DLLExportImport void max_stack_depth2 (std::size_t cnt) MANAPIHTTP_NOEXCEPT;
3336
}
3437

35-
const std::shared_ptr<cthread> &current () MANAPIHTTP_NOEXCEPT;
38+
DLLExportImport const std::shared_ptr<cthread> &current () MANAPIHTTP_NOEXCEPT;
3639
}
3740

3841
class promise_base_future {
@@ -189,7 +192,7 @@ namespace manapi {
189192
promise.waiting = handle;
190193

191194
auto current_stack_cnt_ = manapi::async::internal::current_stack_cnt_crt ();
192-
if (current_stack_cnt_ >= async::max_stack_depth) {
195+
if (current_stack_cnt_ >= async::internal::max_stack_depth2()) {
193196
auto &thr = manapi::async::current();
194197
if (thr) {
195198
async::internal::ethreadpool_(thr)->append_task([handle = this->handle] () -> void {

include/ManapiBigint.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace manapi {
2525
* Bigint provides utilities to work
2626
* with large integers and decimals.
2727
*/
28-
class bigint {
28+
class DLLExportImport bigint {
2929
struct data_t;
3030

3131
struct data_t_deleter {

include/ManapiDebug.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ namespace manapi::debug {
3636
};
3737
#endif
3838

39-
extern int log_trace_enabled;
39+
DLLExportImport extern int log_trace_enabled;
4040

41-
void log_log(log_level type, const char* file, int line, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
41+
DLLExportImport void log_log(log_level type, const char* file, int line, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
4242

43-
void log_log(log_level type, const char* file, int line, int level, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
43+
DLLExportImport void log_log(log_level type, const char* file, int line, int level, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
4444

4545
// Convenience macros
4646
#define manapi_log_trace(...) manapi::debug::log_log(manapi::debug::LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)

include/ManapiDns.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ namespace manapi::dns {
2222
* Errors:
2323
* -
2424
*/
25-
manapi::future<int> getaddrinfo (const char * node, const char* service, const addrinfo *hints, addrinfo **res, async::cancellation_action token = nullptr);
25+
DLLExportImport manapi::future<int> getaddrinfo (const char * node, const char* service, const addrinfo *hints, addrinfo **res, async::cancellation_action token = nullptr);
2626
}

include/ManapiErrors.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <string>
1111
#include <memory>
1212
#include <format>
13+
#include <optional>
1314

1415
#include "./ManapiUtils.hpp"
1516

@@ -151,7 +152,7 @@ namespace manapi {
151152
/**
152153
* manapi exception
153154
*/
154-
class exception final : public std::exception {
155+
class DLLExportImport exception final : public std::exception {
155156
union messages {
156157
std::string_view view{};
157158
std::string storage;
@@ -201,7 +202,7 @@ namespace manapi {
201202
};
202203

203204
namespace error {
204-
class status {
205+
class DLLExportImport status {
205206
public:
206207
status ();
207208

include/ManapiEventLoop.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace manapi::ev::internal {
7373
}
7474

7575
namespace manapi {
76-
class event_loop {
76+
class DLLExportImport event_loop {
7777
public:
7878
event_loop();
7979

include/ManapiEventStructures.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ namespace manapi::ev {
432432
/* Stores the result of fs::stat() and other stat requests. */
433433
typedef uv_stat_t stat_t;
434434

435-
class async {
435+
class DLLExportImport async {
436436
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(async, uv_async_t)
437437
public:
438438
MANAPIHTTP_EV_DEFAULT(async, uv_async_t)
@@ -480,7 +480,7 @@ namespace manapi::ev {
480480
uv_async_t s_;
481481
};
482482

483-
class idle {
483+
class DLLExportImport idle {
484484
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(idle, uv_idle_t)
485485
public:
486486
MANAPIHTTP_EV_DEFAULT(idle, uv_idle_t)
@@ -519,7 +519,7 @@ namespace manapi::ev {
519519
uv_idle_t s_;
520520
};
521521

522-
class check {
522+
class DLLExportImport check {
523523
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(check, uv_check_t)
524524
public:
525525
MANAPIHTTP_EV_DEFAULT(check, uv_check_t)
@@ -558,7 +558,7 @@ namespace manapi::ev {
558558
uv_check_t s_;
559559
};
560560

561-
class io {
561+
class DLLExportImport io {
562562
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(io, uv_poll_t)
563563
public:
564564
MANAPIHTTP_EV_DEFAULT(io, uv_poll_t)
@@ -590,7 +590,7 @@ namespace manapi::ev {
590590
uv_poll_t s_;
591591
};
592592

593-
class write {
593+
class DLLExportImport write {
594594
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(write, uv_write_t)
595595
public:
596596
MANAPIHTTP_EV_DEFAULT(write, uv_write_t)
@@ -616,7 +616,7 @@ namespace manapi::ev {
616616
uv_connect_t s_{};
617617
};
618618

619-
class tcp {
619+
class DLLExportImport tcp {
620620
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(tcp, uv_tcp_t)
621621
public:
622622
MANAPIHTTP_EV_DEFAULT(tcp, uv_tcp_t)
@@ -661,7 +661,7 @@ namespace manapi::ev {
661661
uv_tcp_t s_;
662662
};
663663

664-
class udp {
664+
class DLLExportImport udp {
665665
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(udp, uv_udp_t)
666666
public:
667667
MANAPIHTTP_EV_DEFAULT(udp, uv_udp_t)
@@ -685,7 +685,7 @@ namespace manapi::ev {
685685
uv_udp_t s_;
686686
};
687687

688-
class udp_send {
688+
class DLLExportImport udp_send {
689689
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(udp_send, uv_udp_send_t)
690690
public:
691691
MANAPIHTTP_EV_DEFAULT(udp_send, uv_udp_send_t)
@@ -698,7 +698,7 @@ namespace manapi::ev {
698698
uv_udp_send_t s_;
699699
};
700700

701-
class prepare {
701+
class DLLExportImport prepare {
702702
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(prepare, uv_prepare_t)
703703
public:
704704
MANAPIHTTP_EV_DEFAULT(prepare, uv_prepare_t)
@@ -715,7 +715,7 @@ namespace manapi::ev {
715715
uv_prepare_t s_;
716716
};
717717

718-
class timer {
718+
class DLLExportImport timer {
719719
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(timer, uv_timer_t)
720720
public:
721721
MANAPIHTTP_EV_DEFAULT(timer, uv_timer_t)
@@ -741,7 +741,7 @@ namespace manapi::ev {
741741
uv_timer_t s_;
742742
};
743743

744-
class fs {
744+
class DLLExportImport fs {
745745
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(fs, uv_fs_t)
746746
public:
747747
MANAPIHTTP_EV_DEFAULT(fs, uv_fs_t)
@@ -906,7 +906,7 @@ namespace manapi::ev {
906906
uv_fs_t s_;
907907
};
908908

909-
class random {
909+
class DLLExportImport random {
910910
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(random, uv_random_t)
911911
public:
912912
MANAPIHTTP_EV_DEFAULT(random, uv_random_t)
@@ -922,7 +922,7 @@ namespace manapi::ev {
922922
uv_random_t s_;
923923
};
924924

925-
class getaddrinfo {
925+
class DLLExportImport getaddrinfo {
926926
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(getaddrinfo, uv_getaddrinfo_t)
927927
public:
928928
MANAPIHTTP_EV_DEFAULT(getaddrinfo, uv_getaddrinfo_t)
@@ -940,7 +940,7 @@ namespace manapi::ev {
940940
uv_getaddrinfo_t s_;
941941
};
942942

943-
class getnameinfo {
943+
class DLLExportImport getnameinfo {
944944
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(getnameinfo, uv_getnameinfo_t)
945945
public:
946946
MANAPIHTTP_EV_DEFAULT(getnameinfo, uv_getnameinfo_t)
@@ -956,7 +956,7 @@ namespace manapi::ev {
956956
uv_getnameinfo_t s_;
957957
};
958958

959-
class work {
959+
class DLLExportImport work {
960960
MANAPIHTTP_EV_DEFAULT_PRIVATE_VAR(work, uv_work_t)
961961
public:
962962
MANAPIHTTP_EV_DEFAULT(work, uv_work_t)
@@ -997,7 +997,7 @@ namespace manapi::sys_error {
997997
/**
998998
* error status for the OS event
999999
*/
1000-
class status final : public manapi::error::status {
1000+
class DLLExportImport status final : public manapi::error::status {
10011001
public:
10021002
/**
10031003
* initialize error status

include/ManapiFetch.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace manapi::net {
2121
* A Fetch FormData interface to work with the Fetch and Fetch2 API.
2222
* Based on the curl formdata
2323
*/
24-
class fetch_formdata {
24+
class DLLExportImport fetch_formdata {
2525
public:
2626
struct multipart_param_value_file {
2727
std::move_only_function<size_t (void *buff, size_t size)> callback;
@@ -110,7 +110,7 @@ namespace manapi::net {
110110
/**
111111
* Fetch API for C++. Based on cURL
112112
*/
113-
class fetch {
113+
class DLLExportImport fetch {
114114
public:
115115
struct data_t;
116116

0 commit comments

Comments
 (0)