xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("apr")
  2. set_homepage("https://github.com/apache/apr")
  3. set_description("Mirror of Apache Portable Runtime")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/apache/apr/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/apache/apr.git")
  7. add_versions("1.7.4", "060b6e5ca8b3251545a93777c9ef744ceff02d4a59bb60a7dd9b3da9da33673e")
  8. add_versions("1.7.0", "a7e2c5e6d60f6c7b1611b31a2f914a3e58f44eded5b064f0bae43ff30b16a4e6")
  9. if is_plat("linux") then
  10. add_deps("libtool", "python")
  11. add_patches("1.7.0", path.join(os.scriptdir(), "patches", "1.7.0", "common.patch"), "bbfef69c914ca1ab98a9d94fc4794958334ce5f47d8c08c05e0965a48a44c50d")
  12. elseif is_plat("windows") then
  13. add_deps("cmake")
  14. add_syslinks("wsock32", "ws2_32", "advapi32", "shell32", "rpcrt4")
  15. end
  16. on_install("linux", "macosx|x86_64", function (package)
  17. local configs = {}
  18. if package:is_plat("linux") then
  19. os.vrunv("sh", {"./buildconf"})
  20. io.replace("configure", "RM='$RM'", "RM='$RM -f'")
  21. else
  22. io.replace("configure.in", "pid_t_fmt='#error Can not determine the proper size for pid_t'", "pid_t_fmt='#define APR_PID_T_FMT \"d\"'")
  23. os.vrunv("sh", {"./buildconf"})
  24. table.insert(configs, "CFLAGS=-DAPR_IOVEC_DEFINED")
  25. end
  26. import("package.tools.autoconf").install(package, configs)
  27. if package:config("shared") then
  28. os.rm(package:installdir("lib/*.a"))
  29. else
  30. os.tryrm(package:installdir("lib/*.so*"))
  31. os.tryrm(package:installdir("lib/*.dylib"))
  32. end
  33. package:add("links", "apr-1")
  34. package:add("includedirs", "include/apr-1")
  35. end)
  36. on_install("windows|x86", "windows|x64", function (package)
  37. local configs = {}
  38. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  39. table.insert(configs, "-DAPR_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  40. table.insert(configs, "-DAPR_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  41. import("package.tools.cmake").install(package, configs)
  42. -- libapr-1 is shared, apr-1 is static
  43. if package:config("shared") then
  44. package:add("defines", "APR_DECLARE_EXPORT")
  45. os.rm(package:installdir("lib/apr-1.lib"))
  46. os.rm(package:installdir("lib/aprapp-1.lib"))
  47. else
  48. package:add("defines", "APR_DECLARE_STATIC")
  49. os.rm(package:installdir("lib/lib*.lib"))
  50. os.rm(package:installdir("bin/lib*.dll"))
  51. end
  52. end)
  53. on_test(function (package)
  54. assert(package:has_cfuncs("apr_initialize", {includes = "apr_general.h"}))
  55. end)