Skip to content

Commit

Permalink
Add gl2ps (xmake-io#6507)
Browse files Browse the repository at this point in the history
* test

* fixup hash

* Do not build tests.

* test

* fixup

* test

* Update xmake.lua

* Update xmake.lua

* retry

* re

* remove v

* Update xmake.lua

* Update xmake.lua

* test

* fixup

* retry

* re

* make opengl deps optional = true

---------

Co-authored-by: star9029 <hengxings783@gmail.com>
  • Loading branch information
2 people authored and Doekin committed Mar 5, 2025
1 parent 261dd6a commit 1c14442
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
64 changes: 64 additions & 0 deletions packages/g/gl2ps/port/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
add_rules("mode.debug", "mode.release")

set_project("gl2ps")
set_version("1.4.2")
set_languages("c99")

option("zlib", {description = "Enable ZLIB compression", default = true})
option("png", {description = "Enable PNG support", default = true})

includes("@builtin/check")

set_configvar("GL2PS_MAJOR_VERSION", 1)
set_configvar("GL2PS_MINOR_VERSION", 4)
set_configvar("GL2PS_PATCH_VERSION", 2)
set_configvar("GL2PS_EXTRA_VERSION", "")
set_configvar("GL2PS_OS", is_plat("macosx") and "MacOSX" or (is_plat("windows", "mingw") and "Windows" or "Linux"))

option("HAVE_VSNPRINTF")
add_cfuncs("vsnprintf")
add_cincludes("stdio.h")
option_end()

if not has_config("HAVE_VSNPRINTF") then
add_defines("HAVE_NO_VSNPRINTF")
end

add_requires("opengl", {optional = true})
add_requires("glut")
if has_config("zlib") then
add_requires("zlib")
add_defines("HAVE_ZLIB")
end
if has_config("png") then
add_requires("libpng")
add_defines("HAVE_PNG")
end

if is_plat("linux", "macosx") then
add_syslinks("m")
end

if is_plat("macosx") then
add_cflags("-Wno-deprecated-declarations")
end

target("gl2ps")
set_kind("$(kind)")
add_files("gl2ps.c")
add_headerfiles("gl2ps.h")
add_packages("opengl", "glut")

if is_kind("shared") and is_plat("windows", "cygwin") then
add_defines("GL2PSDLL", "GL2PSDLL_EXPORTS")
end
if is_kind("static") then
add_defines("GL2PS_STATIC")
end

if has_config("zlib") then
add_packages("zlib")
end
if has_config("png") then
add_packages("libpng")
end
52 changes: 52 additions & 0 deletions packages/g/gl2ps/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package("gl2ps")
set_homepage("https://gitlab.onelab.info/gl2ps/gl2ps")
set_description("OpenGL to PostScript printing library")
set_license("LGPL")

add_urls("https://gitlab.onelab.info/gl2ps/gl2ps/-/archive/gl2ps_$(version)/gl2ps-gl2ps_$(version).tar.gz",
"https://gitlab.onelab.info/gl2ps/gl2ps.git", { version = function(version)
return version:gsub("%.", "_")
end})

add_versions("1.4.2", "afb6f4a8df9c7639449546a79aabd1baaccacc4360fc23741c6485138512ff72")

add_configs("zlib", {description = "Enable compression using ZLIB", default = true, type = "boolean"})
add_configs("png", {description = "Enable PNG support", default = true, type = "boolean"})

add_deps("opengl", "glut")

if is_plat("macosx", "linux", "bsd") then
add_deps("libx11")
end

if is_plat("linux", "bsd") then
add_syslinks("m")
elseif is_plat("macosx") then
add_frameworks("Cocoa", "OpenGL")
end

on_check("windows", function (package)
local msvc = package:toolchain("msvc")
if msvc and package:is_arch("arm.*") then
local vs = msvc:config("vs")
assert(vs and tonumber(vs) >= 2022, "package(gl2ps): requires Visual Studio 2022 and later for arm targets")
end
end)

on_load(function (package)
if package:config("zlib") then
package:add("deps", "zlib")
end
if package:config("png") then
package:add("deps", "libpng")
end
end)

on_install("windows", "linux", "macosx", "mingw", function (package)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
import("package.tools.xmake").install(package, configs)
end)

on_test(function (package)
assert(package:has_cfuncs("gl2psEndPage", {includes = "gl2ps.h"}))
end)

0 comments on commit 1c14442

Please sign in to comment.