Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Support producing shared libraries on Windows #2204

Merged
merged 2 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ project(toxcore)

list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)

option(FLAT_OUTPUT_STRUCTURE "Whether to produce output artifacts in ${CMAKE_BINARY_DIR}/{bin,lib}" OFF)
if(FLAT_OUTPUT_STRUCTURE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()

set_source_files_properties(
toxcore/mono_time.c
toxcore/network.c
Expand Down
24 changes: 17 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ image: Visual Studio 2019
cache:
- '%USERPROFILE%\.conan -> conanfile.py'

environment:
matrix:
- job_name: static
- job_name: shared

install:
- set PATH=C:\Python310-x64\Scripts;%PATH%
- py -3 -m pip install conan

before_build:
- git submodule update --init --recursive
- conan install -if _build .

build_script:
- conan build -bf _build -if _build .
for:
- matrix:
only:
- job_name: static
before_build:
- conan install -if _build -o with_tests=True .
- matrix:
only:
- job_name: shared
before_build:
- conan install -if _build -o with_tests=True -o shared=True .

test_script:
build_script:
- set CONAN_CPU_COUNT=50
- set CTEST_OUTPUT_ON_FAILURE=1
- conan install -if _build -o with_tests=True .
- conan build -bf _build -if _build .
8 changes: 4 additions & 4 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ static IP get_loopback(void)
{
IP ip;
#if USE_IPV6
ip.family = net_family_ipv6;
ip.family = net_family_ipv6();
ip.ip.v6 = get_ip6_loopback();
#else
ip.family = net_family_ipv4;
ip.family = net_family_ipv4();
ip.ip.v4 = get_ip4_loopback();
#endif
return ip;
Expand Down Expand Up @@ -68,7 +68,7 @@ static void test_basic(void)

// Check all opened ports for connectivity.
for (uint8_t i = 0; i < NUM_PORTS; i++) {
sock = net_socket(ns, net_family_ipv6, TOX_SOCK_STREAM, TOX_PROTO_TCP);
sock = net_socket(ns, net_family_ipv6(), TOX_SOCK_STREAM, TOX_PROTO_TCP);
localhost.port = net_htons(ports[i]);
bool ret = net_connect(logger, sock, &localhost);
ck_assert_msg(ret, "Failed to connect to created TCP relay server on port %d (%d).", ports[i], errno);
Expand Down Expand Up @@ -201,7 +201,7 @@ static struct sec_TCP_con *new_TCP_con(const Logger *logger, const Random *rng,
struct sec_TCP_con *sec_c = (struct sec_TCP_con *)malloc(sizeof(struct sec_TCP_con));
ck_assert(sec_c != nullptr);
sec_c->ns = ns;
Socket sock = net_socket(ns, net_family_ipv6, TOX_SOCK_STREAM, TOX_PROTO_TCP);
Socket sock = net_socket(ns, net_family_ipv6(), TOX_SOCK_STREAM, TOX_PROTO_TCP);

IP_Port localhost;
localhost.ip = get_loopback();
Expand Down
7 changes: 6 additions & 1 deletion auto_tests/auto_test_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
#define ABORT_ON_LOG_ERROR true
#endif

const Run_Auto_Options default_run_auto_options = { GRAPH_COMPLETE, nullptr };
Run_Auto_Options default_run_auto_options() {
return (Run_Auto_Options) {
.graph = GRAPH_COMPLETE,
.init_autotox = nullptr,
};
}

// List of live bootstrap nodes. These nodes should have TCP server enabled.
static const struct BootstrapNodes {
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/auto_test_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct Run_Auto_Options {
void (*init_autotox)(AutoTox *autotox, uint32_t n);
} Run_Auto_Options;

extern const Run_Auto_Options default_run_auto_options;
Run_Auto_Options default_run_auto_options(void);

void run_auto_test(struct Tox_Options *options, uint32_t tox_count, void test(AutoTox *autotoxes),
uint32_t state_size, const Run_Auto_Options *autotest_opts);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, NUM_AV_GROUP_TOX, test_groupav, sizeof(State), &options);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_double_invite_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, 2, conference_double_invite_test, sizeof(State), &options);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_invite_merge_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, NUM_INVITE_MERGE_TOX, conference_invite_merge_test, sizeof(State), &options);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_peer_nick_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, 2, conference_peer_nick_test, sizeof(State), &options);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, NUM_GROUP_TOX, test_many_group, sizeof(State), &options);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/dht_getnodes_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, NUM_TOXES, test_dht_getnodes, sizeof(State), &options);
Expand Down
6 changes: 3 additions & 3 deletions auto_tests/forwarding_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ static inline IP get_loopback(void)
{
IP ip;
#if USE_IPV6
ip.family = net_family_ipv6;
ip.family = net_family_ipv6();
ip.ip.v6 = get_ip6_loopback();
#else
ip.family = net_family_ipv4;
ip.family = net_family_ipv4();
ip.ip.v4 = get_ip4_loopback();
#endif
return ip;
Expand Down Expand Up @@ -309,7 +309,7 @@ static void test_forwarding(void)
ck_assert(NUM_FORWARDER - NUM_FORWARDER_TCP > 1);

for (uint32_t i = NUM_FORWARDER_TCP; i < NUM_FORWARDER; ++i) {
ck_assert_msg(get_close_nodes(subtoxes[i]->dht, dht_get_self_public_key(subtoxes[i]->dht), nodes, net_family_unspec, true,
ck_assert_msg(get_close_nodes(subtoxes[i]->dht, dht_get_self_public_key(subtoxes[i]->dht), nodes, net_family_unspec(), true,
true) > 0,
"node %u has no nodes marked as announce nodes", i);
}
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/friend_connection_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, 2, friend_connection_test, 0, &options);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/friend_request_spam_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, FR_TOX_COUNT, test_friend_request, sizeof(State), &options);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/lossless_packet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, 2, test_lossless_packet, sizeof(State), &options);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/lossy_packet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;

