summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-05-15 00:23:38 +0800
committerruki <[email protected]>2018-05-14 20:21:49 +0800
commitcc2c840795a7472c485b806f5bffbeb8b11c4063 (patch)
treea5fd3affac54acfacc1dc0c317205125b6e4c961
parent9bbbe1dda368c67263a127bd292c455006db6f36 (diff)
add file values to target
-rw-r--r--tests/projects/wdk/kmdf/msdsm/xmake.lua6
-rw-r--r--xmake/core/project/target.lua24
-rw-r--r--xmake/core/project/template.lua2
-rw-r--r--xmake/rules/wdk/man/xmake.lua10
-rw-r--r--xmake/rules/wdk/mc/xmake.lua4
-rw-r--r--xmake/rules/wdk/mof/xmake.lua3
-rw-r--r--xmake/rules/wdk/tracewpp/xmake.lua2
7 files changed, 39 insertions, 12 deletions
diff --git a/tests/projects/wdk/kmdf/msdsm/xmake.lua b/tests/projects/wdk/kmdf/msdsm/xmake.lua
index b706a9daf..65a861fc1 100644
--- a/tests/projects/wdk/kmdf/msdsm/xmake.lua
+++ b/tests/projects/wdk/kmdf/msdsm/xmake.lua
@@ -13,5 +13,9 @@ target("msdsm")
-- add files
add_files("*.c", {rule = "wdk.tracewpp"})
- add_files("*.mof", "*.rc", "*.inf")
+ add_files("*.rc", "*.inf")
+ add_files("*.mof|msdsm.mof")
+
+ -- add file msdsm.mof and modify default wdk.mof.header for this file
+ add_files("msdsm.mof", {values = {wdk_mof_header = "msdsmwmi.h"}})
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 1452413d7..578b3f0f3 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -249,8 +249,28 @@ function target:data_add(name, data)
end
-- get values
-function target:values(name)
- return self:get("values." .. name)
+function target:values(name, sourcefile)
+
+ -- get values from the source file first
+ local values = {}
+ if sourcefile then
+ local fileconfig = self:fileconfig(sourcefile)
+ if fileconfig then
+ local filevalues = fileconfig.values
+ if filevalues then
+ -- we use '_' to simplify setting, for example:
+ --
+ -- add_files("xxx.mof", {values = {wdk_mof_header = "xxx.h"}})
+ -- add_files("xxx.mof", {values = {["wdk.mof.header"] = "xxx.h"}})
+ --
+ table.join2(values, filevalues[name] or filevalues[name:gsub("%.", "_")])
+ end
+ end
+ end
+
+ -- get values from target
+ table.join2(values, self:get("values." .. name))
+ return #values > 0 and table.unwrap(values) or nil
end
-- set values
diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua
index e72209523..c21e5c869 100644
--- a/xmake/core/project/template.lua
+++ b/xmake/core/project/template.lua
@@ -280,6 +280,7 @@ function template.create(language, templateid, targetname)
if os.isfile(projectfile) then
local file = io.open("xmake.lua", "a+")
if file then
+ file:print("")
file:print(template.faq())
file:close()
end
@@ -292,6 +293,7 @@ end
-- get FAQ
function template.faq()
return [[
+--
-- FAQ
--
-- You can enter the project directory firstly before building project.
diff --git a/xmake/rules/wdk/man/xmake.lua b/xmake/rules/wdk/man/xmake.lua
index 76dd493a4..8158fa610 100644
--- a/xmake/rules/wdk/man/xmake.lua
+++ b/xmake/rules/wdk/man/xmake.lua
@@ -66,7 +66,7 @@ rule("wdk.man")
-- init args
local args = {sourcefile}
- local flags = target:values("wdk.man.flags")
+ local flags = target:values("wdk.man.flags", sourcefile)
if flags then
table.join2(args, flags)
end
@@ -75,7 +75,7 @@ rule("wdk.man")
target:add("includedirs", outputdir)
-- add header file
- local header = target:values("wdk.man.header")
+ local header = target:values("wdk.man.header", sourcefile)
local headerfile = header and path.join(outputdir, header) or nil
if headerfile then
table.insert(args, "-o")
@@ -86,14 +86,14 @@ rule("wdk.man")
end
-- add prefix
- local prefix = target:values("wdk.man.prefix")
+ local prefix = target:values("wdk.man.prefix", sourcefile)
if prefix then
table.insert(args, "-prefix")
table.insert(args, prefix)
end
-- add counter header file
- local counter_header = target:values("wdk.man.counter_header")
+ local counter_header = target:values("wdk.man.counter_header", sourcefile)
local counter_headerfile = counter_header and path.join(outputdir, counter_header) or nil
if counter_headerfile then
table.insert(args, "-ch")
@@ -102,7 +102,7 @@ rule("wdk.man")
end
-- add resource file
- local resource = target:values("wdk.man.resource")
+ local resource = target:values("wdk.man.resource", sourcefile)
local resourcefile = resource and path.join(outputdir, resource) or nil
if resourcefile then
table.insert(args, "-rc")
diff --git a/xmake/rules/wdk/mc/xmake.lua b/xmake/rules/wdk/mc/xmake.lua
index a3550cedd..7f517e167 100644
--- a/xmake/rules/wdk/mc/xmake.lua
+++ b/xmake/rules/wdk/mc/xmake.lua
@@ -66,7 +66,7 @@ rule("wdk.mc")
-- init args
local args = {}
- local flags = target:values("wdk.mc.flags")
+ local flags = target:values("wdk.mc.flags", sourcefile)
if flags then
table.join2(args, flags)
end
@@ -80,7 +80,7 @@ rule("wdk.mc")
target:add("includedirs", outputdir)
-- add header file
- local header = target:values("wdk.mc.header")
+ local header = target:values("wdk.mc.header", sourcefile)
local headerfile = header and path.join(outputdir, header) or nil
if headerfile then
table.insert(args, "-z")
diff --git a/xmake/rules/wdk/mof/xmake.lua b/xmake/rules/wdk/mof/xmake.lua
index 5975cb077..422f875f8 100644
--- a/xmake/rules/wdk/mof/xmake.lua
+++ b/xmake/rules/wdk/mof/xmake.lua
@@ -82,7 +82,8 @@ rule("wdk.mof")
target:add("includedirs", outputdir)
-- get header file
- local headerfile = path.join(outputdir, path.basename(sourcefile) .. ".h")
+ local header = target:values("wdk.mof.header", sourcefile)
+ local headerfile = path.join(outputdir, header and header or (path.basename(sourcefile) .. ".h"))
-- get some temporary file
local sourcefile_mof = path.join(outputdir, path.filename(sourcefile))
diff --git a/xmake/rules/wdk/tracewpp/xmake.lua b/xmake/rules/wdk/tracewpp/xmake.lua
index 38e538a00..382669584 100644
--- a/xmake/rules/wdk/tracewpp/xmake.lua
+++ b/xmake/rules/wdk/tracewpp/xmake.lua
@@ -76,7 +76,7 @@ rule("wdk.tracewpp")
table.insert(args, "-km")
table.insert(args, "-gen:{km-WdfDefault.tpl}*.tmh")
end
- local flags = target:values("wdk.tracewpp.flags")
+ local flags = target:values("wdk.tracewpp.flags", sourcefile)
if flags then
table.join2(args, flags)
end