Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
684 changes: 345 additions & 339 deletions scripts/installer.nsi

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions xmake/core/base/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ end
-- @param str the string with colors
-- @param opt options
-- patch_reset: wrap str with `"${reset}"`?
-- ignore_unknown: ignore unknown codes like `"${unknown_code}"`?
--
-- 8 colors:
--
Expand Down Expand Up @@ -340,12 +341,12 @@ function colors.translate(str, opt)
for _, theme_block_sub in ipairs(theme_block:split("%s")) do
table.insert(blocks, theme_block_sub)
end
else
else
table.insert(blocks, block)
end
elseif block:startswith("color.") or block:startswith("text.") then
local default_theme = {["color.error"] = "red", ["color.warning"] = "yellow", ["text.error"] = "error", ["text.warning"] = "warning"}
local theme_block = default_theme[block]
local theme_block = default_theme[block]
if theme_block then
table.insert(blocks, theme_block)
else
Expand Down Expand Up @@ -384,7 +385,8 @@ function colors.translate(str, opt)
local emoji_code = emoji.translate(block)
if emoji_code then
table.insert(text_buffer, emoji_code)
else
elseif not opt.ignore_unknown then
-- unknown code, regard as plain text
table.insert(text_buffer, block)
end
end
Expand Down
77 changes: 49 additions & 28 deletions xmake/core/base/dump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,42 @@ local table = require("base/table")
-- format string with theme colors
function dump._format(fmtkey, fmtdefault, ...)
local theme = colors.theme()
local fmt = theme and theme:get(fmtkey) or fmtdefault
return string.format(fmt, ...)
if theme then
return colors.translate(string.format(theme:get(fmtkey), ...), { patch_reset = false, ignore_unknown = true })
else
return string.format(fmtdefault, ...)
end
end

-- translate string with theme formats
function dump._translate(str)
return colors.translate(str, { patch_reset = false, ignore_unknown = true })
end

-- print string
function dump._print_string(str, as_key)
local quote = (not as_key) or (not str:match("^[a-zA-Z_][a-zA-Z0-9_]*$"))
if quote then
io.write(colors.translate("${reset}${color.dump.string_quote}\"${reset}${color.dump.string}", { patch_reset = false }))
io.write(dump._translate("${reset}${color.dump.string_quote}\"${reset}${color.dump.string}"))
else
io.write(colors.translate("${reset}${color.dump.string}", { patch_reset = false }))
io.write(dump._translate("${reset}${color.dump.string}"))
end
io.write(str)
if quote then
io.write(colors.translate("${reset}${color.dump.string_quote}\"${reset}", { patch_reset = false }))
io.write(dump._translate("${reset}${color.dump.string_quote}\"${reset}"))
else
io.write(colors.translate("${reset}", { patch_reset = false }))
io.write(dump._translate("${reset}"))
end
end

-- print keyword
function dump._print_keyword(keyword)
io.write(colors.translate("${color.dump.keyword}" .. tostring(keyword)))
io.write(dump._translate("${reset}${color.dump.keyword}"), tostring(keyword), dump._translate("${reset}"))
end

-- print number
function dump._print_number(num)
io.write(colors.translate("${color.dump.number}" .. tostring(num)))
io.write(dump._translate("${reset}${color.dump.number}"), tostring(num), dump._translate("${reset}"))
end

-- print function
Expand All @@ -68,14 +76,23 @@ function dump._print_function(func, as_key)
if funcinfo.linedefined >= 0 then
srcinfo = srcinfo .. ":" .. funcinfo.linedefined
end
io.write(colors.translate("${color.dump.function}function ${bright}" .. (funcinfo.name or "") .. "${reset}${dim}" .. srcinfo))
local funcname = funcinfo.name and (funcinfo.name .. " ") or ""
io.write(dump._translate("${reset}${color.dump.function}function ${bright}"), funcname, dump._translate("${reset}${dim}"), srcinfo)
end

-- print value with default format
function dump._print_default(value)
io.write(colors.translate("${color.dump.default}", { patch_reset = false }))
io.write(dump._format("text.dump.default_format", "%s", value))
io.write(colors.translate("${reset}", { patch_reset = false }))
io.write(dump._translate("${reset}${color.dump.default}"), dump._format("text.dump.default_format", "<%s>", value), dump._translate("${reset}"))
end

-- print udata value with scalar format
function dump._print_udata_scalar(value)
io.write(dump._translate("${reset}${color.dump.udata}"), dump._format("text.dump.udata_format", "[%s]", value), dump._translate("${reset}"))
end