run_auto_test(nullptr, 2, test_lossy_packet, sizeof(State), &options);
Expand Down
8 changes: 4 additions & 4 deletions auto_tests/network_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void test_addr_resolv_localhost(void)
#endif

ip_init(&ip, 1); // ipv6enabled = 1
ip.family = net_family_unspec;
ip.family = net_family_unspec();
IP extra;
ip_reset(&extra);
res = addr_resolve_or_parse_ip(ns, localhost, &ip, &extra);
Expand Down Expand Up @@ -115,14 +115,14 @@ static void test_ip_equal(void)
res = ip_equal(nullptr, &ip1);
ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %d.", res);

ip1.family = net_family_ipv4;
ip1.family = net_family_ipv4();
ip1.ip.v4.uint32 = net_htonl(0x7F000001);

res = ip_equal(&ip1, &ip2);
ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_UNSPEC, 0} ): "
"expected result 0, got %d.", res);

ip2.family = net_family_ipv4;
ip2.family = net_family_ipv4();
ip2.ip.v4.uint32 = net_htonl(0x7F000001);

res = ip_equal(&ip1, &ip2);
Expand All @@ -135,7 +135,7 @@ static void test_ip_equal(void)
ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.2} ): "
"expected result 0, got %d.", res);

ip2.family = net_family_ipv6;
ip2.family = net_family_ipv6();
ip2.ip.v6.uint32[0] = 0;
ip2.ip.v6.uint32[1] = 0;
ip2.ip.v6.uint32[2] = net_htonl(0xFFFF);
Expand Down
4 changes: 2 additions & 2 deletions auto_tests/onion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ static inline IP get_loopback(void)
{
IP ip;
#if USE_IPV6
ip.family = net_family_ipv6;
ip.family = net_family_ipv6();
ip.ip.v6 = get_ip6_loopback();
#else
ip.family = net_family_ipv4;
ip.family = net_family_ipv4();
ip.ip.v4 = get_ip4_loopback();
#endif
return ip;
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/overflow_recvq_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, 3, net_crypto_overflow_test, sizeof(State), &options);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/overflow_sendq_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, 2, net_crypto_overflow_test, 0, &options);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/reconnect_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, TOX_COUNT, test_reconnect, 0, &options);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/send_message_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(void)
struct Tox_Options *tox_options = tox_options_new(nullptr);
ck_assert(tox_options != nullptr);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
tox_options_set_ipv6_enabled(tox_options, true);
run_auto_test(tox_options, 2, send_message_test, sizeof(State), &options);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/typing_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

Run_Auto_Options options = default_run_auto_options;
Run_Auto_Options options = default_run_auto_options();
options.graph = GRAPH_LINEAR;
run_auto_test(nullptr, 2, test_typing, sizeof(State), &options);

Expand Down
19 changes: 15 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ class ToxConan(ConanFile):
generators = "cmake_find_package"
scm = {"type": "git", "url": "auto", "revision": "auto"}

options = {"with_tests": [True, False]}
default_options = {"with_tests": False}
options = {
"shared": [True, False],
"with_tests": [True, False],
}
default_options = {
"shared": False,
"with_tests": False,
}

_cmake = None

Expand All @@ -30,11 +36,16 @@ def _create_cmake(self):
self._cmake = CMake(self)
self._cmake.definitions["AUTOTEST"] = self.options.with_tests
self._cmake.definitions["BUILD_MISC_TESTS"] = self.options.with_tests
self._cmake.definitions["ENABLE_SHARED"] = False
self._cmake.definitions["ENABLE_STATIC"] = True

self._cmake.definitions[
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared
self._cmake.definitions["ENABLE_SHARED"] = self.options.shared
self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared
self._cmake.definitions["MUST_BUILD_TOXAV"] = True
if self.settings.compiler == "Visual Studio":
self._cmake.definitions["MSVC_STATIC_SODIUM"] = True
self._cmake.definitions[
"FLAT_OUTPUT_STRUCTURE"] = self.options.shared

self._cmake.configure()
return self._cmake
Expand Down
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ccc903803f118d6d069f65bb0a1ef95979ab8b374d207e8f13716771d6da9dd8 /usr/local/bin/tox-bootstrapd
cfa2c61f92df59419af678ef9d6fcd4f5609a505235d77a54c1a4ec66f1c10af /usr/local/bin/tox-bootstrapd
Loading