xmake.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package("ghostscript")
  2. set_homepage("https://www.ghostscript.com/")
  3. set_description("Ghostscript is an interpreter for the PostScript® language and PDF files.")
  4. set_license("AGPL-3.0")
  5. add_urls("https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/$(version).tar.gz", {version = function (version)
  6. return format("gs%s/ghostscript-%s", version:gsub("%.", ""), version)
  7. end})
  8. add_versions("9.55.0", "31e2064be67e15b478a8da007d96d6cd4d2bee253e5be220703a225f7f79a70b")
  9. add_versions("10.0.0", "a57764d70caf85e2fc0b0f59b83b92e25775631714dcdb97cc6e0cea414bb5a3")
  10. add_versions("10.02.0", "e54062f166708d84ca82de9f8304a04344466080f936118b88082bd55ed6dc97")
  11. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  12. if is_plat("windows") then
  13. add_defines("__WIN32__", "_Windows")
  14. end
  15. on_install("windows|x64", "windows|x86", function (package)
  16. local configs = {"-f", "psi/msvc.mak", "COMP=cl"}
  17. if package:is_arch("x64") then
  18. table.insert(configs, "WIN64=1")
  19. end
  20. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  21. local vs_toolset = import("core.tool.toolchain").load("msvc"):config("vs_toolset")
  22. local vc_ver = "13"
  23. if vs == "2015" then vc_ver = "14"
  24. elseif vs == "2017" then vc_ver = "15"
  25. elseif vs == "2019" then vc_ver = "16"
  26. elseif vs == "2022" then vc_ver = "17"
  27. end
  28. table.insert(configs, "MSVC_VERSION=" .. vc_ver)
  29. table.insert(configs, "MS_TOOLSET_VERSION=" .. vs_toolset)
  30. table.insert(configs, "AROOTDIR=" .. package:installdir():gsub("\\", "/"))
  31. import("package.tools.nmake").build(package, configs)
  32. os.cp("psi/*.h", package:installdir("include"))
  33. os.cp("bin/gsdll*.lib", package:installdir("lib"))
  34. os.cp("bin/gsdll*.dll", package:installdir("bin"))
  35. os.cp("bin/gs*.exe", package:installdir("bin"))
  36. package:addenv("PATH", "bin")
  37. end)
  38. on_install("macosx", "linux", function (package)
  39. import("package.tools.autoconf").configure(package)
  40. os.vrun("make so")
  41. os.vrun("make soinstall")
  42. os.cp("soobj/*.h", package:installdir("include"))
  43. os.cp("base/*.h", package:installdir("include"))
  44. os.cp("psi/*.h", package:installdir("include"))
  45. package:addenv("PATH", "bin")
  46. end)
  47. on_test(function (package)
  48. local program
  49. if package:is_plat("windows") then
  50. program = package:is_arch("x64") and "gswin64c" or "gswin32c"
  51. else
  52. program = "gsc"
  53. end
  54. os.vrunv(program, {"--version"})
  55. assert(package:has_cxxfuncs("gsapi_new_instance", {includes = "iapi.h"}))
  56. end)