xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package("libuuid")
  2. set_homepage("https://sourceforge.net/projects/libuuid")
  3. set_description("Portable uuid C library")
  4. set_license("BSD-3-Clause")
  5. set_urls("https://sourceforge.net/projects/libuuid/files/libuuid-$(version).tar.gz",
  6. "https://github.com/xmake-mirror/libuuid/releases/download/$(version)/libuuid-$(version).tar.gz",
  7. "https://git.code.sf.net/p/libuuid/code.git")
  8. add_versions("1.0.3", "46af3275291091009ad7f1b899de3d0cea0252737550e7919d17237997db5644")
  9. on_install("linux", "macosx", "bsd", "android", "iphoneos", "wasm", "cross", function(package)
  10. io.writefile("xmake.lua", [[
  11. includes("check_cfuncs.lua")
  12. add_rules("mode.debug", "mode.release")
  13. target("uuid")
  14. set_kind("$(kind)")
  15. add_files("*.c|test_*.c")
  16. add_headerfiles("*.h", {prefixdir = "uuid"})
  17. add_rules("utils.install.pkgconfig_importfiles", {filename = "uuid.pc"})
  18. check_cfuncs("HAVE_USLEEP", "usleep", {includes = "unistd.h"})
  19. check_cfuncs("HAVE_FTRUNCATE", "ftruncate", {includes = "unistd.h"})
  20. check_cfuncs("HAVE_GETTIMEOFDAY", "gettimeofday", {includes = "sys/time.h"})
  21. check_cfuncs("HAVE_MEMSET", "memset", {includes = "string.h"})
  22. check_cfuncs("HAVE_SOCKET", "socket", {includes = "sys/socket.h"})
  23. check_cfuncs("HAVE_STRTOUL", "strtoul", {includes = "stdlib.h"})
  24. check_cfuncs("HAVE_SRANDOM", "srandom", {includes = "stdlib.h"})
  25. ]])
  26. local configs = {}
  27. if package:config("shared") then
  28. configs.kind = "shared"
  29. end
  30. import("package.tools.xmake").install(package, configs)
  31. end)
  32. on_test(function(package)
  33. assert(package:check_csnippets({
  34. test = [[
  35. void test() {
  36. uuid_t buf;
  37. char str[100];
  38. uuid_generate(buf);
  39. uuid_unparse(buf, str);
  40. }
  41. ]]
  42. }, {configs = {languages = "c11"}, includes = "uuid/uuid.h"}))
  43. end)