|
| 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