xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("pedeps")
  2. set_homepage("https://github.com/brechtsanders/pedeps")
  3. set_description("Cross-platform C library to read data from PE/PE+ files (the format of Windows .exe and .dll files)")
  4. set_license("MIT")
  5. add_urls("https://github.com/brechtsanders/pedeps/releases/download/$(version)/pedeps-$(version).tar.xz",
  6. "https://github.com/brechtsanders/pedeps.git")
  7. add_versions("0.1.15", "41e6239ff27deed21ad435567f3f8f1c049d072c86a37c2005fd74aea906f1d3")
  8. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  9. on_load(function (package)
  10. if package:config("tools") then
  11. package:add("patches", "0.1.15", "patches/0.1.15/tool.patch", "7c25438c0357721ddb6ee74c28a074ad1b7772f4c0b7604de11885569d7b4cb0")
  12. end
  13. if not package:config("shared") and package:is_plat("windows", "mingw", "msys") then
  14. package:add("defines", "STATIC")
  15. end
  16. end)
  17. on_install(function (package)
  18. io.writefile("xmake.lua", [[
  19. option("tools", {default = false})
  20. add_rules("mode.debug", "mode.release")
  21. rule("tools")
  22. on_load(function (target)
  23. if not get_config("tools") then
  24. target:set("enabled", false)
  25. return
  26. end
  27. target:add("kind", "binary")
  28. target:add("deps", "pedeps")
  29. end)
  30. target("pedeps")
  31. set_kind("$(kind)")
  32. add_files("lib/*.c")
  33. add_headerfiles("lib/*.h")
  34. add_includedirs("lib", {public = true})
  35. if is_kind("static") then
  36. add_defines("BUILD_PEDEPS_STATIC")
  37. add_defines("STATIC", {interface = true})
  38. elseif is_kind("shared") then
  39. add_defines("BUILD_PEDEPS_DLL")
  40. end
  41. for _, file in ipairs(os.files("src/*.c")) do
  42. target(path.basename(file))
  43. add_rules("tools")
  44. add_files(file)
  45. end
  46. ]])
  47. import("package.tools.xmake").install(package, {tools = package:config("tools")})
  48. end)
  49. on_test(function (package)
  50. assert(package:has_cfuncs("pefile_create", {includes = "pedeps.h"}))
  51. end)