2
0

xmake.lua 2.9 KB

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