Skip to content

Commit 8c08cc8

Browse files
valijson: add package (#8279)
* valijson: add package * Update xmake.lua * Update xmake.lua --------- Co-authored-by: Saikari <lin@sz.cn.eu.org>
1 parent 8dac574 commit 8c08cc8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

packages/v/valijson/xmake.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package("valijson")
2+
set_kind("library", {headeronly = true})
3+
set_homepage("https://github.com/tristanpenman/valijson")
4+
set_description("Header-only C++ library for JSON Schema validation, with support for many popular parsers")
5+
set_license("BSD-2-Clause")
6+
7+
add_urls("https://github.com/tristanpenman/valijson/archive/refs/tags/$(version).tar.gz",
8+
"https://github.com/tristanpenman/valijson.git", {submodules = false})
9+
10+
add_versions("v1.0.6", "bf0839de19510ff7792d8a8aca94ea11a288775726b36c4c9a2662651870f8da")
11+
12+
add_configs("exceptions", {description = "Enable exception", default = true, type = "boolean"})
13+
14+
add_deps("cmake")
15+
16+
on_load(function (package)
17+
if package:config("exceptions") then
18+
package:add("defines", "VALIJSON_USE_EXCEPTIONS=1")
19+
end
20+
end)
21+
22+
on_install(function (package)
23+
io.replace("include/valijson/constraints/concrete_constraints.hpp", [[#include <cmath>]], [[#include <cmath>
24+
#include <cstdint>]], {plain = true})
25+
local configs = {"-Dvalijson_BUILD_EXAMPLES=OFF", "-Dvalijson_BUILD_TESTS=OFF"}
26+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
27+
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
28+
import("package.tools.cmake").install(package, configs)
29+
end)
30+
31+
on_test(function (package)
32+
assert(package:check_cxxsnippets({test = [[
33+
#include <valijson/schema.hpp>
34+
#include <valijson/schema_parser.hpp>
35+
void test() {
36+
valijson::Schema mySchema;
37+
valijson::SchemaParser parser;
38+
}
39+
]]}, {configs = {languages = "c++14"}}))
40+
end)

0 commit comments

Comments
 (0)