xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package("pthreads4w")
  2. set_homepage("https://sourceforge.net/projects/pthreads4w/")
  3. set_description("POSIX Threads for Win32")
  4. set_urls("https://github.com/xmake-mirror/pthreads4w/archive/$(version).tar.gz",
  5. "https://github.com/xmake-mirror/pthreads4w.git",
  6. "https://gitee.com/xmake-mirror/pthreads4w.git")
  7. add_versions("3.0.0", "31f20963840c26d78fb20224577b7e677018b3eb3000c3570db88528043adc20")
  8. add_includedirs("include/pthread")
  9. if is_host("linux", "macosx") and is_plat("mingw") then
  10. add_deps("autoconf", "automake")
  11. end
  12. on_install("windows|x64", "windows|x86", function (package)
  13. local target = "VC"
  14. if not package:config("shared") then
  15. target = target .. "-static"
  16. end
  17. if package:debug() then
  18. target = target .. "-debug"
  19. end
  20. import("package.tools.nmake").build(package, {"-f", "Makefile", target})
  21. os.cp("*.lib", package:installdir("lib"))
  22. os.cp("*.h", package:installdir("include/pthread"))
  23. if package:config("shared") then
  24. os.cp("*.dll", package:installdir("bin"))
  25. package:addenv("PATH", "bin")
  26. end
  27. if package:debug() then
  28. os.cp("*.pdb", package:installdir("lib"))
  29. end
  30. end)
  31. on_install("mingw@macosx,linux", function (package)
  32. local configs = {}
  33. if package:config("shared") then
  34. table.insert(configs, "--enable-shared=yes")
  35. else
  36. table.insert(configs, "--enable-shared=no")
  37. end
  38. if package:debug() then
  39. table.insert(configs, "--enable-debug")
  40. end
  41. import("package.tools.autoconf").configure(package, configs)
  42. local target = "GC"
  43. if not package:config("shared") then
  44. target = target .. "-static"
  45. end
  46. if package:debug() then
  47. target = target .. "-debug"
  48. end
  49. os.vrunv("make", {"V=1", target})
  50. end)
  51. on_test(function (package)
  52. assert(package:has_cfuncs("pthread_create", {includes = "pthread.h"}))
  53. end)