summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2018-05-12 22:18:30 +0800
committerruki <[email protected]>2018-05-12 22:18:30 +0800
commit0d8e537bc562c39695de25371ba6e8a0adeac5dc (patch)
tree688df5b9753d765fa43af42f36133501d9591ce0 /xmake/rules
parent166a68fd2868db1cea82bfe2e3172d0ca1bd0ae6 (diff)
add wdk.mc rule and serial tests
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/wdk/inf/xmake.lua81
-rw-r--r--xmake/rules/wdk/mc/xmake.lua120
-rw-r--r--xmake/rules/wdk/xmake.lua8
3 files changed, 180 insertions, 29 deletions
diff --git a/xmake/rules/wdk/inf/xmake.lua b/xmake/rules/wdk/inf/xmake.lua
index 3cec2660b..d612e51ea 100644
--- a/xmake/rules/wdk/inf/xmake.lua
+++ b/xmake/rules/wdk/inf/xmake.lua
@@ -22,14 +22,14 @@
-- @file xmake.lua
--
--- define rule: *.inf
-rule("wdk.inf")
+-- define rule: *.mc
+rule("wdk.mc")
-- add rule: wdk environment
add_deps("wdk.env")
-- set extensions
- set_extensions(".inf", ".inx")
+ set_extensions(".mc")
-- on load
on_load(function (target)
@@ -40,50 +40,81 @@ rule("wdk.inf")
-- 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!")
+ -- get mc
+ local mc = path.join(target:data("wdk").bindir, arch, is_host("windows") and "mc.exe" or "mc")
+ assert(mc and os.isexec(mc), "mc not found!")
- -- save uic
- target:data_set("wdk.stampinf", stampinf)
+ -- save mc
+ target:data_set("wdk.mc", mc)
+
+ -- save output directory
+ target:data_set("wdk.mc.outputdir", path.join(config.buildir(), ".wdk", "mc", config.get("mode") or "generic", config.get("arch") or os.arch(), target:name()))
end)
- -- on build file
- on_build_file(function (target, sourcefile, opt)
+ -- before build file
+ before_build_file(function (target, sourcefile, opt)
-- imports
import("core.base.option")
import("core.project.depend")
- -- the target file
- local targetfile = path.join(target:targetdir(), path.basename(sourcefile) .. ".inf")
+ -- get mc
+ local mc = target:data("wdk.mc")
+
+ -- get output directory
+ local outputdir = target:data("wdk.mc.outputdir")
+
+ -- init args
+ local args = {}
+ local flags = target:values("wdk.mc.flags")
+ if flags then
+ table.join2(args, flags)
+ end
+ table.insert(args, "-h")
+ table.insert(args, outputdir)
+ table.insert(args, "-r")
+ table.insert(args, outputdir)
+
+ -- add header file
+ local header = target:values("wdk.mc.header")
+ local headerfile = header and path.join(outputdir, header) or nil
+ if headerfile then
+ table.insert(args, "-z")
+ table.insert(args, path.basename(headerfile))
+ target:data_add("wdk.cleanfiles", headerfile)
+ else
+ headerfile = path.join(outputdir, path.basename(sourcefile) .. ".h")
+ end
+
+ -- add source file
+ table.insert(args, sourcefile)
- -- add clean files
- target:data_add("wdk.cleanfiles", targetfile)
+ -- add includedirs
+ target:add("includedirs", outputdir)
-- need build this object?
- local dependfile = target:dependfile(targetfile)
+ local dependfile = target:dependfile(headerfile)
local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
- if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile)}) then
+ if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
-- trace progress info
if option.get("verbose") then
- cprint("${green}[%02d%%]:${dim} compiling.wdk.inf %s", opt.progress, sourcefile)
+ cprint("${green}[%02d%%]:${dim} compiling.wdk.mc %s", opt.progress, sourcefile)
else
- cprint("${green}[%02d%%]:${clear} compiling.wdk.inf %s", opt.progress, sourcefile)
+ cprint("${green}[%02d%%]:${clear} compiling.wdk.mc %s", opt.progress, sourcefile)
end
- -- get stampinf
- local stampinf = target:data("wdk.stampinf")
-
- -- update the timestamp
- os.cp(sourcefile, targetfile)
- os.vrunv(stampinf, {"-d", "*", "-a", is_arch("x64") and "arm64" or "x86", "-v", "*", "-f", targetfile}, {wildcards = false})
+ -- do message compile
+ if not os.isdir(outputdir) then
+ os.mkdir(outputdir)
+ end
+ os.vrunv(mc, args)
-- update files and values to the dependent file
- dependinfo.files = {sourcefile}
+ dependinfo.files = {sourcefile}
+ dependinfo.values = args
depend.save(dependinfo, dependfile)
end)
diff --git a/xmake/rules/wdk/mc/xmake.lua b/xmake/rules/wdk/mc/xmake.lua
new file mode 100644
index 000000000..3765bf151
--- /dev/null
+++ b/xmake/rules/wdk/mc/xmake.lua
@@ -0,0 +1,120 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define rule: *.mc
+rule("wdk.mc")
+
+ -- add rule: wdk environment
+ add_deps("wdk.env")
+
+ -- set extensions
+ set_extensions(".mc")
+
+ -- on load
+ on_load(function (target)
+
+ -- imports
+ import("core.project.config")
+
+ -- get arch
+ local arch = assert(config.arch(), "arch not found!")
+
+ -- get mc
+ local mc = path.join(target:data("wdk").bindir, arch, is_host("windows") and "mc.exe" or "mc")
+ assert(mc and os.isexec(mc), "mc not found!")
+
+ -- save mc
+ target:data_set("wdk.mc", mc)
+
+ -- save output directory
+ target:data_set("wdk.mc.outputdir", path.join(config.buildir(), ".wdk", "mc", config.get("mode") or "generic", config.get("arch") or os.arch(), target:name()))
+ end)
+
+ -- before build file
+ before_build_file(function (target, sourcefile, opt)
+
+ -- imports
+ import("core.base.option")
+ import("core.project.depend")
+
+ -- get mc
+ local mc = target:data("wdk.mc")
+
+ -- get output directory
+ local outputdir = target:data("wdk.mc.outputdir")
+
+ -- init args
+ local args = {}
+ local flags = target:values("wdk.mc.flags")
+ if flags then
+ table.join2(args, flags)
+ end
+ table.insert(args, "-h")
+ table.insert(args, outputdir)
+ table.insert(args, "-r")
+ table.insert(args, outputdir)
+ table.insert(args, sourcefile)
+
+ -- add includedirs
+ target:add("includedirs", outputdir)
+
+ -- add header file
+ local header = target:values("wdk.mc.header")
+ local headerfile = header and path.join(outputdir, header) or nil
+ if headerfile then
+ table.insert(args, "-z")
+ table.insert(args, path.basename(headerfile))
+ table.insert(args, "-e")
+ table.insert(args, path.extension(headerfile))
+ target:data_add("wdk.cleanfiles", headerfile)
+ else
+ headerfile = path.join(outputdir, path.basename(sourcefile) .. ".h")
+ end
+
+ -- need build this object?
+ local dependfile = target:dependfile(headerfile)
+ local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
+ return
+ end
+
+ -- trace progress info
+ if option.get("verbose") then
+ cprint("${green}[%02d%%]:${dim} compiling.wdk.mc %s", opt.progress, sourcefile)
+ else
+ cprint("${green}[%02d%%]:${clear} compiling.wdk.mc %s", opt.progress, sourcefile)
+ end
+
+ -- do message compile
+ if not os.isdir(outputdir) then
+ os.mkdir(outputdir)
+ end
+ os.vrunv(mc, args)
+
+ -- update files and values to the dependent file
+ dependinfo.files = {sourcefile}
+ dependinfo.values = args
+ depend.save(dependinfo, dependfile)
+ end)
+
diff --git a/xmake/rules/wdk/xmake.lua b/xmake/rules/wdk/xmake.lua
index 402cd1c64..931803f44 100644
--- a/xmake/rules/wdk/xmake.lua
+++ b/xmake/rules/wdk/xmake.lua
@@ -26,7 +26,7 @@
rule("wdk.umdf.driver")
-- add rules
- add_deps("wdk.inf", "wdk.man")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc")
-- on load
on_load(function (target)
@@ -37,7 +37,7 @@ rule("wdk.umdf.driver")
rule("wdk.umdf.binary")
-- add rules
- add_deps("wdk.inf", "wdk.man")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc")
-- on load
on_load(function (target)
@@ -48,7 +48,7 @@ rule("wdk.umdf.binary")
rule("wdk.kmdf.driver")
-- add rules
- add_deps("wdk.inf", "wdk.man")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc")
-- on load
on_load(function (target)
@@ -59,7 +59,7 @@ rule("wdk.kmdf.driver")
rule("wdk.kmdf.binary")
-- add rules
- add_deps("wdk.inf", "wdk.man")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc")
-- on load
on_load(function (target)