@@ -9,7 +9,7 @@ const samples = [_][]const u8{
9
9
"math" ,
10
10
};
11
11
12
- const avr_target_query = std.zig.CrossTarget {
12
+ const avr_target_query = std.Target.Query {
13
13
.cpu_arch = .avr ,
14
14
.cpu_model = .{ .explicit = & std .Target .avr .cpu .atmega328p },
15
15
.os_tag = .freestanding ,
@@ -86,7 +86,7 @@ pub fn build(b: *Build) !void {
86
86
.strip = false ,
87
87
});
88
88
sample .bundle_compiler_rt = false ;
89
- sample .setLinkerScriptPath (b .path ("linker.ld" ));
89
+ sample .setLinkerScript (b .path ("linker.ld" ));
90
90
91
91
// install to the prefix:
92
92
const install_elf_sample = b .addInstallFile (sample .getEmittedBin (), b .fmt ("samples/{s}.elf" , .{sample_name }));
@@ -191,14 +191,19 @@ fn addTestSuite(
191
191
const config = try parseTestSuiteConfig (b , file );
192
192
193
193
const custom_target = if (config .cpu ) | cpu |
194
- b .resolveTargetQuery (std .zig . CrossTarget .parse (.{
194
+ b .resolveTargetQuery (std .Target . Query .parse (.{
195
195
.arch_os_abi = "avr-freestanding-eabi" ,
196
196
.cpu_features = cpu ,
197
197
}) catch @panic (cpu ))
198
198
else
199
199
avr_target ;
200
200
201
- const is_zig_test = std .mem .eql (u8 , std .fs .path .extension (entry .path ), ".zig" );
201
+ const file_ext = std .fs .path .extension (entry .path );
202
+ const is_zig_test = std .mem .eql (u8 , file_ext , ".zig" );
203
+ const is_c_test = std .mem .eql (u8 , file_ext , ".c" );
204
+ const is_asm_test = std .mem .eql (u8 , file_ext , ".S" );
205
+
206
+ std .debug .assert (is_zig_test or is_c_test or is_asm_test );
202
207
203
208
const source_file = b .path (b .fmt ("testsuite/{s}" , .{entry .path }));
204
209
const root_file = if (is_zig_test )
@@ -211,24 +216,33 @@ fn addTestSuite(
211
216
.target = custom_target ,
212
217
.optimize = config .optimize ,
213
218
.strip = false ,
214
- .root_source_file = root_file ,
219
+ .root_source_file = if ( is_zig_test ) root_file else null ,
215
220
.link_libc = false ,
216
221
});
217
222
test_payload .want_lto = false ; // AVR has no LTO support!
218
223
test_payload .verbose_link = true ;
219
224
test_payload .verbose_cc = true ;
220
- if (! is_zig_test ) {
225
+ test_payload .bundle_compiler_rt = false ;
226
+
227
+ test_payload .setLinkerScript (b .path ("linker.ld" ));
228
+
229
+ if (is_c_test or is_asm_test ) {
230
+ test_payload .addIncludePath (b .path ("testsuite" ));
231
+ }
232
+ if (is_c_test ) {
221
233
test_payload .addCSourceFile (.{
222
234
.file = source_file ,
223
235
.flags = &.{},
224
236
});
225
237
}
226
- test_payload .bundle_compiler_rt = false ;
227
- test_payload .addIncludePath (b .path ("testsuite" ));
228
- test_payload .setLinkerScriptPath (b .path ("linker.ld" ));
229
- test_payload .root_module .addAnonymousImport ("testsuite" , .{
230
- .root_source_file = b .path ("src/libtestsuite/lib.zig" ),
231
- });
238
+ if (is_asm_test ) {
239
+ test_payload .addAssemblyFile (source_file );
240
+ }
241
+ if (is_zig_test ) {
242
+ test_payload .root_module .addAnonymousImport ("testsuite" , .{
243
+ .root_source_file = b .path ("src/libtestsuite/lib.zig" ),
244
+ });
245
+ }
232
246
233
247
debug_step .dependOn (& b .addInstallFile (
234
248
test_payload .getEmittedBin (),
@@ -261,7 +275,7 @@ fn addTestSuite(
261
275
262
276
const test_run = b .addRunArtifact (testrunner_exe );
263
277
test_run .addArg ("--config" );
264
- test_run .addFileArg (write_file .files . items [ 0 ]. getPath ( ));
278
+ test_run .addFileArg (write_file .getDirectory (). path ( b , "config.json" ));
265
279
test_run .addArg ("--name" );
266
280
test_run .addArg (entry .path );
267
281
@@ -282,7 +296,7 @@ fn addTestSuiteUpdate(
282
296
.cwd_relative = path ,
283
297
} else | _ | b .addExecutable (.{
284
298
.name = "no-avr-gcc" ,
285
- .target = b .host ,
299
+ .target = b .graph . host ,
286
300
.root_source_file = b .path ("tools/no-avr-gcc.zig" ),
287
301
}).getEmittedBin ();
288
302
@@ -347,7 +361,7 @@ fn addTestSuiteUpdate(
347
361
const write_file = b .addWriteFile ("config.json" , config .toString (b ));
348
362
349
363
const copy_file = b .addSystemCommand (&.{"cp" }); // todo make this cross-platform!
350
- copy_file .addFileArg (write_file .files . items [ 0 ]. getPath ( ));
364
+ copy_file .addFileArg (write_file .getDirectory (). path ( b , "config.json" ));
351
365
copy_file .addArg (b .fmt ("testsuite/{s}/{s}.elf.json" , .{ std .fs .path .dirname (entry .path ).? , std .fs .path .stem (entry .basename ) }));
352
366
353
367
invoke_step .dependOn (& gcc_invocation .step );
@@ -396,7 +410,7 @@ fn generateIsaTables(b: *Build, isa_mod: *Build.Module) LazyPath {
396
410
const generate_tables_exe = b .addExecutable (.{
397
411
.name = "aviron-generate-tables" ,
398
412
.root_source_file = b .path ("tools/generate-tables.zig" ),
399
- .target = b .host ,
413
+ .target = b .graph . host ,
400
414
.optimize = .Debug ,
401
415
});
402
416
generate_tables_exe .root_module .addImport ("isa" , isa_mod );
0 commit comments