-- print table value with scalar format
function dump._print_table_scalar(value)
io.write(dump._translate("${reset}${color.dump.table}"), dump._format("text.dump.table_format", "{%s}", value), dump._translate("${reset}"))
end

-- print scalar value
Expand All @@ -90,31 +107,34 @@ function dump._print_scalar(value, as_key)
dump._print_string(value, as_key)
elseif type(value) == "function" then
dump._print_function(value, as_key)
elseif type(value) == "userdata" then
dump._print_udata_scalar(value)
elseif type(value) == "table" then
dump._print_table_scalar(value)
else
dump._print_default(value)
end
end

-- print anchor
function dump._print_anchor(value)
io.write(colors.translate("${color.dump.anchor}", { patch_reset = false }))
io.write(dump._format("text.dump.anchor", "&%s", value))
io.write(colors.translate("${reset}", { patch_reset = false }))
io.write(dump._translate("${color.dump.anchor}"), dump._format("text.dump.anchor", "&%s", value), dump._translate("${reset}"))
end

-- print reference
function dump._print_reference(value)
io.write(colors.translate("${color.dump.reference}", { patch_reset = false }))
io.write(dump._format("text.dump.reference", "*%s", value))
io.write(colors.translate("${reset}", { patch_reset = false }))
io.write(dump._translate("${color.dump.reference}"), dump._format("text.dump.reference", "*%s", value), dump._translate("${reset}"))
end

-- print anchor and store to printed_set
function dump._print_table_anchor(value, printed_set)
printed_set.len = printed_set.len + 1
io.write(" ")
dump._print_anchor(printed_set.len)
printed_set[value] = printed_set.len
end

