xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_install(function (package)
  10. if not package:config("shared") and package:is_plat("windows", "mingw", "msys") then
  11. package:add("defines", "STATIC")
  12. end
  13. io.writefile("xmake.lua", [[
  14. option("tools", {default = false})
  15. add_rules("mode.debug", "mode.release")
  16. rule("tools")
  17. on_load(function (target)
  18. if not get_config("tools") then
  19. target:set("enabled", false)
  20. return
  21. end
  22. target:add("kind", "binary")
  23. target:add("deps", "pedeps")
  24. end)
  25. target("pedeps")
  26. set_kind("$(kind)")
  27. add_files("lib/*.c")
  28. add_headerfiles("lib/*.h")
  29. add_includedirs("lib", {public = true})
  30. if is_kind("static") then
  31. add_defines("BUILD_PEDEPS_STATIC")
  32. elseif is_kind("shared") then
  33. add_defines("BUILD_PEDEPS_DLL")
  34. end
  35. for _, file in ipairs(os.files("src/*.c")) do
  36. target(path.basename(file))
  37. add_rules("tools")
  38. add_files(file)
  39. end
  40. ]])
  41. import("package.tools.xmake").install(package, {tools = package:config("tools")})
  42. end)
  43. on_test(function (package)
  44. assert(package:has_cfuncs("pefile_create", {includes = "pedeps.h"}))
  45. end)