@@ -6,19 +6,18 @@ import { __dirname } from './paths.js';
6
6
7
7
export default class Context {
8
8
buildDir = path . normalize ( __dirname + '\\..\\build\\' ) ;
9
- signDir = `${ this . buildDir } signdir\\` ;
10
9
11
- vcvarsCommunityPath = 'C:\\Program Files (x86) \\Microsoft Visual Studio\\2019 \\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat' ;
12
- vcvarsEnterprisePath = 'C:\\Program Files (x86) \\Microsoft Visual Studio\\2019 \\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat' ;
10
+ vcvarsCommunityPath = 'C:\\Program Files\\Microsoft Visual Studio\\2022 \\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat' ;
11
+ vcvarsEnterprisePath = 'C:\\Program Files\\Microsoft Visual Studio\\2022 \\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat' ;
13
12
vcPath = null ;
14
13
15
14
cmakeTplPath = path . normalize ( __dirname + '\\..\\templates\\CMakeLists.txt.tpl' ) ;
16
15
infTplPath = path . normalize ( __dirname + '\\..\\templates\\chamd.inf.tpl' ) ;
16
+ makeCatTplPath = path . normalize ( __dirname + '\\..\\templates\\makecat.cdf.tpl' ) ;
17
17
datTplPath = path . normalize ( __dirname + '\\..\\templates\\driver64.dat.tpl' ) ;
18
18
datPath = `${ this . buildDir } driver64.dat` ;
19
19
srcDir = path . normalize ( __dirname + '\\..\\src\\' ) ;
20
20
cmakeConfigPath = this . srcDir + 'CMakeLists.txt' ;
21
- inf2CatPath = "C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x86\\inf2cat.exe"
22
21
23
22
constructor ( driverName , distDir ) {
24
23
this . distDir = distDir ;
@@ -37,18 +36,16 @@ export default class Context {
37
36
this . vcPath = this . vcvarsEnterprisePath ;
38
37
}
39
38
40
- this . infPath = `${ this . buildDir } ${ this . driverName } .inf ` ;
39
+ this . makeCatPath = `${ this . buildDir } ${ this . driverName } .cdf ` ;
41
40
}
42
41
43
42
async all ( ) {
44
43
console . log ( `Generating ${ this . driverName } driver ...` ) ;
45
44
await this . purge ( ) ;
46
45
await this . generateCmakeFile ( ) ;
47
46
await this . compile ( ) ;
48
- await this . createInfFile ( ) ;
49
- await this . stampInfFile ( ) ;
50
- // optimization for inf2cat directory search
51
- await this . copyToSignDir ( ) ;
47
+ await this . createMakeCatFile ( ) ;
48
+ await this . makeCatFile ( ) ;
52
49
await this . signDriver ( ) ;
53
50
await this . createDriverDatFile ( ) ;
54
51
await this . install ( ) ;
@@ -104,56 +101,40 @@ export default class Context {
104
101
fs . mkdirSync ( this . buildDir ) ;
105
102
}
106
103
107
- const cmd = `"${ this . vcPath } " amd64 && cd "${ this . buildDir } " && cmake -G "Visual Studio 16 2019" "${ this . srcDir } " && cmake --build . --config Release` ;
104
+ const cmd = `"${ this . vcPath } " amd64 && cd "${ this . buildDir } " && cmake -G "Visual Studio 17 2022" -A x64 -T v143 "${ this . srcDir } " && cmake --build . --config Release` ;
108
105
await this . execute ( cmd , this . buildDir ) ;
109
106
}
110
107
111
- async createInfFile ( ) {
112
- console . log ( 'Creating inf file' ) ;
108
+ async createMakeCatFile ( ) {
109
+ console . log ( 'Creating makecat file' ) ;
113
110
await this . templateToFile (
114
- this . infTplPath ,
115
- this . infPath , {
111
+ this . makeCatTplPath ,
112
+ this . makeCatPath , {
116
113
DRIVER_NAME : this . driverName ,
117
114
} ,
118
115
) ;
119
116
}
120
117
121
- async stampInfFile ( ) {
122
- console . log ( 'Stamping inf file' ) ;
123
- const cmd = `"${ this . vcPath } " amd64 && stampinf .exe -f .\\${ this . driverName } .inf -a "amd64" -k "1.15" -v "*" -d "*" `
118
+ async makeCatFile ( ) {
119
+ console . log ( 'Makeing cat file' ) ;
120
+ const cmd = `"${ this . vcPath } " amd64 && MakeCat .exe -v .\\${ this . driverName } .cdf `
124
121
await this . execute ( cmd , this . buildDir ) ;
125
122
}
126
123
127
- async copyToSignDir ( ) {
128
- fs . mkdirSync ( this . signDir ) ;
129
-
130
- fs . copyFileSync (
131
- `${ this . buildDir } ${ this . driverName } .sys` ,
132
- `${ this . signDir } ${ this . driverName } .sys`
133
- ) ;
134
-
135
- fs . copyFileSync (
136
- `${ this . buildDir } ${ this . driverName } .inf` ,
137
- `${ this . signDir } ${ this . driverName } .inf`
138
- ) ;
139
- }
140
-
141
124
async signDriver ( ) {
142
125
console . log ( 'Signing driver' ) ;
143
126
const openssl = `openssl req -nodes -newkey rsa:2048 -keyout ${ this . driverName } .key -out ${ this . driverName } .csr -subj "/CN=${ this . driverName } .com/O=${ this . driverName } LTD./C=US"`
144
127
const crt = `openssl x509 -signkey ${ this . driverName } .key -in ${ this . driverName } .csr -req -days 365 -out ${ this . driverName } .crt` ;
145
128
const pfx = `openssl pkcs12 -export -out ${ this . driverName } .pfx -inkey ${ this . driverName } .key -in ${ this . driverName } .crt -password pass:` ;
146
- const inf2cat = `"${ this . inf2CatPath } " /driver:"./signdir" /os:10_X64 /verbose` ;
147
129
const vc = `"${ this . vcPath } " amd64` ;
148
- const signtool = `signtool sign /fd SHA256 -f "./${ this . driverName } .pfx" -t "http://timestamp.digicert.com" -v "${ this . signDir } ${ this . driverName } .cat"` ;
130
+ const signtool = `signtool sign /fd SHA256 -f "./${ this . driverName } .pfx" -t "http://timestamp.digicert.com" -v "${ this . driverName } .cat"` ;
149
131
150
- const cmd = `${ openssl } && ${ crt } && ${ pfx } && ${ inf2cat } && ${ vc } && ${ signtool } ` ;
132
+ const cmd = `${ openssl } && ${ crt } && ${ pfx } && ${ vc } && ${ signtool } ` ;
151
133
152
134
await this . execute ( cmd , this . buildDir ) ;
153
135
}
154
136
155
137
async execute ( cmd , cwd , params = [ ] ) {
156
-
157
138
console . log ( `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!` ) ;
158
139
console . log ( `Executing: ${ cmd } ` ) ;
159
140
@@ -191,17 +172,12 @@ export default class Context {
191
172
}
192
173
193
174
fs . copyFileSync (
194
- `${ this . signDir } ${ this . driverName } .sys` ,
175
+ `${ this . buildDir } ${ this . driverName } .sys` ,
195
176
`${ this . distDir } ${ this . driverName } .sys`
196
177
) ;
197
178
198
179
fs . copyFileSync (
199
- `${ this . signDir } ${ this . driverName } .inf` ,
200
- `${ this . distDir } ${ this . driverName } .inf`
201
- ) ;
202
-
203
- fs . copyFileSync (
204
- `${ this . signDir } ${ this . driverName } .cat` ,
180
+ `${ this . buildDir } ${ this . driverName } .cat` ,
205
181
`${ this . distDir } ${ this . driverName } .cat`
206
182
) ;
207
183
0 commit comments