-- print metatable of value
function dump._print_metatable(value, metatable, inner_indent, printed_set, print_archor)
if not metatable then
return false
Expand All @@ -136,7 +156,7 @@ function dump._print_metatable(value, metatable, inner_indent, printed_set, prin
io.write("\n", inner_indent)
local funcname = k:sub(3)
dump._print_keyword(funcname)
io.write(colors.translate("${dim} = "))
io.write(dump._translate("${reset} ${dim}=${reset} "))
if funcname == "tostring" or funcname == "len" then
local ok, result = pcall(v, value, value)
if ok then
Expand Down Expand Up @@ -173,7 +193,7 @@ function dump._print_metatable(value, metatable, inner_indent, printed_set, prin
dump._print_keyword("(")
dump._print_scalar(k, true)
dump._print_keyword(")")
io.write(colors.translate("${dim} = "))
io.write(dump._translate("${reset} ${dim}=${reset} "))
if v and printed_set[v] then
dump._print_reference(printed_set[v])
else
Expand All @@ -193,16 +213,16 @@ function dump._print_udata(value, first_indent, remain_indent)
local inner_indent = remain_indent .. " "

-- print open brackets
io.write(colors.translate("${dim}["))
io.write(dump._translate("${reset}${color.dump.udata}[${reset}"))

-- print metatable
local no_value = not dump._print_metatable(value, metatable, inner_indent, { len = 0 }, false)

-- print close brackets
if no_value then
io.write(colors.translate(" ${dim}]"))
io.write(dump._translate(" ${color.dump.udata}]${reset}"))
else
io.write("\b \n" .. remain_indent .. colors.translate("${dim}]"))
io.write("\b \n", remain_indent, dump._translate("${reset}${color.dump.udata}]${reset}"))
end
end

Expand All @@ -216,15 +236,15 @@ function dump._print_table(value, first_indent, remain_indent, printed_set)
if not first_level and tostringmethod then
local ok, strrep = pcall(tostringmethod, value, value)
if ok then
return dump._print_default(strrep)
return dump._print_table_scalar(strrep)
end
end
printed_set = printed_set or { len = 0 }
local inner_indent = remain_indent .. " "
local first_value = true

-- print open brackets
io.write(colors.translate("${dim}{"))
io.write(dump._translate("${reset}${color.dump.table}{${reset}"))

local function print_newline()
if first_value then
Expand All @@ -235,6 +255,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set)
end

if first_level then
-- print metatable
first_value = not dump._print_metatable(value, metatable, inner_indent, printed_set, true)
end

Expand Down Expand Up @@ -262,7 +283,7 @@ function dump._print_table(value, first_indent, remain_indent, printed_set)
if not is_arr or type(k) ~= "number" then
print_newline()
dump._print_scalar(k, true)
io.write(colors.translate("${dim} = "))
io.write(dump._translate("${reset} ${dim}=${reset} "))
if type(v) == "table" then
if printed_set[v] then
dump._print_reference(printed_set[v])
Expand All @@ -278,9 +299,9 @@ function dump._print_table(value, first_indent, remain_indent, printed_set)

-- print close brackets
if first_value then
io.write(colors.translate(" ${dim}}"))
io.write(dump._translate(" ${color.dump.table}}${reset}"))
else
io.write("\b \n" .. remain_indent .. colors.translate("${dim}}"))
io.write("\b \n", remain_indent, dump._translate("${reset}${color.dump.table}}${reset}"))
end
end

Expand Down
2 changes: 1 addition & 1 deletion xmake/modules/detect/tools/find_nvcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function main(opt)

-- not found? attempt to find program from cuda toolchains
if not program then
local toolchains = find_cuda(config.get("cuda"))
local toolchains = find_cuda()
if toolchains and toolchains.bindir then
program = find_program(path.join(toolchains.bindir, "nvcc"), opt)
end
Expand Down
39 changes: 19 additions & 20 deletions xmake/plugins/project/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@ import("core.base.task")
import("core.platform.environment")
import("make.makefile")
import("cmake.cmakelists")
import("vstudio.vs2002")
import("vstudio.vs2003")
import("vstudio.vs2005")
import("vstudio.vs2008")
import("vstudio.vs2010")
import("vstudio.vs2012")
import("vstudio.vs2013")
import("vstudio.vs2015")
import("vstudio.vs2017")
import("vstudio.vs2019")
import("vstudio.vs")
import("vstudio.vsx")
import("vsxmake.vsxmake")
import("clang.compile_flags")
import("clang.compile_commands")

Expand All @@ -45,16 +38,22 @@ function _make(kind)
{
makefile = makefile.make
, cmakelists = cmakelists.make
, vs2002 = vs2002.make
, vs2003 = vs2003.make
, vs2005 = vs2005.make
, vs2008 = vs2008.make
, vs2010 = vs2010.make
, vs2012 = vs2012.make
, vs2013 = vs2013.make
, vs2015 = vs2015.make
, vs2017 = vs2017.make
, vs2019 = vs2019.make
, vs2002 = vs.make(2002)
, vs2003 = vs.make(2003)
, vs2005 = vs.make(2005)
, vs2008 = vs.make(2008)
, vs2010 = vsx.make(2010)
, vs2012 = vsx.make(2012)
, vs2013 = vsx.make(2013)
, vs2015 = vsx.make(2015)
, vs2017 = vsx.make(2017)
, vs2019 = vsx.make(2019)
, vsxmake2010 = vsxmake.make(2010)
, vsxmake2012 = vsxmake.make(2012)
, vsxmake2013 = vsxmake.make(2013)
, vsxmake2015 = vsxmake.make(2015)
, vsxmake2017 = vsxmake.make(2017)
, vsxmake2019 = vsxmake.make(2019)
, compile_flags = compile_flags.make
, compile_commands = compile_commands.make
}
Expand Down
15 changes: 3 additions & 12 deletions xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function _make_linkflags(target, vcprojdir)
-- save flag
table.insert(flags, flag)
end

-- make flags string
flags = os.args(flags)

Expand All @@ -114,20 +114,11 @@ function _make_header(vcprojfile, vsinfo, target)
-- the target name
local targetname = target:name()

-- the versions
local versions =
{
vs2002 = '7.0'
, vs2003 = '7.1'
, vs2005 = '8.0'
, vs2008 = '9.0'
}

-- make header
vcprojfile:print("<?xml version=\"1.0\" encoding=\"gb2312\"?>")
vcprojfile:print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
vcprojfile:enter("<VisualStudioProject")
vcprojfile:print("ProjectType=\"Visual C++\"")
vcprojfile:print("Version=\"%s0\"", assert(versions["vs" .. vsinfo.vstudio_version]))
vcprojfile:print("Version=\"%s0\"", assert(vsinfo.project_version))
vcprojfile:print("Name=\"%s\"", targetname)
vcprojfile:print("ProjectGUID=\"{%s}\"", hash.uuid(targetname))
vcprojfile:print("RootNamespace=\"%s\"", targetname)
Expand Down
3 changes: 0 additions & 3 deletions xmake/plugins/project/vstudio/impl/vs201x_solution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,4 @@ function make(vsinfo)

-- exit solution file
slnfile:close()

-- convert gb2312 to utf8
io.writefile(slnpath, io.readfile(slnpath):convert("gb2312", "utf8"))
end
Loading