xmake.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  10. if is_plat("windows") then
  11. add_defines("__WIN32__", "_Windows")
  12. end
  13. on_install("windows", function (package)
  14. local configs = {"-f", "psi/msvc.mak", "COMP=cl"}
  15. if package:is_arch("x64") then
  16. table.insert(configs, "WIN64=1")
  17. end
  18. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  19. local vs_toolset = import("core.tool.toolchain").load("msvc"):config("vs_toolset")
  20. local vc_ver = "13"
  21. if vs == "2015" then vc_ver = "14"
  22. elseif vs == "2017" then vc_ver = "15"
  23. elseif vs == "2019" then vc_ver = "16"
  24. elseif vs == "2022" then vc_ver = "17"
  25. end
  26. table.insert(configs, "MSVC_VERSION=" .. vc_ver)
  27. table.insert(configs, "MS_TOOLSET_VERSION=" .. vs_toolset)
  28. table.insert(configs, "AROOTDIR=" .. package:installdir():gsub("\\", "/"))
  29. import("package.tools.nmake").build(package, configs)
  30. os.cp("psi/*.h", package:installdir("include"))
  31. os.cp("bin/gsdll*.lib", package:installdir("lib"))
  32. os.cp("bin/gsdll*.dll", package:installdir("bin"))
  33. os.cp("bin/gs*.exe", package:installdir("bin"))
  34. package:addenv("PATH", "bin")
  35. end)
  36. on_install("macosx", "linux", function (package)
  37. import("package.tools.autoconf").configure(package)
  38. os.vrun("make so")
  39. os.vrun("make soinstall")
  40. os.cp("soobj/*.h", package:installdir("include"))
  41. os.cp("base/*.h", package:installdir("include"))
  42. os.cp("psi/*.h", package:installdir("include"))
  43. package:addenv("PATH", "bin")
  44. end)
  45. on_test(function (package)
  46. local program
  47. if package:is_plat("windows") then
  48. program = package:is_arch("x64") and "gswin64c" or "gswin32c"
  49. else
  50. program = "gsc"
  51. assert(package:has_cfuncs("gs_rotate", {includes = "gscoord.h"}))
  52. end
  53. os.vrunv(program, {"--version"})
  54. assert(package:has_cxxfuncs("gsapi_new_instance", {includes = "iapi.h"}))
  55. end)