@@ -38,8 +38,7 @@ function _winver_libdir(winver)
38
38
return vervals [winver ]
39
39
end
40
40
41
- -- load for umdf environment
42
- function umdf (target )
41
+ function _base (target , mode )
43
42
44
43
-- get wdk
45
44
local wdk = target :data (" wdk" )
@@ -48,7 +47,8 @@ function umdf(target)
48
47
local arch = config .arch ()
49
48
50
49
-- add definitions
51
- local umdfver = wdk .umdfver :split (' %.' )
50
+ local ver = mode == " um" and wdk .umdfver or wdk .kmdfver
51
+ local ver_split = ver :split (' %.' )
52
52
if arch == " x64" then
53
53
target :add (" defines" , " _WIN64" , " _AMD64_" , " AMD64" )
54
54
else
@@ -57,16 +57,27 @@ function umdf(target)
57
57
target :add (" defines" , " STD_CALL" )
58
58
target :add (" cxflags" , " -Gz" , {force = true })
59
59
end
60
- target :add (" defines" , " UMDF_VERSION_MAJOR=" .. umdfver [1 ], " UMDF_VERSION_MINOR=" .. umdfver [2 ], " UMDF_USING_NTSTATUS" )
60
+
61
+ local prefix = mode == " um" and " UM" or " KM"
62
+ target :add (" defines" , prefix .. " DF_VERSION_MAJOR=" .. ver_split [1 ], prefix .. " DF_VERSION_MINOR=" .. ver_split [2 ], prefix .. " DF_USING_NTSTATUS" )
61
63
target :add (" defines" , " WIN32_LEAN_AND_MEAN=1" , " WINNT=1" , " _WINDLL" )
62
64
63
65
-- add include directories
64
- target :add (" includedirs " , path .join (wdk .includedir , wdk .sdkver , " um " ))
65
- target :add (" includedirs " , path .join (wdk .includedir , " wdf" , " umdf " , wdk . umdfver ))
66
+ target :add (" sysincludedirs " , path .join (wdk .includedir , wdk .sdkver , mode ))
67
+ target :add (" sysincludedirs " , path .join (wdk .includedir , " wdf" , mode .. " df " , ver ))
66
68
67
69
-- add link directories
68
- target :add (" linkdirs" , path .join (wdk .libdir , wdk .sdkver , " um" , arch ))
69
- target :add (" linkdirs" , path .join (wdk .libdir , " wdf" , " umdf" , arch , wdk .umdfver ))
70
+ target :add (" linkdirs" , path .join (wdk .libdir , wdk .sdkver , mode , arch ))
71
+ local p = path .join (wdk .libdir , " wdf" , mode .. " df" , arch , ver )
72
+ if os .isdir (p ) then
73
+ target :add (" linkdirs" , p )
74
+ end
75
+ end
76
+
77
+ -- load for umdf environment
78
+ function umdf (target )
79
+
80
+ _base (target , " um" )
70
81
end
71
82
72
83
-- load for kmdf environment
@@ -80,69 +91,23 @@ function kmdf(target)
80
91
81
92
-- add definitions
82
93
local winver = target :values (" wdk.env.winver" ) or config .get (" wdk_winver" )
83
- local kmdfver = wdk .kmdfver :split (' %.' )
84
- if arch == " x64" then
85
- target :add (" defines" , " _WIN64" , " _AMD64_" , " AMD64" )
86
- else
87
- target :add (" defines" , " _X86_=1" , " i386=1" )
88
- target :add (" defines" , " DEPRECATE_DDK_FUNCTIONS=1" , " MSC_NOOPT" , " _ATL_NO_WIN_SUPPORT" )
89
- target :add (" defines" , " STD_CALL" )
90
- target :add (" cxflags" , " -Gz" , {force = true })
91
- end
92
- target :add (" defines" , " KMDF_VERSION_MAJOR=" .. kmdfver [1 ], " KMDF_VERSION_MINOR=" .. kmdfver [2 ], " KMDF_USING_NTSTATUS" )
93
- target :add (" defines" , " WIN32_LEAN_AND_MEAN=1" , " WINNT=1" , " _WINDLL" )
94
+
95
+ _base (target , " km" )
94
96
95
97
-- add include directories
96
- target :add (" includedirs" , path .join (wdk .includedir , wdk .sdkver , " km" ))
97
98
if target :rule (" wdk.driver" ) then
98
- target :add (" includedirs " , path .join (wdk .includedir , wdk .sdkver , " km" , " crt" ))
99
+ target :add (" sysincludedirs " , path .join (wdk .includedir , wdk .sdkver , " km" , " crt" ))
99
100
end
100
- target :add (" includedirs" , path .join (wdk .includedir , " wdf" , " kmdf" , wdk .kmdfver ))
101
101
102
102
-- add link directories
103
103
local libdirver = _winver_libdir (winver )
104
104
if libdirver then
105
105
target :add (" linkdirs" , path .join (wdk .libdir , libdirver , " km" , arch ))
106
106
end
107
- target :add (" linkdirs" , path .join (wdk .libdir , wdk .sdkver , " km" , arch ))
108
- target :add (" linkdirs" , path .join (wdk .libdir , " wdf" , " kmdf" , arch , wdk .kmdfver ))
109
107
end
110
108
111
109
-- load for wdm environment
112
110
function wdm (target )
113
111
114
- -- get wdk
115
- local wdk = target :data (" wdk" )
116
-
117
- -- get arch
118
- local arch = config .arch ()
119
-
120
- -- add definitions
121
- local winver = target :values (" wdk.env.winver" ) or config .get (" wdk_winver" )
122
- local kmdfver = wdk .kmdfver :split (' %.' )
123
- if arch == " x64" then
124
- target :add (" defines" , " _WIN64" , " _AMD64_" , " AMD64" )
125
- else
126
- target :add (" defines" , " _X86_=1" , " i386=1" )
127
- target :add (" defines" , " DEPRECATE_DDK_FUNCTIONS=1" , " MSC_NOOPT" , " _ATL_NO_WIN_SUPPORT" )
128
- target :add (" defines" , " STD_CALL" )
129
- target :add (" cxflags" , " -Gz" , {force = true })
130
- end
131
- target :add (" defines" , " KMDF_VERSION_MAJOR=" .. kmdfver [1 ], " KMDF_VERSION_MINOR=" .. kmdfver [2 ], " KMDF_USING_NTSTATUS" )
132
- target :add (" defines" , " WIN32_LEAN_AND_MEAN=1" , " WINNT=1" , " _WINDLL" )
133
-
134
- -- add include directories
135
- target :add (" includedirs" , path .join (wdk .includedir , wdk .sdkver , " km" ))
136
- if target :rule (" wdk.driver" ) then
137
- target :add (" includedirs" , path .join (wdk .includedir , wdk .sdkver , " km" , " crt" ))
138
- end
139
- target :add (" includedirs" , path .join (wdk .includedir , " wdf" , " kmdf" , wdk .kmdfver ))
140
-
141
- -- add link directories
142
- local libdirver = _winver_libdir (winver )
143
- if libdirver then
144
- target :add (" linkdirs" , path .join (wdk .libdir , libdirver , " km" , arch ))
145
- end
146
- target :add (" linkdirs" , path .join (wdk .libdir , wdk .sdkver , " km" , arch ))
147
- target :add (" linkdirs" , path .join (wdk .libdir , " wdf" , " kmdf" , arch , wdk .kmdfver ))
112
+ kmdf (target )
148
113
end
0 commit comments