xmake.lua 2.6 KB

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