summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-10 22:36:41 +0800
committerruki <[email protected]>2024-04-10 22:36:41 +0800
commit7e7b37e4f776e76d9a88b38f6419ff5c95923ef4 (patch)
tree61b1c3342adc6f0a627513f38b6fffd1f517e36c
parent86075cdc1f9e82e65a94d35dd2725acbf590cd97 (diff)
improve nmake
-rw-r--r--xmake/modules/package/tools/make.lua2
-rw-r--r--xmake/modules/package/tools/nmake.lua45
2 files changed, 22 insertions, 25 deletions
diff --git a/xmake/modules/package/tools/make.lua b/xmake/modules/package/tools/make.lua
index 7b172ed3f..055e40faf 100644
--- a/xmake/modules/package/tools/make.lua
+++ b/xmake/modules/package/tools/make.lua
@@ -116,8 +116,6 @@ end
-- build package
function build(package, configs, opt)
-
- -- init options
opt = opt or {}
-- pass configurations
diff --git a/xmake/modules/package/tools/nmake.lua b/xmake/modules/package/tools/nmake.lua
index c618531ce..db54b1c63 100644
--- a/xmake/modules/package/tools/nmake.lua
+++ b/xmake/modules/package/tools/nmake.lua
@@ -26,8 +26,8 @@ import("lib.detect.find_tool")
-- get msvc
function _get_msvc(package)
- local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()})
- assert(msvc:check(), "vs not found!") -- we need check vs envs if it has been not checked yet
+ local msvc = package:toolchain("msvc")
+ assert(msvc:check(), "vs not found!") -- we need to check vs envs if it has been not checked yet
return msvc
end
@@ -36,10 +36,21 @@ function buildenvs(package, opt)
return os.joinenvs(_get_msvc(package):runenvs())
end
+-- do make
+function make(package, argv, opt)
+ opt = opt or {}
+ local program
+ local runenvs = opt.envs or buildenvs(package)
+ local tool = find_tool("nmake", {envs = runenvs})
+ if tool then
+ program = tool.program
+ end
+ assert(program, "nmake not found!")
+ os.vrunv(program, argv or {}, {envs = runenvs, curdir = opt.curdir})
+end
+
-- build package
function build(package, configs, opt)
-
- -- pass configurations
opt = opt or {}
local argv = {}
if option.get("verbose") then
@@ -57,33 +68,21 @@ function build(package, configs, opt)
end
-- do build
- local runenvs = opt.envs or buildenvs(package, opt)
- local nmake = find_tool("nmake", {envs = runenvs})
- os.vrunv(nmake.program, argv, {envs = runenvs})
+ make(package, argv, opt)
end
-- install package
function install(package, configs, opt)
- -- pass configurations
+ -- do build
opt = opt or {}
+ build(package, configs, opt)
+
+ -- do install
local argv = {"install"}
if option.get("verbose") then
table.insert(argv, "VERBOSE=1")
+ table.insert(argv, "V=1")
end
- for name, value in pairs(configs) do
- value = tostring(value):trim()
- if value ~= "" then
- if type(name) == "number" then
- table.insert(argv, value)
- else
- table.insert(argv, name .. "=" .. value)
- end
- end
- end
-
- -- do install
- local runenvs = opt.envs or buildenvs(package, opt)
- local nmake = find_tool("nmake", {envs = runenvs})
- os.vrunv(nmake.program, argv, {envs = runenvs})
+ make(package, argv, opt)
end