package An official xmake package repository https://xrepo.xmake.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
5.0 KiB

4 years ago
package("libsdl_ttf")
set_homepage("https://github.com/libsdl-org/SDL_ttf/")
4 years ago
set_description("Simple DirectMedia Layer text rendering library")
set_license("zlib")
4 years ago
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2_ttf")
elseif is_plat("linux") then
add_extsources("pacman::sdl2_ttf", "apt::libsdl2-ttf-dev")
elseif is_plat("macosx") then
add_extsources("brew::sdl2_ttf")
end
libsdl_ttf: add .zip download sources on Windows (#2615) * libsdl_ttf: add .zip download sources on Windows sdl_ttf cannot be installed without using precompiled. I think xmake should disable symlink extraction (there's the same problem with sfml) ``` => download https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.2/SDL2_ttf-2.20.2.tar.gz .. failed C:\Program Files\xmake\winenv\bin\7z x -y SDL2_ttf-2.20.2.tar.gz -oC:\Users\lynix\AppData\Local\Temp\.xmake\230918\_B21627892EB948108F44065483A74B70.tar 7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21 Scanning the drive for archives: 1 file, 13161592 bytes (13 MiB) Extracting archive: SDL2_ttf-2.20.2.tar.gz -- Path = SDL2_ttf-2.20.2.tar.gz Type = gzip Headers Size = 10 Everything is Ok Size: 42510336 Compressed: 13161592 C:\Program Files\xmake\winenv\bin\7z x -y C:\Users\lynix\AppData\Local\Temp\.xmake\230918\_B21627892EB948108F44065483A74B70.tar\SDL2_ttf-2.20.2.tar -osource.tmp 7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21 Scanning the drive for archives: 1 file, 42510336 bytes (41 MiB) Extracting archive: C:\Users\lynix\AppData\Local\Temp\.xmake\230918\_B21627892EB948108F44065483A74B70.tar\SDL2_ttf-2.20.2.tar -- Path = C:\Users\lynix\AppData\Local\Temp\.xmake\230918\_B21627892EB948108F44065483A74B70.tar\SDL2_ttf-2.20.2.tar Type = tar Physical Size = 42510336 Headers Size = 800768 Code Page = UTF-8 ERROR: Can not create symbolic link : Le client ne dispose pas d'un privilège nécessaire. : source.tmp\SDL2_ttf-2.20.2\Xcode\macOS\SDL2.framework\Resources ERROR: Can not create symbolic link : Le client ne dispose pas d'un privilège nécessaire. : source.tmp\SDL2_ttf-2.20.2\Xcode\macOS\SDL2.framework\Headers ERROR: Can not create symbolic link : Le client ne dispose pas d'un privilège nécessaire. : source.tmp\SDL2_ttf-2.20.2\Xcode\macOS\SDL2.framework\SDL2 ERROR: Can not create symbolic link : Le client ne dispose pas d'un privilège nécessaire. : source.tmp\SDL2_ttf-2.20.2\Xcode\macOS\SDL2.framework\Versions\Current Sub items Errors: 4 Archives with Errors: 1 Sub items Errors: 4 tar -xf C:\Users\lynix\AppData\Local\Temp\.xmake\230918\_B21627892EB948108F44065483A74B70.tar\SDL2_ttf-2.20.2.tar SDL2_ttf-2.20.2/Xcode/macOS/SDL2.framework/Resources: Can't create '\\\\?\\C:\\Users\\lynix\\AppData\\Local\\.xmake\\cache\\packages\\2309\\l\\libsdl_ttf\\2.20.2\\source.tmp\\SDL2_ttf-2.20.2\\Xcode\\macOS\\SDL2.framework\\Resources' SDL2_ttf-2.20.2/Xcode/macOS/SDL2.framework/Headers: Can't create '\\\\?\\C:\\Users\\lynix\\AppData\\Local\\.xmake\\cache\\packages\\2309\\l\\libsdl_ttf\\2.20.2\\source.tmp\\SDL2_ttf-2.20.2\\Xcode\\macOS\\SDL2.framework\\Headers' SDL2_ttf-2.20.2/Xcode/macOS/SDL2.framework/SDL2: Can't create '\\\\?\\C:\\Users\\lynix\\AppData\\Local\\.xmake\\cache\\packages\\2309\\l\\libsdl_ttf\\2.20.2\\source.tmp\\SDL2_ttf-2.20.2\\Xcode\\macOS\\SDL2.framework\\SDL2' SDL2_ttf-2.20.2/Xcode/macOS/SDL2.framework/Versions/Current: Can't create '\\\\?\\C:\\Users\\lynix\\AppData\\Local\\.xmake\\cache\\packages\\2309\\l\\libsdl_ttf\\2.20.2\\source.tmp\\SDL2_ttf-2.20.2\\Xcode\\macOS\\SDL2.framework\\Versions\\Current' tar: Error exit delayed from previous errors. error: ...modules\private\action\require\impl\actions\download.lua:213: cannot extract SDL2_ttf-2.20.2.tar.gz, maybe missing extractor or invalid package file! stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:921]: [...modules\private\action\require\impl\actions\download.lua:213]: in function '_download' [...modules\private\action\require\impl\actions\download.lua:325]: => download https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.20.2.tar.gz .. failed we can also download these packages manually: - https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.2/SDL2_ttf-2.20.2.tar.gz - https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.20.2.tar.gz to the local search directories: - libsdl_ttf-2.20.2.tar.gz, SDL2_ttf-2.20.2.tar.gz and we can run `xmake g --pkg_searchdirs=/xxx` to set the search directories. error: @programdir\modules\private\async\runjobs.lua:256: ...modules\private\action\require\impl\actions\download.lua:378: stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:921]: [...modules\private\action\require\impl\actions\download.lua:378]: in function 'catch' [@programdir\core\sandbox\modules\try.lua:123]: in function 'try' [...modules\private\action\require\impl\actions\download.lua:298]: [...modules\private\action\require\impl\install_packages.lua:472]: in function 'jobfunc' [@programdir\modules\private\async\runjobs.lua:232]: stack traceback: [C]: in function 'error' @programdir\core\base\os.lua:921: in function 'os.raiselevel' (...tail calls...) @programdir\modules\private\async\runjobs.lua:256: in field 'catch' @programdir\core\sandbox\modules\try.lua:123: in global 'try' @programdir\modules\private\async\runjobs.lua:218: in upvalue 'cotask' @programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397> ``` * Update xmake.lua
1 year ago
if is_plat("windows", "mingw") then
add_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).zip",
"https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).zip")
add_versions("2.20.0", "04e94fc5ecac3475ab35c1d5cf52650df691867e7e4befcc861bf982a747111a")
add_versions("2.20.1", "18d81ab399c8e39adababe8918691830ba6e0d6448e5baa141ee0ddf87ede2dc")
add_versions("2.20.2", "aa6256bfcffd8381a75b3a2a2384ac12109b5b148e72722a19b0ede54c4051dc")
else
add_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).tar.gz",
"https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).tar.gz")
add_versions("2.20.0", "874680232b72839555a558b48d71666b562e280f379e673b6f0c7445ea3b9b8a")
add_versions("2.20.1", "78cdad51f3cc3ada6932b1bb6e914b33798ab970a1e817763f22ddbfd97d0c57")
add_versions("2.20.2", "9dc71ed93487521b107a2c4a9ca6bf43fb62f6bddd5c26b055e6b91418a22053")
end
add_patches(">=2.20.0 <=2.20.1", path.join(os.scriptdir(), "patches", "2.20.1", "cmakelists.patch"), "fe04ada62d9ed70029c0efb3c04bfec22fc7596bd6b73a567beb964e61ebd82c")
add_deps("cmake", "freetype")
add_includedirs("include", "include/SDL2")
if is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end
on_load(function (package)
if package:config("shared") then
package:add("deps", "libsdl", { configs = { shared = true }})
else
package:add("deps", "libsdl")
4 years ago
end
end)
on_install(function (package)
local configs = {"-DSDL2TTF_SAMPLES=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
local libsdl = package:dep("libsdl")
if libsdl and not libsdl:is_system() then
table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir())
local fetchinfo = libsdl:fetch()
if fetchinfo then
for _, dir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
if os.isfile(path.join(dir, "SDL_version.h")) then
table.insert(configs, "-DSDL2_INCLUDE_DIR=" .. dir)
break
end
end
for _, libfile in ipairs(fetchinfo.libfiles) do
if libfile:match("SDL2%..+$") or libfile:match("SDL2-static%..+$") then
table.insert(configs, "-DSDL2_LIBRARY=" .. libfile)
end
end
end
end
local freetype = package:dep("freetype")
if freetype then
local fetchinfo = freetype:fetch()
if fetchinfo then
local includedirs = table.wrap(fetchinfo.includedirs or fetchinfo.sysincludedirs)
if #includedirs > 0 then
table.insert(configs, "-DFREETYPE_INCLUDE_DIRS=" .. table.concat(includedirs, ";"))
end
local libfiles = table.wrap(fetchinfo.libfiles)
if #libfiles > 0 then
table.insert(configs, "-DFREETYPE_LIBRARY=" .. libfiles[1])
end
if not freetype:config("shared") then
local libfiles = {}
for _, dep in ipairs(freetype:librarydeps()) do
local depinfo = dep:fetch()
if depinfo then
table.join2(libfiles, depinfo.libfiles)
end
end
if #libfiles > 0 then
local libraries = ""
for _, libfile in ipairs(libfiles) do
libraries = libraries .. " " .. (libfile:gsub("\\", "/"))
end
io.replace("CMakeLists.txt", "target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype)",
"target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype " .. libraries .. ")", {plain = true})
end
end
end
end
import("package.tools.cmake").install(package, configs)
4 years ago
end)
on_test(function (package)
assert(package:has_cfuncs("TTF_Init",
{includes = "SDL2/SDL_ttf.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
end)