Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soil2: add package #5749

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions packages/s/soil2/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package("soil2")
set_homepage("https://github.com/SpartanJ/SOIL2")
set_description("SOIL2 is a tiny C library used primarily for uploading textures into OpenGL.")
set_license("MIT-0")

add_urls("https://github.com/SpartanJ/SOIL2.git")
add_versions("2024.10.14", "1ecaa772fdc67a49f9737452d628730384806f9b")

if is_plat("macosx") then
add_frameworks("CoreFoundation")
end

add_deps("cmake")
add_deps("opengl", {optional = true})

if on_check then
on_check("windows", function (package)
if package:is_arch("arm.*") then
local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
if vs_toolset then
local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
local minor = vs_toolset_ver:minor()
assert(minor and minor >= 30, "package(soil2) require vs_toolset >= 14.3")
end
end
end)
end

-- TODO: fix glXGetProcAddress on linux
on_install("!android and !wasm and !cross and !iphoneos and !linux and !bsd", function (package)
star-hengxing marked this conversation as resolved.
Show resolved Hide resolved
io.replace("CMakeLists.txt", "$<$<CXX_COMPILER_ID:Clang>:-fPIC>", "", {plain = true})
io.replace("CMakeLists.txt", "$<$<CXX_COMPILER_ID:GNU>:-fPIC>", "", {plain = true})

local configs = {"-DSOIL2_BUILD_TESTS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:is_plat("windows") and package:config("shared") then
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
end

local opt = {packagedeps = "opengl"}
if package:is_plat("macosx") then
opt.shflags = {"-framework", "CoreFoundation"}
end
import("package.tools.cmake").install(package, configs, opt)

if package:is_plat("windows") and package:is_debug() then
local dir = package:installdir(package:config("shared") and "bin" or "lib")
os.trycp(path.join(package:buildir(), "soil2.pdb"), dir)
end
end)

on_test(function (package)
assert(package:has_cfuncs("SOIL_load_OGL_texture", {includes = "soil2/SOIL2.h"}))
end)
Loading