|
@@ -1,6 +1,5 @@
|
|
package("libsdl_ttf")
|
|
package("libsdl_ttf")
|
|
-
|
|
|
|
- set_homepage("https://www.libsdl.org/projects/SDL_ttf/")
|
|
|
|
|
|
+ set_homepage("https://github.com/libsdl-org/SDL_ttf/")
|
|
set_description("Simple DirectMedia Layer text rendering library")
|
|
set_description("Simple DirectMedia Layer text rendering library")
|
|
set_license("zlib")
|
|
set_license("zlib")
|
|
|
|
|
|
@@ -12,69 +11,87 @@ package("libsdl_ttf")
|
|
add_extsources("brew::sdl2_ttf")
|
|
add_extsources("brew::sdl2_ttf")
|
|
end
|
|
end
|
|
|
|
|
|
- if is_plat("windows", "mingw") then
|
|
|
|
- set_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-$(version)-VC.zip")
|
|
|
|
- add_urls("https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-devel-$(version)-VC.zip")
|
|
|
|
- add_versions("2.0.15", "aab0d81f1aa6fe654be412efc85829f2b188165dca6c90eb4b12b673f93e054b")
|
|
|
|
- add_versions("2.0.18", "4e1404ac6095bbcd4cb133eb644a765885aa283ae45f36cfbc3cf5a77d7e1cbd")
|
|
|
|
- add_versions("2.20.0", "bc206392a74d2b32f74d770a3a1e623e87c72374781c115478277ab4c722358b")
|
|
|
|
- add_versions("2.20.1", "2facfa180f77bac381776376c7598ad504a84d99414418049bb106cb1705fe22")
|
|
|
|
- else
|
|
|
|
- set_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).zip")
|
|
|
|
- add_urls("https://github.com/libsdl-org/SDL_ttf/releases/download/release-$(version)/SDL2_ttf-$(version).zip")
|
|
|
|
- add_versions("2.0.15", "cdb72b5b1c3b27795fa128af36f369fee5d3e38a96c350855da0b81880555dbc")
|
|
|
|
- add_versions("2.0.18", "64e6a93c7542aba1e32e1418413898dfde82be95fdd0c73ba265fbdada189b5f")
|
|
|
|
- add_versions("2.20.0", "04e94fc5ecac3475ab35c1d5cf52650df691867e7e4befcc861bf982a747111a")
|
|
|
|
- add_versions("2.20.1", "18d81ab399c8e39adababe8918691830ba6e0d6448e5baa141ee0ddf87ede2dc")
|
|
|
|
- end
|
|
|
|
|
|
+ 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")
|
|
|
|
|
|
- add_deps("libsdl")
|
|
|
|
- if is_plat("linux", "macosx") then
|
|
|
|
- add_deps("freetype")
|
|
|
|
- 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_links("SDL2_ttf")
|
|
|
|
add_includedirs("include", "include/SDL2")
|
|
add_includedirs("include", "include/SDL2")
|
|
|
|
|
|
- on_load("macosx", "linux", function (package)
|
|
|
|
- if package:version():ge("2.20") then
|
|
|
|
- package:add("deps", "cmake")
|
|
|
|
- else
|
|
|
|
- package:add("deps", "automake", "autoconf")
|
|
|
|
- end
|
|
|
|
- end)
|
|
|
|
|
|
+ if is_plat("wasm") then
|
|
|
|
+ add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
|
|
|
|
+ end
|
|
|
|
|
|
- on_install("windows", "mingw", function (package)
|
|
|
|
- local arch = package:arch()
|
|
|
|
- if package:is_plat("mingw") then
|
|
|
|
- arch = (arch == "x86_64") and "x64" or "x86"
|
|
|
|
|
|
+ on_load(function (package)
|
|
|
|
+ if package:config("shared") then
|
|
|
|
+ package:add("deps", "libsdl", { configs = { shared = true }})
|
|
|
|
+ else
|
|
|
|
+ package:add("deps", "libsdl")
|
|
end
|
|
end
|
|
- os.cp("include/*", package:installdir("include/SDL2"))
|
|
|
|
- os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
|
|
|
|
- os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
|
|
|
|
end)
|
|
end)
|
|
|
|
|
|
- on_install("macosx", "linux", function (package)
|
|
|
|
- if package:version():ge("2.20") then
|
|
|
|
- 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"))
|
|
|
|
- if libsdl and not libsdl:is_system() then
|
|
|
|
- table.insert(configs, "-DSDL2_DIR=" .. libsdl:installdir())
|
|
|
|
|
|
+ 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
|
|
- import("package.tools.cmake").install(package, configs)
|
|
|
|
- else
|
|
|
|
- local configs = {}
|
|
|
|
- table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
|
|
|
|
- table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
|
|
|
|
- local libsdl = package:dep("libsdl")
|
|
|
|
- if libsdl and not libsdl:is_system() then
|
|
|
|
- table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
|
|
|
|
|
|
+ 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.autoconf").install(package, configs)
|
|
|
|
end
|
|
end
|
|
|
|
+ import("package.tools.cmake").install(package, configs)
|
|
end)
|
|
end)
|
|
|
|
|
|
on_test(function (package)
|
|
on_test(function (package)
|
|
- assert(package:has_cfuncs("TTF_Init", {includes = "SDL2/SDL_ttf.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
|
|
|
|
|
|
+ assert(package:has_cfuncs("TTF_Init",
|
|
|
|
+ {includes = "SDL2/SDL_ttf.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
|
|
end)
|
|
end)
|