summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-05-01 00:41:35 +0800
committerruki <[email protected]>2018-04-30 22:09:31 +0800
commit594ae238861f5fe2b59808ef834e2910dbe39f8e (patch)
tree1c5f00f2e48a97a01da2bdcf608762fb1e967e9f
parentb15a22b22a3b9a530f50e67c6698c0819671ff23 (diff)
build inf file
-rw-r--r--tests/projects/wdk/kmdf/ioctl/xmake.lua1
-rw-r--r--tests/projects/wdk/umdf/echo/xmake.lua1
-rw-r--r--xmake/core/base/os.lua31
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua2
-rw-r--r--xmake/core/sandbox/modules/os.lua16
-rw-r--r--xmake/modules/privilege/sudo.lua24
-rw-r--r--xmake/rules/wdk/xmake.lua51
7 files changed, 91 insertions, 35 deletions
diff --git a/tests/projects/wdk/kmdf/ioctl/xmake.lua b/tests/projects/wdk/kmdf/ioctl/xmake.lua
index 44ff872d7..3ee226d17 100644
--- a/tests/projects/wdk/kmdf/ioctl/xmake.lua
+++ b/tests/projects/wdk/kmdf/ioctl/xmake.lua
@@ -22,4 +22,5 @@ target("app")
-- add files
add_files("exe/*.c")
+ add_files("exe/*.inf")
diff --git a/tests/projects/wdk/umdf/echo/xmake.lua b/tests/projects/wdk/umdf/echo/xmake.lua
index 143b3491a..45ec8ec9d 100644
--- a/tests/projects/wdk/umdf/echo/xmake.lua
+++ b/tests/projects/wdk/umdf/echo/xmake.lua
@@ -13,6 +13,7 @@ target("echo")
-- add files
add_files("driver/*.c")
+ add_files("driver/*.inx")
-- add includedirs
add_includedirs("exe")
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index a3b66b674..679ac50fa 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -500,13 +500,13 @@ function os.run(cmd)
end
-- run command with arguments list
-function os.runv(program, argv)
+function os.runv(program, argv, opt)
-- make temporary log file
local log = os.tmpfile()
-- execute it
- local ok = os.execv(program, argv, log, log)
+ local ok = os.execv(program, argv, table.join(opt or {}, {stdout = log, stderr = log}))
if ok ~= 0 then
-- make errors
@@ -543,18 +543,29 @@ function os.exec(cmd, outfile, errfile)
end
-- run it
- return os.execv(argv[1], table.slice(argv, 2), outfile, errfile)
+ return os.execv(argv[1], table.slice(argv, 2), {stdout = outfile, stderr = errfile})
end
-- execute command with arguments list
--
--- program: "clang", "xcrun -sdk macosx clang", "~/dir/test\ xxx/clang"
--- filename: "clang", "xcrun"", "~/dir/test\ xxx/clang"
+-- @param program "clang", "xcrun -sdk macosx clang", "~/dir/test\ xxx/clang"
+-- filename "clang", "xcrun"", "~/dir/test\ xxx/clang"
+-- @param argv the arguments
+-- @param opt the option, .e.g {wildcards = false, stdout = outfile, stderr = errfile}
--
-function os.execv(program, argv, outfile, errfile)
+function os.execv(program, argv, opt)
+
+ -- init options
+ opt = opt or {}
+
+ -- enable wildcards? default enabled
+ local wildcards = opt.wildcards
+ if wildcards == nil then
+ wildcards = true
+ end
-- init arguments
- local args = os.argw(argv)
+ local args = wildcards and os.argw(argv) or argv
-- is not executable program file?
local filename = program
@@ -570,7 +581,7 @@ function os.execv(program, argv, outfile, errfile)
-- open command
local ok = -1
- local proc = process.openv(filename, args, outfile, errfile)
+ local proc = process.openv(filename, args, opt.stdout, opt.stderr)
if proc ~= nil then
-- wait process
@@ -623,14 +634,14 @@ function os.iorun(cmd)
end
-- run command with arguments and return output and error data
-function os.iorunv(program, argv)
+function os.iorunv(program, argv, opt)
-- make temporary output and error file
local outfile = os.tmpfile()
local errfile = os.tmpfile()
-- run command
- local ok = os.execv(program, argv, outfile, errfile)
+ local ok = os.execv(program, argv, table.join(opt or {}, {stdout = outfile, stderr = errfile}))
-- get output and error data
local outdata = io.readfile(outfile)
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index 954cdc315..1e5d8a3dd 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -45,7 +45,7 @@ function sandbox_lib_detect_find_program._check(program, check)
-- no check script? attempt to run it directly
if not check then
- return 0 == os.execv(program, {"--version"}, os.nuldev(), os.nuldev())
+ return 0 == os.execv(program, {"--version"}, {stdout = os.nuldev(), stderr = os.nuldev()})
end
-- check it
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 43b12bca8..77e55450f 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -264,13 +264,13 @@ function sandbox_os.run(cmd, ...)
end
-- quietly run command with arguments list
-function sandbox_os.runv(program, argv)
+function sandbox_os.runv(program, argv, opt)
-- make program
program = vformat(program)
-- run it
- local ok, errors = os.runv(program, argv)
+ local ok, errors = os.runv(program, argv, opt)
if not ok then
os.raise(errors)
end
@@ -289,7 +289,7 @@ function sandbox_os.vrun(cmd, ...)
end
-- quietly run command with arguments list and echo verbose info if [-v|--verbose] option is enabled
-function sandbox_os.vrunv(program, argv)
+function sandbox_os.vrunv(program, argv, opt)
-- echo command
if option.get("verbose") then
@@ -297,7 +297,7 @@ function sandbox_os.vrunv(program, argv)
end
-- run it
- utils.ifelse(option.get("verbose"), sandbox_os.execv, sandbox_os.runv)(program, argv)
+ utils.ifelse(option.get("verbose"), sandbox_os.execv, sandbox_os.runv)(program, argv, opt)
end
-- run command and return output and error data
@@ -321,13 +321,13 @@ function sandbox_os.iorun(cmd, ...)
end
-- run command and return output and error data
-function sandbox_os.iorunv(program, argv)
+function sandbox_os.iorunv(program, argv, opt)
-- make program
program = vformat(program)
-- run it
- local ok, outdata, errdata = os.iorunv(program, argv)
+ local ok, outdata, errdata = os.iorunv(program, argv, opt)
if not ok then
local errors = errdata or ""
if #errors:trim() == 0 then
@@ -354,7 +354,7 @@ function sandbox_os.exec(cmd, ...)
end
-- execute command with arguments list
-function sandbox_os.execv(program, argv)
+function sandbox_os.execv(program, argv, opt)
-- make program
program = vformat(program)
@@ -374,7 +374,7 @@ function sandbox_os.execv(program, argv)
io.flush()
-- run it
- local ok = os.execv(program, argv)
+ local ok = os.execv(program, argv, opt)
if ok ~= 0 then
if argv ~= nil then
os.raise("execv(%s %s) failed(%d)!", program, table.concat(argv, ' '), ok)
diff --git a/xmake/modules/privilege/sudo.lua b/xmake/modules/privilege/sudo.lua
index 78ab1575c..bd53ff187 100644
--- a/xmake/modules/privilege/sudo.lua
+++ b/xmake/modules/privilege/sudo.lua
@@ -60,14 +60,14 @@ end
-- .e.g
-- _sudov(os.runv, {"echo", "hello xmake!"})
--
-function _sudov(runner, program, argv)
+function _sudov(runner, program, argv, opt)
-- find sudo
local sudo = find_sudo()
assert(sudo, "sudo not found!")
-- run it with administrator permission and preserve parent environment
- runner(sudo, table.join(_envars(), program, argv))
+ runner(sudo, table.join(_envars(), program, argv), opt)
end
-- sudo run lua script with administrator permission and arguments list
@@ -103,8 +103,8 @@ function run(cmd, ...)
end
-- sudo run command with arguments list
-function runv(program, argv)
- return _sudov(os.run, program, argv)
+function runv(program, argv, opt)
+ return _sudov(os.run, program, argv, opt)
end
-- sudo quietly run command and echo verbose info if [-v|--verbose] option is enabled
@@ -113,8 +113,8 @@ function vrun(cmd, ...)
end
-- sudo quietly run command with arguments list and echo verbose info if [-v|--verbose] option is enabled
-function vrunv(program, argv)
- return _sudov(os.vrunv, program, argv)
+function vrunv(program, argv, opt)
+ return _sudov(os.vrunv, program, argv, opt)
end
-- sudo run command and return output and error data
@@ -123,8 +123,8 @@ function iorun(cmd, ...)
end
-- sudo run command and return output and error data
-function iorunv(program, argv)
- return _sudov(os.iorunv, program, argv)
+function iorunv(program, argv, opt)
+ return _sudov(os.iorunv, program, argv, opt)
end
-- sudo execute command
@@ -133,13 +133,13 @@ function exec(cmd, ...)
end
-- sudo execute command with arguments list
-function execv(program, argv)
- return _sudov(os.execv, program, argv)
+function execv(program, argv, opt)
+ return _sudov(os.execv, program, argv, opt)
end
-- sudo run lua script
-function runl(luafile, luaargv)
- return _lua(os.runv, luafile, luaargv)
+function runl(luafile, luaargv, opt)
+ return _lua(os.runv, luafile, luaargv, opt)
end
-- sudo quietly run lua script and echo verbose info if [-v|--verbose] option is enabled
diff --git a/xmake/rules/wdk/xmake.lua b/xmake/rules/wdk/xmake.lua
index 21aaae2cb..9344fbbcb 100644
--- a/xmake/rules/wdk/xmake.lua
+++ b/xmake/rules/wdk/xmake.lua
@@ -41,11 +41,54 @@ rule("wdk.env")
target:data_set("wdk.cleanfiles", nil)
end)
+-- define rule: *.inf
+rule("wdk.inf")
+
+ -- add rule: wdk environment
+ add_deps("wdk.env")
+
+ -- set extensions
+ set_extensions(".inf", ".inx")
+
+ -- on load
+ on_load(function (target)
+
+ -- imports
+ import("core.project.config")
+
+ -- get arch
+ local arch = assert(config.arch(), "arch not found!")
+
+ -- get stampinf
+ local stampinf = path.join(target:data("wdk").bindir, arch, is_host("windows") and "stampinf.exe" or "stampinf")
+ assert(stampinf and os.isexec(stampinf), "stampinf not found!")
+
+ -- save uic
+ target:data_set("wdk.stampinf", stampinf)
+ end)
+
+ -- on build file
+ on_build_file(function (target, sourcefile)
+
+ -- copy file to target directory
+ local targetfile = path.join(target:targetdir(), path.basename(sourcefile) .. ".inf")
+ os.cp(sourcefile, targetfile)
+
+ -- get stampinf
+ local stampinf = target:data("wdk.stampinf")
+
+ -- update the timestamp
+ os.vrunv(stampinf, {"-d", "*", "-a", "arm64", "-v", "*", "-f", targetfile}, {wildcards = false})
+
+ -- add clean files
+ target:data_add("wdk.cleanfiles", targetfile)
+ end)
+
-- define rule: umdf driver
rule("wdk.umdf.driver")
-- add rules
- add_deps("wdk.env")
+ add_deps("wdk.inf")
-- on load
on_load(function (target)
@@ -56,7 +99,7 @@ rule("wdk.umdf.driver")
rule("wdk.umdf.binary")
-- add rules
- add_deps("wdk.env")
+ add_deps("wdk.inf")
-- on load
on_load(function (target)
@@ -67,7 +110,7 @@ rule("wdk.umdf.binary")
rule("wdk.kmdf.driver")
-- add rules
- add_deps("wdk.env")
+ add_deps("wdk.inf")
-- on load
on_load(function (target)
@@ -78,7 +121,7 @@ rule("wdk.kmdf.driver")
rule("wdk.kmdf.binary")
-- add rules
- add_deps("wdk.env")
+ add_deps("wdk.inf")
-- on load
on_load(function (target)