1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
--!A cross-platform build utility based on Lua
--
-- Licensed 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-present, TBOOX Open Source Group.
--
-- @author ruki
-- @file load.lua
--
-- imports
import("core.project.config")
-- get version of the library sub-directory
function _winver_libdir(winver)
-- ignore the subname with '_xxx'
winver = (winver or ""):split('_')[1]
-- make defined values
local vervals =
{
win81 = "winv6.3"
, winblue = "winv6.3"
, win8 = "win8"
, win7 = "win7"
}
return vervals[winver]
end
-- load for umdf environment
function umdf(target)
-- get wdk
local wdk = target:data("wdk")
-- get arch
local arch = config.arch()
-- add definitions
local umdfver = wdk.umdfver:split('%.')
if arch == "x64" then
target:add("defines", "_WIN64", "_AMD64_", "AMD64")
else
target:add("defines", "_X86_=1", "i386=1")
target:add("defines", "DEPRECATE_DDK_FUNCTIONS=1", "MSC_NOOPT", "_ATL_NO_WIN_SUPPORT")
target:add("defines", "STD_CALL")
target:add("cxflags", "-Gz", {force = true})
end
target:add("defines", "UMDF_VERSION_MAJOR=" .. umdfver[1], "UMDF_VERSION_MINOR=" .. umdfver[2], "UMDF_USING_NTSTATUS")
target:add("defines", "WIN32_LEAN_AND_MEAN=1", "WINNT=1", "_WINDLL")
-- add include directories
target:add("includedirs", path.join(wdk.includedir, wdk.sdkver, "um"))
target:add("includedirs", path.join(wdk.includedir, "wdf", "umdf", wdk.umdfver))
-- add link directories
target:add("linkdirs", path.join(wdk.libdir, wdk.sdkver, "um", arch))
target:add("linkdirs", path.join(wdk.libdir, "wdf", "umdf", arch, wdk.umdfver))
end
-- load for kmdf environment
function kmdf(target)
-- get wdk
local wdk = target:data("wdk")
-- get arch
local arch = config.arch()
-- add definitions
local winver = target:values("wdk.env.winver") or config.get("wdk_winver")
local kmdfver = wdk.kmdfver:split('%.')
if arch == "x64" then
target:add("defines", "_WIN64", "_AMD64_", "AMD64")
else
target:add("defines", "_X86_=1", "i386=1")
target:add("defines", "DEPRECATE_DDK_FUNCTIONS=1", "MSC_NOOPT", "_ATL_NO_WIN_SUPPORT")
target:add("defines", "STD_CALL")
target:add("cxflags", "-Gz", {force = true})
end
target:add("defines", "KMDF_VERSION_MAJOR=" .. kmdfver[1], "KMDF_VERSION_MINOR=" .. kmdfver[2], "KMDF_USING_NTSTATUS")
target:add("defines", "WIN32_LEAN_AND_MEAN=1", "WINNT=1", "_WINDLL")
-- add include directories
target:add("includedirs", path.join(wdk.includedir, wdk.sdkver, "km"))
if target:rule("wdk.driver") then
target:add("includedirs", path.join(wdk.includedir, wdk.sdkver, "km", "crt"))
end
target:add("includedirs", path.join(wdk.includedir, "wdf", "kmdf", wdk.kmdfver))
-- add link directories
local libdirver = _winver_libdir(winver)
if libdirver then
target:add("linkdirs", path.join(wdk.libdir, libdirver, "km", arch))
end
target:add("linkdirs", path.join(wdk.libdir, wdk.sdkver, "km", arch))
target:add("linkdirs", path.join(wdk.libdir, "wdf", "kmdf", arch, wdk.kmdfver))
end
-- load for wdm environment
function wdm(target)
-- get wdk
local wdk = target:data("wdk")
-- get arch
local arch = config.arch()
-- add definitions
local winver = target:values("wdk.env.winver") or config.get("wdk_winver")
local kmdfver = wdk.kmdfver:split('%.')
if arch == "x64" then
target:add("defines", "_WIN64", "_AMD64_", "AMD64")
else
target:add("defines", "_X86_=1", "i386=1")
target:add("defines", "DEPRECATE_DDK_FUNCTIONS=1", "MSC_NOOPT", "_ATL_NO_WIN_SUPPORT")
target:add("defines", "STD_CALL")
target:add("cxflags", "-Gz", {force = true})
end
target:add("defines", "KMDF_VERSION_MAJOR=" .. kmdfver[1], "KMDF_VERSION_MINOR=" .. kmdfver[2], "KMDF_USING_NTSTATUS")
target:add("defines", "WIN32_LEAN_AND_MEAN=1", "WINNT=1", "_WINDLL")
-- add include directories
target:add("includedirs", path.join(wdk.includedir, wdk.sdkver, "km"))
if target:rule("wdk.driver") then
target:add("includedirs", path.join(wdk.includedir, wdk.sdkver, "km", "crt"))
end
target:add("includedirs", path.join(wdk.includedir, "wdf", "kmdf", wdk.kmdfver))
-- add link directories
local libdirver = _winver_libdir(winver)
if libdirver then
target:add("linkdirs", path.join(wdk.libdir, libdirver, "km", arch))
end
target:add("linkdirs", path.join(wdk.libdir, wdk.sdkver, "km", arch))
target:add("linkdirs", path.join(wdk.libdir, "wdf", "kmdf", arch, wdk.kmdfver))
end
|