summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/actions/package/main.lua2
-rw-r--r--xmake/rules/wdk/inf.lua89
-rw-r--r--xmake/rules/wdk/inf/xmake.lua2
-rw-r--r--xmake/rules/wdk/package/xmake.lua104
-rw-r--r--xmake/rules/wdk/tracewpp.lua124
-rw-r--r--xmake/rules/wdk/xmake.lua6
6 files changed, 109 insertions, 218 deletions
diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua
index b0d82800c..f8c63c7ed 100644
--- a/xmake/actions/package/main.lua
+++ b/xmake/actions/package/main.lua
@@ -35,7 +35,7 @@ import("core.platform.platform")
function _package_library(target)
-- the output directory
- local outputdir = option.get("outputdir") or config.get("buildir")
+ local outputdir = option.get("outputdir") or config.buildir()
-- the target name
local targetname = target:name()
diff --git a/xmake/rules/wdk/inf.lua b/xmake/rules/wdk/inf.lua
deleted file mode 100644
index 72b8581c3..000000000
--- a/xmake/rules/wdk/inf.lua
+++ /dev/null
@@ -1,89 +0,0 @@
---!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 inf.lua
---
-
--- 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, "stampinf.exe")
- 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, opt)
-
- -- imports
- import("core.base.option")
- import("core.project.depend")
-
- -- the target file
- local targetfile = path.join(target:targetdir(), path.basename(sourcefile) .. ".inf")
-
- -- add clean files
- target:data_add("wdk.cleanfiles", targetfile)
-
- -- need build this object?
- local dependfile = target:dependfile(targetfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
- if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile)}) then
- return
- end
-
- -- trace progress info
- if option.get("verbose") then
- cprint("${green}[%02d%%]:${dim} compiling.wdk.inf %s", opt.progress, sourcefile)
- else
- cprint("${green}[%02d%%]:${clear} compiling.wdk.inf %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})
-
- -- update files and values to the dependent file
- dependinfo.files = {sourcefile}
- depend.save(dependinfo, dependfile)
- end)
-
diff --git a/xmake/rules/wdk/inf/xmake.lua b/xmake/rules/wdk/inf/xmake.lua
index a9ab72212..60debf220 100644
--- a/xmake/rules/wdk/inf/xmake.lua
+++ b/xmake/rules/wdk/inf/xmake.lua
@@ -64,7 +64,7 @@ rule("wdk.inf")
-- add clean files
target:data_add("wdk.cleanfiles", targetfile)
- -- save this target file for signing (wdk.sign.* rules)
+ -- save this target file for signing (wdk.sign.*, wdk.package.* rules)
target:data_set("wdk.sign.inf", targetfile)
-- init args
diff --git a/xmake/rules/wdk/package/xmake.lua b/xmake/rules/wdk/package/xmake.lua
new file mode 100644
index 000000000..8629cc1a3
--- /dev/null
+++ b/xmake/rules/wdk/package/xmake.lua
@@ -0,0 +1,104 @@
+--!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: package *.cab
+rule("wdk.package.cab")
+
+ -- on package
+ on_package(function (target)
+
+ -- imports
+ import("core.base.option")
+ import("core.project.config")
+ import("lib.detect.find_program")
+
+ -- the output directory
+ local outputdir = path.join(option.get("outputdir") or config.buildir(), "drivers", target:name())
+ local mode = config.mode()
+ if mode then
+ outputdir = path.join(outputdir, mode)
+ end
+ local arch = config.arch()
+ if arch then
+ outputdir = path.join(outputdir, arch)
+ end
+
+ -- the package file
+ local packagefile = path.join(outputdir, target:name() .. ".cab")
+
+ -- the .ddf file
+ local ddfile = os.tmpfile(target:targetfile()) .. ".ddf"
+
+ -- add clean files
+ target:data_add("wdk.cleanfiles", ddfile)
+
+ -- trace progress info
+ if option.get("verbose") then
+ cprint("${dim magenta}packaging %s", packagefile)
+ else
+ cprint("${magenta}packaging %s", packagefile)
+ end
+
+ -- get makecab
+ local makecab = find_program("makecab", {check = "/?"})
+ assert(makecab, "makecab not found!")
+
+ -- make .ddf file
+ local file = io.open(ddfile, "w")
+ if file then
+ file:print("; %s.ddf", target:name())
+ file:print(";")
+ file:print(".OPTION EXPLICIT ; Generate errors")
+ file:print(".Set CabinetFileCountThreshold=0")
+ file:print(".Set FolderFileCountThreshold=0")
+ file:print(".Set FolderSizeThreshold=0")
+ file:print(".Set MaxCabinetSize=0")
+ file:print(".Set MaxDiskFileCount=0")
+ file:print(".Set MaxDiskSize=0")
+ file:print(".Set CompressionType=MSZIP")
+ file:print(".Set Cabinet=on")
+ file:print(".Set Compress=on")
+ file:print(";Specify file name for new cab file")
+ file:print(".Set CabinetNameTemplate=%s.cab", target:name())
+ file:print("; Specify the subdirectory for the files. ")
+ file:print("; Your cab file should not have files at the root level,")
+ file:print("; and each driver package must be in a separate subfolder.")
+ file:print(".Set DiskDirectoryTemplate=%s", outputdir)
+ file:print(";Specify files to be included in cab file")
+ local infile = target:data("wdk.sign.inf")
+ if infile and os.isfile(infile) then
+ file:print(path.absolute(infile))
+ end
+ file:print(path.absolute(target:targetfile()))
+ file:close()
+ end
+
+ -- make .cab
+ os.vrunv(makecab, {"/f", ddfile})
+
+ -- save this package file for signing (wdk.sign.* rules)
+ target:data_set("wdk.sign.cab", packagefile)
+ end)
+
+
diff --git a/xmake/rules/wdk/tracewpp.lua b/xmake/rules/wdk/tracewpp.lua
deleted file mode 100644
index c450a27e8..000000000
--- a/xmake/rules/wdk/tracewpp.lua
+++ /dev/null
@@ -1,124 +0,0 @@
---!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 tracewpp.lua
---
-
--- define rule: tracewpp
-rule("wdk.tracewpp")
-
- -- add rule: wdk environment
- add_deps("wdk.env")
-
- -- on load
- on_load(function (target)
-
- -- imports
- import("core.project.config")
-
- -- get wdk
- local wdk = target:data("wdk")
-
- -- get arch
- local arch = assert(config.arch(), "arch not found!")
-
- -- get tracewpp
- local tracewpp = path.join(wdk.bindir, arch, "tracewpp.exe")
- assert(tracewpp and os.isexec(tracewpp), "tracewpp not found!")
-
- -- save tracewpp
- target:data_set("wdk.tracewpp", tracewpp)
-
- -- save output directory
- target:data_set("wdk.tracewpp.outputdir", path.join(config.buildir(), ".wpp", config.get("mode") or "generic", config.get("arch") or os.arch(), target:name()))
-
- -- save config directory
- target:data_set("wdk.tracewpp.configdir", path.join(wdk.bindir, wdk.sdkver, "WppConfig", "Rev1"))
- end)
-
- -- before build file
- before_build_file(function (target, sourcefile, opt)
-
- -- imports
- import("core.base.option")
- import("core.project.depend")
-
- -- get tracewpp
- local tracewpp = target:data("wdk.tracewpp")
-
- -- get outputdir
- local outputdir = target:data("wdk.tracewpp.outputdir")
-
- -- get configdir
- local configdir = target:data("wdk.tracewpp.configdir")
-
- -- init args
- local args = {}
- if target:rule("wdk.kmdf.driver") then
- table.insert(args, "-km")
- table.insert(args, "-gen:{km-WdfDefault.tpl}*.tmh")
- end
- local flags = target:values("wdk.tracewpp.flags")
- if flags then
- table.join2(args, flags)
- end
- table.insert(args, "-cfgdir:" .. configdir)
- table.insert(args, "-odir:" .. outputdir)
- table.insert(args, sourcefile)
-
- -- add includedirs
- target:add("includedirs", outputdir)
-
- -- add clean files
- target:data_add("wdk.cleanfiles", outputdir)
-
- -- need build this object?
- local targetfile = path.join(outputdir, path.basename(sourcefile) .. ".tmh")
- local dependfile = target:dependfile(targetfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
- if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = args}) then
- return
- end
-
- -- trace progress info
- if option.get("verbose") then
- cprint("${green}[%02d%%]:${dim} compiling.wdk.tracewpp %s", opt.progress, sourcefile)
- else
- cprint("${green}[%02d%%]:${clear} compiling.wdk.tracewpp %s", opt.progress, sourcefile)
- end
-
- -- ensure the output directory
- if not os.isdir(outputdir) then
- os.mkdir(outputdir)
- end
-
- -- remove the previous target file first
- os.tryrm(targetfile)
-
- -- generate the *.tmh file
- os.vrunv(tracewpp, args, {wildcards = false})
-
- -- 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 fcbb1c9cc..97a851052 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", "wdk.mc", "wdk.mof")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.package.cab")
-- 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", "wdk.mc", "wdk.mof")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.package.cab")
-- on load
on_load(function (target)
@@ -86,7 +86,7 @@ rule("wdk.kmdf.binary")
rule("wdk.wdm.driver")
-- add rules
- add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof")
+ add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.package.cab")
-- on load
on_load(function (target)