xmake.lua 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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("!windows and !mingw", function(package)
  10. io.writefile("xmake.lua", [[
  11. includes("@builtin/check")
  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_cincludes("HAVE_DLFCN_H", "dlfcn.h")
  19. check_cincludes("HAVE_FCNTL_H", "fcntl.h")
  20. check_cincludes("HAVE_INTTYPES_H", "inttypes.h")
  21. check_cincludes("HAVE_LIMITS_H", "limits.h")
  22. check_cincludes("HAVE_MEMORY_H", "memory.h")
  23. check_cincludes("HAVE_NETINET_IN_H", "netinet/in.h")
  24. check_cincludes("HAVE_STDINT_H", "stdint.h")
  25. check_cincludes("HAVE_STDLIB_H", "stdlib.h")
  26. check_cincludes("HAVE_STRING_H", "string.h")
  27. check_cincludes("HAVE_STRINGS_H", "strings.h")
  28. check_cincludes("HAVE_SYS_FILE_H", "sys/file.h")
  29. check_cincludes("HAVE_SYS_IOCTL_H", "sys/ioctl.h")
  30. check_cincludes("HAVE_SYS_SOCKET_H", "sys/socket.h")
  31. check_cincludes("HAVE_SYS_STAT_H", "sys/stat.h")
  32. check_cincludes("HAVE_SYS_TIME_H", "sys/time.h")
  33. check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h")
  34. check_cfuncs("HAVE_FTRUNCATE", "ftruncate", {includes = "unistd.h"})
  35. check_cfuncs("HAVE_GETTIMEOFDAY", "gettimeofday", {includes = "sys/time.h"})
  36. check_cfuncs("HAVE_MEMSET", "memset", {includes = "string.h"})
  37. check_cfuncs("HAVE_SOCKET", "socket", {includes = "sys/socket.h"})
  38. check_cfuncs("HAVE_SRANDOM", "srandom", {includes = "stdlib.h"})
  39. check_cfuncs("HAVE_STRTOUL", "strtoul", {includes = "stdlib.h"})
  40. check_cfuncs("HAVE_USLEEP", "usleep", {includes = "unistd.h"})
  41. ]])
  42. import("package.tools.xmake").install(package)
  43. end)
  44. on_test(function(package)
  45. assert(package:check_csnippets({
  46. test = [[
  47. void test() {
  48. uuid_t buf;
  49. char str[100];
  50. uuid_generate(buf);
  51. uuid_unparse(buf, str);
  52. }
  53. ]]
  54. }, {configs = {languages = "c11"}, includes = "uuid/uuid.h"}))
  55. end)