diff options
| author | ruki <[email protected]> | 2017-10-13 00:34:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-10-12 21:25:56 +0800 |
| commit | b8c25ec5b6d445464fa9c2e5dd33c5a640b5bcd4 (patch) | |
| tree | 39f84cb332f8465b54cb36f6e20e666463039f2a /xmake/plugins/macro/main.lua | |
| parent | 62fe8c95b363434e3c9fe109f7bdd7e1af41c2eb (diff) | |
add xmake macro ..
Diffstat (limited to 'xmake/plugins/macro/main.lua')
| -rw-r--r-- | xmake/plugins/macro/main.lua | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/xmake/plugins/macro/main.lua b/xmake/plugins/macro/main.lua index 662ed2a0c..0e144f823 100644 --- a/xmake/plugins/macro/main.lua +++ b/xmake/plugins/macro/main.lua @@ -288,16 +288,48 @@ end -- run macro function _run(macroname) + -- run last command? + if macroname == ".." then + + -- enter local history + history.enter("local.history") + + -- load the history: cmdlines + local cmdlines = history.load("cmdlines") + + -- get the last command + local lastcmd = nil + if cmdlines then + local total = #cmdlines + local index = total + while index ~= 0 do + + -- ignore "xmake m .." and "xmake macro .." + local cmdline = cmdlines[index] + if not cmdline:startswith("__macro_") and not cmdline:find("xmake%s+macro%s*") and not cmdline:find("xmake%s+m%s*") then + lastcmd = cmdline + break + end + + -- the previous line + index = index - 1 + end + end + + -- run the last command + if lastcmd then + os.exec(lastcmd) + end + return + end + -- is anonymous? if macroname == '.' then macroname = "anonymous" end - -- load macro - local macro = import(macroname, {rootdir = _directory(macroname)}) - -- run macro - macro.main(option.get("arguments") or {}) + import(macroname, {rootdir = _directory(macroname), anonymous = true})(option.get("arguments") or {}) end -- main |
