diff options
| author | ruki <[email protected]> | 2018-05-16 00:44:01 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-05-15 22:24:08 +0800 |
| commit | 0e7791da7d897a809ea3922ddc772d700a7b491e (patch) | |
| tree | a1909331956160b7464b73e79eb0ddfbb1f9b00d | |
| parent | 7fdf5ff81ea4c4fb95ec26a82cf353692cbb231d (diff) | |
improve wdk entry and fix build progress
| -rw-r--r-- | tests/projects/wdk/kmdf/msdsm/xmake.lua | 5 | ||||
| -rw-r--r-- | xmake/actions/build/kinds/object.lua | 21 | ||||
| -rw-r--r-- | xmake/rules/wdk/load.lua | 20 |
3 files changed, 32 insertions, 14 deletions
diff --git a/tests/projects/wdk/kmdf/msdsm/xmake.lua b/tests/projects/wdk/kmdf/msdsm/xmake.lua index 0e11a85e4..75f1c12ca 100644 --- a/tests/projects/wdk/kmdf/msdsm/xmake.lua +++ b/tests/projects/wdk/kmdf/msdsm/xmake.lua @@ -23,5 +23,8 @@ target("msdsm") set_pcheader("precomp.h") -- add links - add_links("mpio") + add_links("mpio", "ucrt") + + -- set entry + add_ldflags("-entry:GsDriverEntry", {force = true}) diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua index 8e56cd6a2..283f1ed90 100644 --- a/xmake/actions/build/kinds/object.lua +++ b/xmake/actions/build/kinds/object.lua @@ -246,6 +246,11 @@ function _build_files_with_rule(target, buildinfo, sourcebatch, jobs, suffix) -- do build files on_build_files(target, sourcebatch.sourcefiles, {progress = progress}) + + -- update source index + if not suffix then + _g.sourceindex = _g.sourceindex + #sourcebatch.sourcefiles + end else -- get the build file script local on_build_file = ruleinst:script("build_file" .. (suffix and ("_" .. suffix) or "")) @@ -264,20 +269,16 @@ function _build_files_with_rule(target, buildinfo, sourcebatch, jobs, suffix) progress = ((buildinfo.targetindex + (suffix == "before" and _g.sourceindex or _g.sourcecount) / _g.sourcecount) * 100 / buildinfo.targetcount) end - -- the source file - local sourcefile = sourcebatch.sourcefiles[index] - - -- do build file - on_build_file(target, sourcefile, {progress = progress}) + on_build_file(target, sourcebatch.sourcefiles[index], {progress = progress}) end, #sourcebatch.sourcefiles, jobs) - end - end - -- update object index - if not suffix then - _g.sourceindex = _g.sourceindex + #sourcebatch.sourcefiles + -- update source index + if not suffix then + _g.sourceindex = _g.sourceindex + #sourcebatch.sourcefiles + end + end end end diff --git a/xmake/rules/wdk/load.lua b/xmake/rules/wdk/load.lua index 5632b601c..7ea5d1aba 100644 --- a/xmake/rules/wdk/load.lua +++ b/xmake/rules/wdk/load.lua @@ -115,14 +115,28 @@ function kmdf_driver(target) target:add("linkdirs", path.join(wdk.libdir, "wdf", "kmdf", arch, wdk.kmdfver)) -- add links - target:add("links", "BufferOverflowFastFailK", "ntoskrnl", "hal", "wmilib", "WdfLdr", "WdfDriverEntry", "ntstrsafe", "wdmsec") + target:add("links", "BufferOverflowFastFailK", "ntoskrnl", "hal", "wmilib", "WdfLdr", "ntstrsafe", "wdmsec") -- compile as kernel driver target:add("cxflags", "-kernel", {force = true}) target:add("ldflags", "-kernel", "-driver", {force = true}) - -- set driver entry - target:add("ldflags", "-entry:FxDriverEntry", "-subsystem:native,10.00", {force = true}) + -- set subsystem: native, TODO 10.00 + target:add("ldflags", "-subsystem:native,10.00", {force = true}) + + -- set default driver entry if does not exist + local entry = false + for _, ldflag in ipairs(target:get("ldflags")) do + ldflag = ldflag:lower() + if ldflag:find("[/%-]entry:") then + entry = true + break + end + end + if not entry then + target:add("links", "WdfDriverEntry") + target:add("ldflags", "-entry:FxDriverEntry", {force = true}) + end end -- load for kmdf binary |
