From 2e1bd0622b657b88390dab4eb227a5633650a9e5 Mon Sep 17 00:00:00 2001 From: Guyutongxue Date: Sun, 6 Nov 2022 00:20:21 +0800 Subject: [PATCH] Add Windows Console port for pdcurses (#1599) * Add Windows Console port for pdcurses * Update xmake.lua * fix error PDC_WIDE should be only defined when using wincon Co-authored-by: ruki --- packages/p/pdcurses/xmake.lua | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/p/pdcurses/xmake.lua b/packages/p/pdcurses/xmake.lua index 902e06dff..403fd5d98 100644 --- a/packages/p/pdcurses/xmake.lua +++ b/packages/p/pdcurses/xmake.lua @@ -9,24 +9,39 @@ package("pdcurses") if not is_plat("windows") then add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) end - - add_deps("libsdl") + add_configs("port", {description = "Set the target port.", default = "sdl2", values = {"sdl2", "wincon"}}) + + on_load(function (package) + if package:config("port") == "sdl2" then + package:add("deps", "libsdl") + else + package:add("syslinks", "user32", "advapi32") + end + end) + on_install("linux", "macosx", "mingw", "windows", function (package) io.writefile("xmake.lua", [[ add_rules("mode.debug", "mode.release") - add_requires("libsdl") + option("port", {description = "Set the target port."}) + if is_config("port", "sdl2") then + add_requires("libsdl") + end target("pdcurses") set_kind("$(kind)") - add_files("pdcurses/*.c", "sdl2/*.c") - add_includedirs(".", "sdl2") - add_headerfiles("*.h", "sdl2/*.h") + add_files("pdcurses/*.c", "$(port)/*.c") + add_includedirs(".", "$(port)") + add_headerfiles("*.h", "$(port)/*.h") + if is_config("port", "wincon") then + add_defines("PDC_WIDE", "PDC_FORCE_UTF8") + end add_packages("libsdl") ]]) local configs = {} if package:config("shared") then configs.kind = "shared" end + configs.port = package:config("port") import("package.tools.xmake").install(package, configs) end)