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

add package ipaddress #5506

Merged
merged 8 commits into from
Oct 16, 2024
Merged
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
51 changes: 51 additions & 0 deletions packages/v/vladimirshaleev-ipaddress/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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")

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("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")

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("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)
end)

on_test(function(package)
assert(package:check_cxxsnippets({test = [[
#include <iostream>
#include <ipaddress/ipaddress.hpp>
using namespace ipaddress;
void parse_ip_sample() {
constexpr auto ip = ipv6_address::parse("fec0::1ff:fe23:4567:890a%eth2");
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;
}
]]
}, {configs = {languages = "c++17"}}))
end)
Loading