xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("physfs")
  2. set_homepage("https://icculus.org/physfs/")
  3. set_description("A portable, flexible file i/o abstraction")
  4. set_license("zlib")
  5. set_urls("https://github.com/icculus/physfs.git")
  6. add_versions("2024.09.23", "74c30545031ca8cdb69b2f1ec173e77d79078093")
  7. local archivers = {
  8. ["zip"] = "ZIP",
  9. ["7z"] = "7zip",
  10. ["grp"] = "Build Engine GRP",
  11. ["wad"] = "Doom WAD",
  12. ["hog"] = "Descent I/II HOG",
  13. ["mvl"] = "Descent I/II MVL",
  14. ["qpak"] = "Quake I/II QPAK support",
  15. ["slb"] = "I-War / Independence War SLB",
  16. ["iso9660"] = "ISO9660",
  17. ["vdf"] = "Gothic I/II VDF archive"
  18. }
  19. for k, v in pairs(archivers) do
  20. add_configs(k, {description = "Enable " .. v .. " support", default = true, type = "boolean"})
  21. end
  22. if is_plat("windows") then
  23. add_syslinks("user32", "advapi32", "shell32")
  24. elseif is_plat("linux", "bsd") then
  25. add_syslinks("pthread")
  26. elseif is_plat("macosx") then
  27. add_frameworks("IOKit", "Foundation")
  28. end
  29. add_deps("cmake")
  30. on_install(function (package)
  31. local configs = {"-DPHYSFS_BUILD_TEST=OFF", "-DPHYSFS_BUILD_DOCS=OFF"}
  32. table.insert(configs, "-DPHYSFS_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  33. table.insert(configs, "-DPHYSFS_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  34. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  35. for k, v in pairs(archivers) do
  36. table.insert(configs, "-DPHYSFS_ARCHIVE_" .. v:upper() .. "=" .. (package:config(k) and "ON" or "OFF"))
  37. end
  38. import("package.tools.cmake").install(package, configs)
  39. if package:is_plat("windows") then
  40. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  41. os.trycp(path.join(package:buildir(), "physfs.pdb"), dir)
  42. end
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cfuncs("PHYSFS_init", {includes = "physfs.h"}))
  46. end)