Skip to content

Commit a5e98db

Browse files
telebot: add package (#4220)
* telebot: add package * pthreads4w: limit plat * telebot: fix unistd * limit plat * improve mingw
1 parent 0eae31c commit a5e98db

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

packages/p/pthreads4w/xmake.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package("pthreads4w")
1515
add_deps("autoconf", "automake")
1616
end
1717

18-
on_install("windows", function (package)
18+
on_install("windows|x64", "windows|x86", function (package)
1919
local target = "VC"
2020
if not package:config("shared") then
2121
target = target .. "-static"

packages/t/telebot/xmake.lua

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package("telebot")
2+
set_homepage("https://elmurod.net/telebot")
3+
set_description("Telegram Bot API in C")
4+
set_license("Apache-2.0")
5+
6+
add_urls("https://github.com/smartnode/telebot.git")
7+
add_versions("2024.05.11", "63693b4f9bcdc3fd0b0f2b37104b6694d723b5b4")
8+
9+
if is_plat("linux") then
10+
add_syslinks("pthread")
11+
end
12+
13+
add_deps("json-c", "libcurl")
14+
if is_plat("windows", "mingw@macosx,linux") then
15+
add_deps("pthreads4w")
16+
end
17+
18+
on_install("windows|x64", "windows|x86", "mingw@macosx,linux", "linux", function (package)
19+
if package:is_plat("windows") then
20+
io.replace("src/telebot.c", "#include <unistd.h>", "", {plain = true})
21+
io.replace("src/telebot-core.c", "#include <unistd.h>", "", {plain = true})
22+
end
23+
24+
io.replace("src/telebot.c", "#include <json.h>", "#include <json-c/json.h>", {plain = true})
25+
io.replace("src/telebot-core.c", "#include <json.h>", "#include <json-c/json.h>", {plain = true})
26+
io.replace("src/telebot-parser.c", "#include <json.h>", "#include <json-c/json.h>", {plain = true})
27+
28+
io.replace("src/telebot.c", "#include <json_object.h>", "#include <json-c/json_object.h>", {plain = true})
29+
io.replace("src/telebot-parser.c", "#include <json_object.h>", "#include <json-c/json_object.h>", {plain = true})
30+
31+
io.writefile("xmake.lua", [[
32+
add_rules("mode.debug", "mode.release")
33+
set_encodings("utf-8")
34+
if is_plat("windows", "mingw@macosx,linux") then
35+
add_requires("pthreads4w")
36+
add_packages("pthreads4w")
37+
end
38+
add_requires("json-c", "libcurl")
39+
add_packages("json-c", "libcurl")
40+
target("telebot")
41+
set_kind("$(kind)")
42+
add_files("src/*.c")
43+
add_headerfiles("include/*.h")
44+
add_includedirs("include")
45+
if is_plat("windows") and is_kind("shared") then
46+
add_rules("utils.symbols.export_all")
47+
end
48+
]])
49+
import("package.tools.xmake").install(package)
50+
end)
51+
52+
on_test(function (package)
53+
assert(package:has_cfuncs("telebot_create", {includes = "telebot.h"}))
54+
end)

0 commit comments

Comments
 (0)