Skip to content

Commit

Permalink
Update xmake.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing authored Jan 27, 2025
1 parent f732529 commit fce1ff2
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions packages/s/stc/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package("stc")
set_kind("library", {headeronly = true})
set_homepage("https://github.com/stclib/STC")
set_description("A modern, user friendly, generic, type-safe and fast C99 container library: String, Vector, Sorted and Unordered Map and Set, Deque, Forward List, Smart Pointers, Bitset and Random numbers.")
set_license("MIT")
Expand All @@ -10,11 +9,42 @@ package("stc")
add_versions("v5.0", "d61353852b9d7ef69b56fa32edcbc7934f2153385f3778536234201ceebcc950")
add_versions("v4.2", "f16c3185ba5693f0257e5b521f0b6b3c11041433a4abbbbc531370364eb75d0c")

add_configs("checkscoped", {description = "Build checkscoped tool for c_guard* blocks", default = false, type = "boolean"})
if is_plat("windows") then
add_configs("shared", {description = "Download shared binaries.", default = false, type = "boolean", readonly = true})
end

on_load(function (package)
if package:version() and package:version():ge("5.0.0") then
package:add("deps", "meson", "ninja")
if package:config("checkscoped") then
package:add("deps", "flex", {kind = "binary"})
end
else
package:set("kind", "library", {headeronly = true})
end
end)

on_install(function (package)
os.cp("include", package:installdir())
if package:version() and package:version():ge("5.0.0") then
local configs = {"-Dtests=disabled", "-Dexamples=disabled"}
table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
table.insert(configs, "-Dcheckscoped=" .. (package:config("checkscoped") and "enabled" or "disabled"))
import("package.tools.meson").install(package, configs)
else
os.cp("include", package:installdir())
end
end)

on_test(function (package)
local defines = {"i_type=Floats", "i_val=float"}
assert(package:has_cfuncs("Floats_push", {includes = "stc/cvec.h", configs = {defines = defines}}))
local opt = {}
opt.configs = {
defines = {"i_type=Floats", "i_val=float"}
}
if package:version() and package:version():ge("5.0.0") then
opt.includes = "stc/vec.h"
else
opt.includes = "stc/cvec.h"
end
assert(package:has_cfuncs("Floats_push", opt))
end)

0 comments on commit fce1ff2

Please sign in to comment.