xmake.lua 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package("inih")
  2. set_homepage("https://github.com/benhoyt/inih")
  3. set_description("Simple .INI file parser in C, good for embedded systems")
  4. add_urls("https://github.com/benhoyt/inih/archive/refs/tags/$(version).tar.gz", {version = function (version) return "r" .. version end})
  5. add_urls("https://github.com/benhoyt/inih.git")
  6. add_versions("58", "e79216260d5dffe809bda840be48ab0eec7737b2bb9f02d2275c1b46344ea7b7")
  7. add_versions("59", "062279922805f5e9a369551a08d5ddb506140fe50774183ffdbb7c22bb97e3f4")
  8. add_versions("60", "706aa05c888b53bd170e5d8aa8f8a9d9ccf5449dfed262d5103d1f292af26774")
  9. add_configs("ini_parser", {description = "compile and (if selected) install INIReader", default = true, type = "boolean"})
  10. add_configs("multi_line_entries", {description = "support for multi-line entries in the style of Python's ConfigParser", default = true, type = "boolean"})
  11. add_configs("utf_8_bom", {description = "allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of INI files", default = true, type = "boolean"})
  12. add_configs("inline_comments", {description = "allow inline comments with the comment prefix character", default = true, type = "boolean"})
  13. add_configs("inline_comment_prefix", {description = "allow inline comments with the comment prefix character", default = ";", type = "string"})
  14. add_configs("start_of_line_comment_prefix", {description = "character(s) to start a comment at the beginning of a line", default = ";#", type = "string"})
  15. add_configs("allow_no_value", {description = "allow name with no value", default = false, type = "boolean"})
  16. add_configs("stop_on_first_error", {description = "stop parsing after an error", default = false, type = "boolean"})
  17. add_configs("report_line_numbers", {description = "report line number on ini_handler callback", default = false, type = "boolean"})
  18. add_configs("call_handler_on_new_section", {description = "call the handler each time a new section is encountered", default = false, type = "boolean"})
  19. add_configs("heap", {description = "allocate memory on the heap using malloc instead using a fixed-sized line buffer on the stack", default = false, type = "boolean"})
  20. add_configs("max_line_length", {description = "maximum line length in bytes", default = "200", type = "string"})
  21. add_configs("initial_malloc_size", {description = "initial malloc size in bytes (when using the heap)", default = "200", type = "string"})
  22. add_configs("allow_realloc", {description = "allow initial malloc size to grow to max line length (when using the heap)", default = false, type = "boolean"})
  23. on_install(function (package)
  24. os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), "xmake.lua")
  25. local configs = {}
  26. for name, config_value in table.orderpairs(package:configs()) do
  27. if not package:extraconf("configs", name, "builtin") then
  28. configs[name] = config_value
  29. end
  30. end
  31. import("package.tools.xmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:check_cxxsnippets({test = [[
  35. #include "ini.h"
  36. typedef struct { } configuration;
  37. static int handler(void* user, const char* section, const char* name, const char* value) { return 1; }
  38. int test(int argc, char* argv[])
  39. {
  40. configuration config;
  41. if (ini_parse("test.ini", handler, &config) < 0) {
  42. return 1;
  43. }
  44. return 0;
  45. }
  46. ]]}, {configs = {languages = "cxx11"}}))
  47. if package:config("ini_parser") then
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <iostream>
  50. #include "INIReader.h"
  51. int test()
  52. {
  53. INIReader reader("test.ini");
  54. return 0;
  55. }
  56. ]]}, {configs = {languages = "cxx11"}}))
  57. end
  58. end)