Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
153 lines
4.0 KiB
Lua
153 lines
4.0 KiB
Lua
import 'core.project.project'
|
|
import 'core.project.config'
|
|
import 'core.base.global'
|
|
|
|
local help_content = [==[
|
|
xmake lua spy.lua [OPTION] ACTION
|
|
|
|
OPTION:
|
|
-o FILE output the content to FILE
|
|
|
|
ACTION:
|
|
config get a config
|
|
global get a global config
|
|
getenv ... get some ENVIRONMENTs
|
|
project get all project's configuration
|
|
]==]
|
|
|
|
-- table of action's procedures(functions)
|
|
local actions = {}
|
|
local outfile = nil
|
|
|
|
-- main
|
|
function main(...)
|
|
local args = {...}
|
|
local action = args[1]
|
|
if action == '-o' then
|
|
outfile = args[2]
|
|
action = args[3]
|
|
args = table.slice(args, 3)
|
|
end
|
|
if action then
|
|
local func = actions[action]
|
|
if func then func(args) end
|
|
else
|
|
print(help_content)
|
|
end
|
|
end
|
|
-- convert the value 't' to JSON string, in a line
|
|
local function tojson(t)
|
|
if type(t) == 'table' then
|
|
local list = {}
|
|
if t[1] then
|
|
for i = 1, #t do
|
|
list[i] = tojson(t[i])
|
|
end
|
|
return table.concat({'[', table.concat(list, ','), ']'})
|
|
else
|
|
for k, v in pairs(t) do
|
|
table.insert(list, tojson(k) .. ':' .. tojson(v))
|
|
end
|
|
return table.concat({'{', table.concat(list, ','), '}'})
|
|
end
|
|
end
|
|
local tt = type(t)
|
|
if tt == 'string' then
|
|
-- t = t:gsub('[\\\n\r\t"]', {
|
|
-- ['\\'] = '\\\\', ['\n'] = '\\n',
|
|
-- ['\t'] = '\\t', ['"'] = '\\"', ['\r'] = '\\r'
|
|
-- })
|
|
-- return '"' .. t .. '"'
|
|
return string.format('%q', t)
|
|
elseif tt == 'nil' then
|
|
return 'null'
|
|
else -- number or boolean
|
|
return tostring(t)
|
|
end
|
|
end
|
|
|
|
function output(t)
|
|
local t = tojson(t)
|
|
if outfile then
|
|
local file = io.open(outfile, 'w')
|
|
if not file then
|
|
print('can not open file to write:', outfile)
|
|
return
|
|
end
|
|
file:write(t)
|
|
file:close()
|
|
else
|
|
print(t)
|
|
end
|
|
end
|
|
-- Action: config ----- get the current configuration
|
|
actions.config = function(args)
|
|
config.load()
|
|
local list = {}
|
|
for i = 2,#args do
|
|
list[i-1] = config.get(args[i]) or ''
|
|
end
|
|
output(list)
|
|
end
|
|
-- Action: global ----- get the global configuration
|
|
actions.global = function(args)
|
|
global.load()
|
|
local list = {}
|
|
for i = 2,#args do
|
|
list[i-1] = global.get(args[i]) or ''
|
|
end
|
|
output(list)
|
|
end
|
|
-- Action: getenv ------ get environment variables inside xmake
|
|
actions.getenv = function(args)
|
|
local list = {}
|
|
for i = 2,#args do
|
|
list[i-1] = os.getenv(args[i]) or ''
|
|
end
|
|
output(list)
|
|
end
|
|
actions.incdirs = function(args)
|
|
config.load()
|
|
for name, target in pairs(project.targets()) do
|
|
print(target:get('includedirs'))
|
|
end
|
|
print(os.getenv('INCLUDE'))
|
|
end
|
|
-- Action: project ----- get the project's configuration
|
|
actions.project = function(args)
|
|
config.load()
|
|
-- os.cd(project.directory())
|
|
-- project's configuration
|
|
local xconfig = {
|
|
config = {
|
|
arch = config:arch(),
|
|
plat = config:plat(),
|
|
mode = config:mode(),
|
|
cc = config.get('cc'),
|
|
cxx = config.get('cxx')
|
|
},
|
|
-- project's name
|
|
name = project.name() or '<unamed>',
|
|
-- project's version
|
|
version = project.version(),
|
|
-- project's targets
|
|
targets = {}
|
|
}
|
|
-- read the configuration of all targets
|
|
for tname, target in pairs(project.targets()) do
|
|
local tcfg = {}
|
|
try { function ()
|
|
tcfg.name = target:name()
|
|
tcfg.targetkind = target:targetkind() or ''
|
|
tcfg.sourcefiles = target:sourcefiles() or {}
|
|
tcfg.headerfiles = target:headerfiles() or {}
|
|
tcfg.targetfile = target:targetfile() or '' end,
|
|
catch { function(err)
|
|
print(err)
|
|
end}}
|
|
xconfig.targets[tname] = tcfg
|
|
end
|
|
-- output
|
|
output(xconfig)
|
|
end
|