summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-04 00:16:39 +0800
committerruki <[email protected]>2021-05-04 00:16:39 +0800
commit9fcc366603c2572eb2710b843d240b0368f32ad5 (patch)
tree6d1744e4fb9ac768d32de7f52d5c02ce790efc5d
parentba285402bd1f5fed3eedc5a507ec98a232de8c27 (diff)
enable profiler
-rw-r--r--xmake/core/main.lua31
-rw-r--r--xmake/plugins/show/lists/envs.lua1
2 files changed, 10 insertions, 22 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index fb4de9570..a399ffccc 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -38,15 +38,11 @@ local theme = require("theme/theme")
local config = require("project/config")
local project = require("project/project")
local localcache = require("cache/localcache")
---local profiler = require("base/profiler")
-- init the option menu
local menu =
{
- -- title
title = "${bright}xmake v" .. _VERSION .. ", A cross-platform build utility based on Lua${clear}"
-
- -- copyright
, copyright = "Copyright (C) 2015-present Ruki Wang, ${underline}tboox.org${clear}, ${underline}xmake.io${clear}"
-- the tasks: xmake [task]
@@ -63,33 +59,17 @@ local menu =
-- show help and version info
function main._show_help()
-
- -- show help
if option.get("help") then
-
- -- print menu
option.show_menu(option.taskname())
-
- -- ok
return true
-
- -- show version
elseif option.get("version") then
-
- -- show title
if menu.title then
utils.cprint(menu.title)
end
-
- -- show copyright
if menu.copyright then
utils.cprint(menu.copyright)
end
-
- -- show logo
option.show_logo()
-
- -- ok
return true
end
end
@@ -260,7 +240,12 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
end
-- start profiling
- -- profiler:start()
+ local profiler
+ local profile_mode = os.getenv("XMAKE_PROFILE")
+ if profile_mode then
+ profiler = require("base/profiler")
+ profiler:start(profile_mode)
+ end
-- show help?
if main._show_help() then
@@ -300,7 +285,9 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
end
-- stop profiling
- -- profiler:stop()
+ if profiler then
+ profiler:stop()
+ end
-- exit normally
return main._exit()
diff --git a/xmake/plugins/show/lists/envs.lua b/xmake/plugins/show/lists/envs.lua
index f0ce9030a..4092901fa 100644
--- a/xmake/plugins/show/lists/envs.lua
+++ b/xmake/plugins/show/lists/envs.lua
@@ -36,6 +36,7 @@ function main()
XMAKE_RAMDIR = {"Set the ramdisk directory.", os.getenv("XMAKE_RAMDIR")},
XMAKE_RCFILES = {"Set the runtime configuration files.", path.joinenv(project.rcfiles())},
XMAKE_TMPDIR = {"Set the temporary directory.", os.tmpdir()},
+ XMAKE_PROFILE = {"Start profiler, e.g. perf, trace.", os.getenv("XMAKE_PROFILE")},
XMAKE_PKG_CACHEDIR = {"Set the cache directory of packages.", os.getenv("XMAKE_PKG_CACHEDIR")},
XMAKE_PKG_INSTALLDIR = {"Set the install directory of packages.", os.getenv("XMAKE_PACKAGEDIR")}}
local width = 24