From f2d949f0f0ed64e7ec7a2c71fbaa71e5d1c82617 Mon Sep 17 00:00:00 2001 From: Luffbee Date: Wed, 16 Oct 2024 00:41:32 +0800 Subject: [PATCH 1/8] add package ipaddress --- packages/i/ipaddress/xmake.lua | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 packages/i/ipaddress/xmake.lua diff --git a/packages/i/ipaddress/xmake.lua b/packages/i/ipaddress/xmake.lua new file mode 100644 index 00000000000..5027d70690e --- /dev/null +++ b/packages/i/ipaddress/xmake.lua @@ -0,0 +1,95 @@ +package("ipaddress", function() + set_homepage("https://vladimirshaleev.github.io/ipaddress/") + set_description("A library for working and manipulating IPv4/IPv6 addresses and networks") + set_license("MIT") + set_kind("library", { + headeronly = true + }) + + add_urls("https://github.com/VladimirShaleev/ipaddress/archive/refs/tags/$(version).tar.gz", + "https://github.com/VladimirShaleev/ipaddress.git") + + add_versions("v1.1.0", "e5084d83ebd712210882eb6dac14ed1b9b71584dede523b35c6181e0a06375f1") + + add_configs("noexcept", { + description = "Disable handling cpp exception for", + default = false, + type = "boolean" + }) + add_configs("no_overload_std", { + description = "Do not overload std functions such as to_string, hash etc", + default = false, + type = "boolean" + }) + add_configs("no_ipv6_scope", { + description = "Disable scope id for IPv6 addresses", + default = false, + type = "boolean" + }) + add_configs("ipv6_scope_max_length", { + description = "Maximum scope-id length for IPv6 addresses", + default = 16, + type = "number" + }) + + add_deps("cmake") + + on_install(function(package) + local configs = {"-DBUILD_TESTING=OFF", "-DIPADDRESS_ENABLE_CLANG_TIDY=OFF", "-DIPADDRESS_BUILD_TESTS=OFF", + "-DIPADDRESS_BUILD_BENCHMARK=OFF", "-DIPADDRESS_BUILD_DOC=OFF", + "-DIPADDRESS_BUILD_PACKAGES=OFF"} + + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + + table.insert(configs, "-DIPADDRESS_NO_EXCEPTIONS=" .. (package:config("noexcept") and "ON" or "OFF")) + table.insert(configs, "-DIPADDRESS_NO_OVERLOAD_STD=" .. (package:config("no_overload_std") and "ON" or "OFF")) + table.insert(configs, "-DIPADDRESS_NO_IPV6_SCOPE=" .. (package:config("no_ipv6_scope") and "ON" or "OFF")) + table.insert(configs, "-DIPADDRESS_IPV6_SCOPE_MAX_LENGTH=" .. package:config("ipv6_scope_max_length")) + + import("package.tools.cmake").install(package, configs) + end) + + on_test(function(package) + assert(package:check_cxxsnippets({ + test = [[ + #include + + #include + + using namespace ipaddress; + + void parse_ip_sample() { + constexpr auto ip = ipv6_address::parse("fec0::1ff:fe23:4567:890a%eth2"); + constexpr auto is_site_local = ip.is_site_local(); + + std::cout << "ip " << ip << " is local: " << std::boolalpha << is_site_local << std::endl; + std::cout << "DNS PTR " << ip.reverse_pointer() << std::endl << std::endl; + } + + void teredo_sample() { + constexpr auto teredo_ip = "2001:0000:4136:e378:8000:63bf:3fff:fdd2"_ipv6; + auto [server, client] = teredo_ip.teredo().value(); + + std::cout << "server: " << server << " and client: " << client << " for " << teredo_ip << std::endl << std::endl; + } + + void subnets_sample() { + constexpr auto net = ipv4_network::parse("192.0.2.0/24"); + + std::cout << "subnets for " << net << ':' << std::endl; + for (const auto& subnet : net.subnets(2)) { + std::cout << " " << subnet << std::endl; + } + + constexpr auto last_subnet = net.subnets(2).back(); + std::cout << "last subnet " << last_subnet << std::endl; + } + ]] + }, { + configs = { + languages = "c++17" + } + })) + end) +end) From 58707012c5cd33e355fe54b83e7630a58df9ba5b Mon Sep 17 00:00:00 2001 From: Luffbee Date: Wed, 16 Oct 2024 10:38:52 +0800 Subject: [PATCH 2/8] rename ipaddress to vladimirshaleev-ipaddress --- packages/{i/ipaddress => v/vladimirshaleev-ipaddress}/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename packages/{i/ipaddress => v/vladimirshaleev-ipaddress}/xmake.lua (98%) diff --git a/packages/i/ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua similarity index 98% rename from packages/i/ipaddress/xmake.lua rename to packages/v/vladimirshaleev-ipaddress/xmake.lua index 5027d70690e..34f96ea801a 100644 --- a/packages/i/ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -1,4 +1,4 @@ -package("ipaddress", function() +package("vladimirshaleev-ipaddress", function() set_homepage("https://vladimirshaleev.github.io/ipaddress/") set_description("A library for working and manipulating IPv4/IPv6 addresses and networks") set_license("MIT") From 39428da40c3a3eacdefe40f9a3be7189c4cd9029 Mon Sep 17 00:00:00 2001 From: Luffbee Date: Wed, 16 Oct 2024 10:52:35 +0800 Subject: [PATCH 3/8] format & simplify test --- .../v/vladimirshaleev-ipaddress/xmake.lua | 51 +++---------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/packages/v/vladimirshaleev-ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua index 34f96ea801a..4b8fd061472 100644 --- a/packages/v/vladimirshaleev-ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -1,36 +1,18 @@ -package("vladimirshaleev-ipaddress", function() +package("vladimirshaleev-ipaddress") set_homepage("https://vladimirshaleev.github.io/ipaddress/") set_description("A library for working and manipulating IPv4/IPv6 addresses and networks") set_license("MIT") - set_kind("library", { - headeronly = true - }) + set_kind("library", {headeronly = true}) add_urls("https://github.com/VladimirShaleev/ipaddress/archive/refs/tags/$(version).tar.gz", "https://github.com/VladimirShaleev/ipaddress.git") add_versions("v1.1.0", "e5084d83ebd712210882eb6dac14ed1b9b71584dede523b35c6181e0a06375f1") - add_configs("noexcept", { - description = "Disable handling cpp exception for", - default = false, - type = "boolean" - }) - add_configs("no_overload_std", { - description = "Do not overload std functions such as to_string, hash etc", - default = false, - type = "boolean" - }) - add_configs("no_ipv6_scope", { - description = "Disable scope id for IPv6 addresses", - default = false, - type = "boolean" - }) - add_configs("ipv6_scope_max_length", { - description = "Maximum scope-id length for IPv6 addresses", - default = 16, - type = "number" - }) + add_configs("noexcept", {description = "Disable handling cpp exception for", default = false, type = "boolean"}) + add_configs("no_overload_std", {description = "Do not overload std functions such as to_string, hash etc", default = false, type = "boolean"}) + add_configs("no_ipv6_scope", {description = "Disable scope id for IPv6 addresses", default = false, type = "boolean"}) + add_configs("ipv6_scope_max_length", {description = "Maximum scope-id length for IPv6 addresses", default = 16, type = "number"}) add_deps("cmake") @@ -54,37 +36,17 @@ package("vladimirshaleev-ipaddress", function() assert(package:check_cxxsnippets({ test = [[ #include - #include - using namespace ipaddress; - void parse_ip_sample() { constexpr auto ip = ipv6_address::parse("fec0::1ff:fe23:4567:890a%eth2"); - constexpr auto is_site_local = ip.is_site_local(); - - std::cout << "ip " << ip << " is local: " << std::boolalpha << is_site_local << std::endl; std::cout << "DNS PTR " << ip.reverse_pointer() << std::endl << std::endl; } - void teredo_sample() { constexpr auto teredo_ip = "2001:0000:4136:e378:8000:63bf:3fff:fdd2"_ipv6; auto [server, client] = teredo_ip.teredo().value(); - std::cout << "server: " << server << " and client: " << client << " for " << teredo_ip << std::endl << std::endl; } - - void subnets_sample() { - constexpr auto net = ipv4_network::parse("192.0.2.0/24"); - - std::cout << "subnets for " << net << ':' << std::endl; - for (const auto& subnet : net.subnets(2)) { - std::cout << " " << subnet << std::endl; - } - - constexpr auto last_subnet = net.subnets(2).back(); - std::cout << "last subnet " << last_subnet << std::endl; - } ]] }, { configs = { @@ -92,4 +54,3 @@ package("vladimirshaleev-ipaddress", function() } })) end) -end) From 342fa639faf0f6352753eddf2c0573cbe8572564 Mon Sep 17 00:00:00 2001 From: Luffbee Date: Wed, 16 Oct 2024 11:38:20 +0800 Subject: [PATCH 4/8] fix format --- packages/v/vladimirshaleev-ipaddress/xmake.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/v/vladimirshaleev-ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua index 4b8fd061472..b3fbcdf2703 100644 --- a/packages/v/vladimirshaleev-ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -1,8 +1,8 @@ package("vladimirshaleev-ipaddress") + set_kind("library", {headeronly = true}) set_homepage("https://vladimirshaleev.github.io/ipaddress/") set_description("A library for working and manipulating IPv4/IPv6 addresses and networks") set_license("MIT") - set_kind("library", {headeronly = true}) add_urls("https://github.com/VladimirShaleev/ipaddress/archive/refs/tags/$(version).tar.gz", "https://github.com/VladimirShaleev/ipaddress.git") @@ -48,9 +48,5 @@ package("vladimirshaleev-ipaddress") std::cout << "server: " << server << " and client: " << client << " for " << teredo_ip << std::endl << std::endl; } ]] - }, { - configs = { - languages = "c++17" - } - })) + }, {configs = {languages = "c++17"}})) end) From 03415251d42c52f155fa207d1585e04fd6e98380 Mon Sep 17 00:00:00 2001 From: Luffbee Date: Wed, 16 Oct 2024 11:43:32 +0800 Subject: [PATCH 5/8] rename configs --- packages/v/vladimirshaleev-ipaddress/xmake.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/v/vladimirshaleev-ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua index b3fbcdf2703..e0144cd20bd 100644 --- a/packages/v/vladimirshaleev-ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -9,9 +9,9 @@ package("vladimirshaleev-ipaddress") add_versions("v1.1.0", "e5084d83ebd712210882eb6dac14ed1b9b71584dede523b35c6181e0a06375f1") - add_configs("noexcept", {description = "Disable handling cpp exception for", default = false, type = "boolean"}) - add_configs("no_overload_std", {description = "Do not overload std functions such as to_string, hash etc", default = false, type = "boolean"}) - add_configs("no_ipv6_scope", {description = "Disable scope id for IPv6 addresses", default = false, type = "boolean"}) + add_configs("exceptions", {description = "Disable handling cpp exception for", default = true, type = "boolean"}) + add_configs("overload_std", {description = "Do not overload std functions such as to_string, hash etc", default = true, type = "boolean"}) + add_configs("ipv6_scope", {description = "Disable scope id for IPv6 addresses", default = true, type = "boolean"}) add_configs("ipv6_scope_max_length", {description = "Maximum scope-id length for IPv6 addresses", default = 16, type = "number"}) add_deps("cmake") @@ -24,9 +24,9 @@ package("vladimirshaleev-ipaddress") table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) - table.insert(configs, "-DIPADDRESS_NO_EXCEPTIONS=" .. (package:config("noexcept") and "ON" or "OFF")) - table.insert(configs, "-DIPADDRESS_NO_OVERLOAD_STD=" .. (package:config("no_overload_std") and "ON" or "OFF")) - table.insert(configs, "-DIPADDRESS_NO_IPV6_SCOPE=" .. (package:config("no_ipv6_scope") and "ON" or "OFF")) + table.insert(configs, "-DIPADDRESS_NO_EXCEPTIONS=" .. (package:config("exceptions") and "OFF" or "ON")) + table.insert(configs, "-DIPADDRESS_NO_OVERLOAD_STD=" .. (package:config("overload_std") and "OFF" or "ON")) + table.insert(configs, "-DIPADDRESS_NO_IPV6_SCOPE=" .. (package:config("ipv6_scope") and "OFF" or "ON")) table.insert(configs, "-DIPADDRESS_IPV6_SCOPE_MAX_LENGTH=" .. package:config("ipv6_scope_max_length")) import("package.tools.cmake").install(package, configs) From 742bd1dcd3285dc9c12974dbddf267691073458f Mon Sep 17 00:00:00 2001 From: Luffbee Date: Wed, 16 Oct 2024 12:45:05 +0800 Subject: [PATCH 6/8] fix configs desc --- packages/v/vladimirshaleev-ipaddress/xmake.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/v/vladimirshaleev-ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua index e0144cd20bd..3375ef2ef4f 100644 --- a/packages/v/vladimirshaleev-ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -9,9 +9,9 @@ package("vladimirshaleev-ipaddress") add_versions("v1.1.0", "e5084d83ebd712210882eb6dac14ed1b9b71584dede523b35c6181e0a06375f1") - add_configs("exceptions", {description = "Disable handling cpp exception for", default = true, type = "boolean"}) - add_configs("overload_std", {description = "Do not overload std functions such as to_string, hash etc", default = true, type = "boolean"}) - add_configs("ipv6_scope", {description = "Disable scope id for IPv6 addresses", default = true, type = "boolean"}) + add_configs("exceptions", {description = "Support handling cpp exception", default = true, type = "boolean"}) + add_configs("overload_std", {description = "Overload std functions such as to_string, hash etc", default = true, type = "boolean"}) + add_configs("ipv6_scope", {description = "Support scope id for IPv6 addresses", default = true, type = "boolean"}) add_configs("ipv6_scope_max_length", {description = "Maximum scope-id length for IPv6 addresses", default = 16, type = "number"}) add_deps("cmake") From d676573ca8a03ce3ca4b3a7c66a9005d1ecf22f6 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 16 Oct 2024 13:53:25 +0800 Subject: [PATCH 7/8] Update xmake.lua --- packages/v/vladimirshaleev-ipaddress/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/v/vladimirshaleev-ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua index 3375ef2ef4f..9cf9981538d 100644 --- a/packages/v/vladimirshaleev-ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -5,7 +5,7 @@ package("vladimirshaleev-ipaddress") set_license("MIT") add_urls("https://github.com/VladimirShaleev/ipaddress/archive/refs/tags/$(version).tar.gz", - "https://github.com/VladimirShaleev/ipaddress.git") + "https://github.com/VladimirShaleev/ipaddress.git") add_versions("v1.1.0", "e5084d83ebd712210882eb6dac14ed1b9b71584dede523b35c6181e0a06375f1") From 6683df0c1ff918200fa7eb00571eaea01a08d75b Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 16 Oct 2024 16:39:52 +0800 Subject: [PATCH 8/8] Update xmake.lua --- packages/v/vladimirshaleev-ipaddress/xmake.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/v/vladimirshaleev-ipaddress/xmake.lua b/packages/v/vladimirshaleev-ipaddress/xmake.lua index 9cf9981538d..f8900e52750 100644 --- a/packages/v/vladimirshaleev-ipaddress/xmake.lua +++ b/packages/v/vladimirshaleev-ipaddress/xmake.lua @@ -33,8 +33,7 @@ package("vladimirshaleev-ipaddress") end) on_test(function(package) - assert(package:check_cxxsnippets({ - test = [[ + assert(package:check_cxxsnippets({test = [[ #include #include using namespace ipaddress;