xmake.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.5", "6d0712c529503cd2457011d03164491bbc16d0050bc40ef89568b1ac491c6600")
  8. add_versions("1.7.4", "060b6e5ca8b3251545a93777c9ef744ceff02d4a59bb60a7dd9b3da9da33673e")
  9. add_versions("1.7.0", "a7e2c5e6d60f6c7b1611b31a2f914a3e58f44eded5b064f0bae43ff30b16a4e6")
  10. if is_plat("linux") then
  11. add_deps("libtool", "python")
  12. add_patches("1.7.0", path.join(os.scriptdir(), "patches", "1.7.0", "common.patch"), "bbfef69c914ca1ab98a9d94fc4794958334ce5f47d8c08c05e0965a48a44c50d")
  13. elseif is_plat("windows") then
  14. add_deps("cmake")
  15. add_syslinks("wsock32", "ws2_32", "advapi32", "shell32", "rpcrt4")
  16. end
  17. on_install("linux", "macosx|x86_64", function (package)
  18. local configs = {}
  19. if package:is_plat("linux") then
  20. os.vrunv("sh", {"./buildconf"})
  21. io.replace("configure", "RM='$RM'", "RM='$RM -f'")
  22. else
  23. 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\"'")
  24. os.vrunv("sh", {"./buildconf"})
  25. table.insert(configs, "CFLAGS=-DAPR_IOVEC_DEFINED")
  26. end
  27. import("package.tools.autoconf").install(package, configs)
  28. if package:config("shared") then
  29. os.rm(package:installdir("lib/*.a"))
  30. else
  31. os.tryrm(package:installdir("lib/*.so*"))
  32. os.tryrm(package:installdir("lib/*.dylib"))
  33. end
  34. package:add("links", "apr-1")
  35. package:add("includedirs", "include/apr-1")
  36. end)
  37. on_install("windows|x86", "windows|x64", function (package)
  38. local configs = {}
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DAPR_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  41. table.insert(configs, "-DAPR_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  42. import("package.tools.cmake").install(package, configs)
  43. -- libapr-1 is shared, apr-1 is static
  44. if package:config("shared") then
  45. package:add("defines", "APR_DECLARE_EXPORT")
  46. os.rm(package:installdir("lib/apr-1.lib"))
  47. os.rm(package:installdir("lib/aprapp-1.lib"))
  48. else
  49. package:add("defines", "APR_DECLARE_STATIC")
  50. os.rm(package:installdir("lib/lib*.lib"))
  51. os.rm(package:installdir("bin/lib*.dll"))
  52. end
  53. end)
  54. on_test(function (package)
  55. assert(package:has_cfuncs("apr_initialize", {includes = "apr_general.h"}))
  56. end)