Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
643 lines (609 loc) · 29.4 KB
/
Copy pathbuild.zig
File metadata and controls
643 lines (609 loc) · 29.4 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
const std = @import("std");
pub const helpers = @import("build_helpers.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const library_module = b.addModule("zigcss", .{
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
});
const executable_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = optimize != .Debug,
});
executable_module.addImport("zigcss", library_module);
const exe = b.addExecutable(.{
.name = "zigcss",
.root_module = executable_module,
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const test_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
test_module.addImport("zigcss", library_module);
const unit_tests = b.addTest(.{
.root_module = test_module,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
const core_protocol_test_module = b.createModule(.{
.root_source_file = b.path("src/core_protocol.zig"),
.target = target,
.optimize = optimize,
});
core_protocol_test_module.addImport("zigcss", library_module);
const core_protocol_tests = b.addTest(.{ .root_module = core_protocol_test_module });
const run_core_protocol_tests = b.addRunArtifact(core_protocol_tests);
const node_protocol_test_module = b.createModule(.{
.root_source_file = b.path("src/node_protocol.zig"),
.target = target,
.optimize = optimize,
});
node_protocol_test_module.addImport("zigcss", library_module);
const node_protocol_tests = b.addTest(.{ .root_module = node_protocol_test_module });
const run_node_protocol_tests = b.addRunArtifact(node_protocol_tests);
const lsp_test_module = b.createModule(.{
.root_source_file = b.path("src/lsp.zig"),
.target = target,
.optimize = optimize,
});
lsp_test_module.addImport("zigcss", library_module);
const lsp_tests = b.addTest(.{ .root_module = lsp_test_module });
const run_lsp_tests = b.addRunArtifact(lsp_tests);
const lsp_transport_test_module = b.createModule(.{
.root_source_file = b.path("src/lsp_transport.zig"),
.target = target,
.optimize = optimize,
});
const lsp_transport_tests = b.addTest(.{ .root_module = lsp_transport_test_module });
const run_lsp_transport_tests = b.addRunArtifact(lsp_transport_tests);
const lsp_position_test_module = b.createModule(.{
.root_source_file = b.path("src/lsp_position.zig"),
.target = target,
.optimize = optimize,
});
const lsp_position_tests = b.addTest(.{ .root_module = lsp_position_test_module });
const run_lsp_position_tests = b.addRunArtifact(lsp_position_tests);
const lsp_index_test_module = b.createModule(.{
.root_source_file = b.path("src/lsp_index.zig"),
.target = target,
.optimize = optimize,
});
lsp_index_test_module.addImport("zigcss", library_module);
const lsp_index_tests = b.addTest(.{ .root_module = lsp_index_test_module });
const run_lsp_index_tests = b.addRunArtifact(lsp_index_tests);
const core_tests = b.addTest(.{
.root_module = library_module,
});
const run_core_tests = b.addRunArtifact(core_tests);
const native_preprocessor_module = b.createModule(.{
.root_source_file = b.path("src/preprocessor.zig"),
.target = target,
.optimize = optimize,
});
const native_preprocessor_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/lexer.zig"),
.target = target,
.optimize = optimize,
});
native_preprocessor_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_preprocessor_tests = b.addTest(.{
.root_module = native_preprocessor_test_module,
});
const run_native_preprocessor_tests = b.addRunArtifact(native_preprocessor_tests);
const native_foundation_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/foundation.zig"),
.target = target,
.optimize = optimize,
});
native_foundation_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_foundation_tests = b.addTest(.{
.root_module = native_foundation_test_module,
});
const run_native_foundation_tests = b.addRunArtifact(native_foundation_tests);
const native_resolver_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/resolver.zig"),
.target = target,
.optimize = optimize,
});
native_resolver_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_resolver_tests = b.addTest(.{
.root_module = native_resolver_test_module,
});
const run_native_resolver_tests = b.addRunArtifact(native_resolver_tests);
const native_evaluator_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/evaluator.zig"),
.target = target,
.optimize = optimize,
});
native_evaluator_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_evaluator_tests = b.addTest(.{
.root_module = native_evaluator_test_module,
});
const run_native_evaluator_tests = b.addRunArtifact(native_evaluator_tests);
const native_compiler_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/compiler.zig"),
.target = target,
.optimize = optimize,
});
native_compiler_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_compiler_tests = b.addTest(.{
.root_module = native_compiler_test_module,
});
const run_native_compiler_tests = b.addRunArtifact(native_compiler_tests);
run_native_compiler_tests.setCwd(b.path("."));
const native_compiler_test_step = b.step(
"test-native-compiler",
"Test the private shared native stylesheet compiler route",
);
native_compiler_test_step.dependOn(&run_native_compiler_tests.step);
const native_sass_parser_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_parser.zig"),
.target = target,
.optimize = optimize,
});
native_sass_parser_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_parser_tests = b.addTest(.{
.root_module = native_sass_parser_test_module,
});
const run_native_sass_parser_tests = b.addRunArtifact(native_sass_parser_tests);
run_native_sass_parser_tests.setCwd(b.path("."));
const native_less_parser_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/less_parser.zig"),
.target = target,
.optimize = optimize,
});
native_less_parser_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_less_parser_tests = b.addTest(.{
.root_module = native_less_parser_test_module,
});
const run_native_less_parser_tests = b.addRunArtifact(native_less_parser_tests);
run_native_less_parser_tests.setCwd(b.path("."));
const native_less_parser_test_step = b.step(
"test-native-less-parser",
"Test the private native Less syntax parser",
);
native_less_parser_test_step.dependOn(&run_native_less_parser_tests.step);
const native_stylus_parser_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/stylus_parser.zig"),
.target = target,
.optimize = optimize,
});
native_stylus_parser_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_stylus_parser_tests = b.addTest(.{
.root_module = native_stylus_parser_test_module,
});
const run_native_stylus_parser_tests = b.addRunArtifact(native_stylus_parser_tests);
run_native_stylus_parser_tests.setCwd(b.path("."));
const native_stylus_parser_test_step = b.step(
"test-native-stylus-parser",
"Test the private native Stylus syntax parser",
);
native_stylus_parser_test_step.dependOn(&run_native_stylus_parser_tests.step);
const native_stylus_evaluator_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/stylus_evaluator.zig"),
.target = target,
.optimize = optimize,
});
native_stylus_evaluator_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_stylus_evaluator_tests = b.addTest(.{
.root_module = native_stylus_evaluator_test_module,
});
const run_native_stylus_evaluator_tests = b.addRunArtifact(native_stylus_evaluator_tests);
run_native_stylus_evaluator_tests.setCwd(b.path("."));
const native_stylus_evaluator_test_step = b.step(
"test-native-stylus-evaluator",
"Test the private native Stylus semantic evaluator",
);
native_stylus_evaluator_test_step.dependOn(&run_native_stylus_evaluator_tests.step);
const native_stylus_conformance_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/stylus_conformance.zig"),
.target = target,
.optimize = optimize,
});
native_stylus_conformance_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_stylus_conformance_tests = b.addTest(.{
.root_module = native_stylus_conformance_test_module,
});
const run_native_stylus_conformance_tests = b.addRunArtifact(native_stylus_conformance_tests);
run_native_stylus_conformance_tests.setCwd(b.path("."));
const native_stylus_conformance_test_step = b.step(
"test-native-stylus-conformance",
"Test the pinned native Stylus conformance evidence",
);
native_stylus_conformance_test_step.dependOn(&run_native_stylus_conformance_tests.step);
const native_less_evaluator_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/less_evaluator.zig"),
.target = target,
.optimize = optimize,
});
native_less_evaluator_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_less_evaluator_tests = b.addTest(.{
.root_module = native_less_evaluator_test_module,
});
const run_native_less_evaluator_tests = b.addRunArtifact(native_less_evaluator_tests);
const native_less_evaluator_test_step = b.step(
"test-native-less-evaluator",
"Test the private native Less semantic evaluator",
);
native_less_evaluator_test_step.dependOn(&run_native_less_evaluator_tests.step);
const native_less_conformance_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/less_conformance.zig"),
.target = target,
.optimize = optimize,
});
native_less_conformance_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_less_conformance_tests = b.addTest(.{
.root_module = native_less_conformance_test_module,
});
const run_native_less_conformance_tests = b.addRunArtifact(native_less_conformance_tests);
run_native_less_conformance_tests.setCwd(b.path("."));
const native_less_conformance_test_step = b.step(
"test-native-less-conformance",
"Test the pinned native Less conformance evidence",
);
native_less_conformance_test_step.dependOn(&run_native_less_conformance_tests.step);
const native_sass_arguments_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_arguments.zig"),
.target = target,
.optimize = optimize,
});
native_sass_arguments_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_arguments_tests = b.addTest(.{
.root_module = native_sass_arguments_test_module,
});
const run_native_sass_arguments_tests = b.addRunArtifact(native_sass_arguments_tests);
const native_sass_numeric_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_numeric.zig"),
.target = target,
.optimize = optimize,
});
native_sass_numeric_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_numeric_tests = b.addTest(.{
.root_module = native_sass_numeric_test_module,
});
const run_native_sass_numeric_tests = b.addRunArtifact(native_sass_numeric_tests);
const native_sass_color_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_color.zig"),
.target = target,
.optimize = optimize,
});
native_sass_color_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_color_tests = b.addTest(.{
.root_module = native_sass_color_test_module,
});
const run_native_sass_color_tests = b.addRunArtifact(native_sass_color_tests);
const native_sass_string_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_string.zig"),
.target = target,
.optimize = optimize,
});
native_sass_string_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_string_tests = b.addTest(.{
.root_module = native_sass_string_test_module,
});
const run_native_sass_string_tests = b.addRunArtifact(native_sass_string_tests);
const native_sass_selector_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_selector.zig"),
.target = target,
.optimize = optimize,
});
native_sass_selector_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_selector_tests = b.addTest(.{
.root_module = native_sass_selector_test_module,
});
const run_native_sass_selector_tests = b.addRunArtifact(native_sass_selector_tests);
const native_sass_evaluator_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_evaluator.zig"),
.target = target,
.optimize = optimize,
});
native_sass_evaluator_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_evaluator_tests = b.addTest(.{
.root_module = native_sass_evaluator_test_module,
});
const run_native_sass_evaluator_tests = b.addRunArtifact(native_sass_evaluator_tests);
run_native_sass_evaluator_tests.setCwd(b.path("."));
const native_sass_conformance_test_module = b.createModule(.{
.root_source_file = b.path("tests/native-preprocessor/sass_conformance.zig"),
.target = target,
.optimize = optimize,
});
native_sass_conformance_test_module.addImport("native_preprocessor", native_preprocessor_module);
const native_sass_conformance_tests = b.addTest(.{
.root_module = native_sass_conformance_test_module,
});
const run_native_sass_conformance_tests = b.addRunArtifact(native_sass_conformance_tests);
run_native_sass_conformance_tests.setCwd(b.path("."));
const native_sass_conformance_test_step = b.step(
"test-native-sass-conformance",
"Test the pinned native Sass conformance evidence",
);
native_sass_conformance_test_step.dependOn(&run_native_sass_conformance_tests.step);
const native_preprocessor_test_step = b.step(
"test-native-preprocessor",
"Test the internal self-contained stylesheet frontend implementation",
);
native_preprocessor_test_step.dependOn(&run_native_preprocessor_tests.step);
native_preprocessor_test_step.dependOn(&run_native_foundation_tests.step);
native_preprocessor_test_step.dependOn(&run_native_resolver_tests.step);
native_preprocessor_test_step.dependOn(&run_native_evaluator_tests.step);
native_preprocessor_test_step.dependOn(&run_native_compiler_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_parser_tests.step);
native_preprocessor_test_step.dependOn(&run_native_less_parser_tests.step);
native_preprocessor_test_step.dependOn(&run_native_stylus_parser_tests.step);
native_preprocessor_test_step.dependOn(&run_native_stylus_evaluator_tests.step);
native_preprocessor_test_step.dependOn(&run_native_stylus_conformance_tests.step);
native_preprocessor_test_step.dependOn(&run_native_less_evaluator_tests.step);
native_preprocessor_test_step.dependOn(&run_native_less_conformance_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_arguments_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_numeric_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_color_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_string_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_selector_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_evaluator_tests.step);
native_preprocessor_test_step.dependOn(&run_native_sass_conformance_tests.step);
const public_api_test_module = b.createModule(.{
.root_source_file = b.path("tests/public-api/consumer.zig"),
.target = target,
.optimize = optimize,
});
public_api_test_module.addImport("zigcss", library_module);
const public_api_tests = b.addTest(.{
.root_module = public_api_test_module,
});
const run_public_api_tests = b.addRunArtifact(public_api_tests);
const native_zig_api_test_module = b.createModule(.{
.root_source_file = b.path("tests/public-api/native_consumer.zig"),
.target = target,
.optimize = optimize,
});
native_zig_api_test_module.addImport("zigcss", library_module);
const native_zig_api_tests = b.addTest(.{
.root_module = native_zig_api_test_module,
});
const run_native_zig_api_tests = b.addRunArtifact(native_zig_api_tests);
const public_api_example_module = b.createModule(.{
.root_source_file = b.path("examples/public_api.zig"),
.target = target,
.optimize = optimize,
});
public_api_example_module.addImport("zigcss", library_module);
const public_api_example = b.addExecutable(.{
.name = "zigcss-public-api-example",
.root_module = public_api_example_module,
});
const run_public_api_example = b.addRunArtifact(public_api_example);
run_public_api_example.expectStdOutEqual(".notice{color:red}");
const native_api_example_module = b.createModule(.{
.root_source_file = b.path("examples/native_api.zig"),
.target = target,
.optimize = optimize,
});
native_api_example_module.addImport("zigcss", library_module);
const native_api_example = b.addExecutable(.{
.name = "zigcss-native-api-example",
.root_module = native_api_example_module,
});
const run_native_api_example = b.addRunArtifact(native_api_example);
run_native_api_example.setCwd(b.path("."));
run_native_api_example.expectStdOutEqual(
".card{color:red}\n" ++
".card{color:red}\n" ++
".card{color:red}\n" ++
".card{color:red}\n",
);
const css_modules_example_module = b.createModule(.{
.root_source_file = b.path("examples/css_modules.zig"),
.target = target,
.optimize = optimize,
});
css_modules_example_module.addImport("zigcss", library_module);
const css_modules_example = b.addExecutable(.{
.name = "zigcss-css-modules-example",
.root_module = css_modules_example_module,
});
const run_css_modules_example = b.addRunArtifact(css_modules_example);
run_css_modules_example.expectStdOutEqual("");
const documentation_examples_step = b.step(
"test-documentation-examples",
"Compile and run published Zig documentation examples",
);
documentation_examples_step.dependOn(&run_public_api_example.step);
documentation_examples_step.dependOn(&run_native_api_example.step);
documentation_examples_step.dependOn(&run_css_modules_example.step);
const NativeCliExample = struct {
syntax: []const u8,
input: std.Build.LazyPath,
expected: []const u8,
};
const native_cli_examples = [_]NativeCliExample{
.{ .syntax = "css", .input = b.path("examples/native/styles.css"), .expected = ".card{color:red}" },
.{ .syntax = "scss", .input = b.path("examples/native/styles.scss"), .expected = ".card{color:red}" },
.{ .syntax = "sass", .input = b.path("examples/native/styles.sass"), .expected = ".card{color:red}" },
.{ .syntax = "less", .input = b.path("examples/native/styles.less"), .expected = ".card{color:red}" },
.{ .syntax = "stylus", .input = b.path("examples/native/styles.styl"), .expected = ".card{color:#f00}" },
};
for (native_cli_examples) |example| {
const run_native_cli_example = b.addRunArtifact(exe);
run_native_cli_example.addFileArg(example.input);
run_native_cli_example.addArgs(&.{ "--syntax", example.syntax, "--minify" });
run_native_cli_example.expectStdOutEqual(example.expected);
documentation_examples_step.dependOn(&run_native_cli_example.step);
}
const public_api_step = b.step("test-public-api", "Test the external Zig library surface");
public_api_step.dependOn(&run_public_api_tests.step);
public_api_step.dependOn(documentation_examples_step);
const native_zig_api_step = b.step(
"test-native-zig-api",
"Test the native-graduated stylesheet Zig API route",
);
native_zig_api_step.dependOn(&run_native_zig_api_tests.step);
const native_cli_test_module = b.createModule(.{
.root_source_file = b.path("tests/cli/native_cli.zig"),
.target = target,
.optimize = optimize,
});
const native_cli_options = b.addOptions();
native_cli_options.addOption([]const u8, "compiler_path", b.getInstallPath(.bin, "zigcss"));
native_cli_test_module.addOptions("cli_options", native_cli_options);
const native_cli_tests = b.addTest(.{
.root_module = native_cli_test_module,
});
const run_native_cli_tests = b.addRunArtifact(native_cli_tests);
run_native_cli_tests.step.dependOn(b.getInstallStep());
const native_cli_step = b.step(
"test-native-cli",
"Test stable native stylesheet syntax selection and binary CLI routing",
);
native_cli_step.dependOn(&run_native_cli_tests.step);
const native_product_step = b.step(
"test-native-product",
"Test the finite native stylesheet Zig API and binary routes",
);
native_product_step.dependOn(&run_native_zig_api_tests.step);
native_product_step.dependOn(&run_native_cli_tests.step);
const audit_test_module = b.addModule("zigcss-audit-regressions", .{
.root_source_file = b.path("tests/regressions/audit.zig"),
.target = target,
.optimize = optimize,
});
const audit_options = b.addOptions();
audit_options.addOption([]const u8, "compiler_path", b.getInstallPath(.bin, "zigcss"));
audit_test_module.addOptions("audit_options", audit_options);
audit_test_module.addImport("zigcss", library_module);
const audit_tests = b.addTest(.{
.root_module = audit_test_module,
});
const run_audit_tests = b.addRunArtifact(audit_tests);
run_audit_tests.step.dependOn(b.getInstallStep());
// This executable exposes verified transforms only to differential tests.
// It is installed by `zig build test`, never by the normal install step.
const transform_driver_module = b.createModule(.{
.root_source_file = b.path("tests/transforms/driver.zig"),
.target = target,
.optimize = optimize,
});
transform_driver_module.addImport("zigcss", library_module);
const transform_driver = b.addExecutable(.{
.name = "zigcss-transform-test-driver",
.root_module = transform_driver_module,
});
const install_transform_driver = b.addInstallArtifact(transform_driver, .{});
// This executable exposes the public CSS Modules result only to the
// independent format oracle. It is installed by `zig build test`, never by
// the normal install step or recovery CLI.
const css_modules_driver_module = b.createModule(.{
.root_source_file = b.path("tests/formats/css_modules_driver.zig"),
.target = target,
.optimize = optimize,
});
css_modules_driver_module.addImport("zigcss", library_module);
const css_modules_driver = b.addExecutable(.{
.name = "zigcss-css-modules-test-driver",
.root_module = css_modules_driver_module,
});
const install_css_modules_driver = b.addInstallArtifact(css_modules_driver, .{});
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
test_step.dependOn(&run_core_protocol_tests.step);
test_step.dependOn(&run_node_protocol_tests.step);
test_step.dependOn(&run_lsp_tests.step);
test_step.dependOn(&run_lsp_transport_tests.step);
test_step.dependOn(&run_lsp_position_tests.step);
test_step.dependOn(&run_lsp_index_tests.step);
test_step.dependOn(&run_core_tests.step);
test_step.dependOn(&run_native_preprocessor_tests.step);
test_step.dependOn(&run_native_foundation_tests.step);
test_step.dependOn(&run_native_resolver_tests.step);
test_step.dependOn(&run_native_evaluator_tests.step);
test_step.dependOn(&run_native_compiler_tests.step);
test_step.dependOn(&run_native_sass_parser_tests.step);
test_step.dependOn(&run_native_less_parser_tests.step);
test_step.dependOn(&run_native_stylus_parser_tests.step);
test_step.dependOn(&run_native_stylus_evaluator_tests.step);
test_step.dependOn(&run_native_stylus_conformance_tests.step);
test_step.dependOn(&run_native_less_evaluator_tests.step);
test_step.dependOn(&run_native_less_conformance_tests.step);
test_step.dependOn(&run_native_sass_arguments_tests.step);
test_step.dependOn(&run_native_sass_numeric_tests.step);
test_step.dependOn(&run_native_sass_color_tests.step);
test_step.dependOn(&run_native_sass_string_tests.step);
test_step.dependOn(&run_native_sass_selector_tests.step);
test_step.dependOn(&run_native_sass_evaluator_tests.step);
test_step.dependOn(&run_native_sass_conformance_tests.step);
test_step.dependOn(&run_public_api_tests.step);
test_step.dependOn(&run_native_zig_api_tests.step);
test_step.dependOn(&run_native_cli_tests.step);
test_step.dependOn(documentation_examples_step);
test_step.dependOn(&run_audit_tests.step);
test_step.dependOn(&install_transform_driver.step);
test_step.dependOn(&install_css_modules_driver.step);
const helper_compilation = helpers.addCssCompile(b, exe, .{
.input = b.path("tests/build-helpers/input.css"),
.output_name = "build-helper.css",
.optimize = true,
.minify = true,
});
const check_helper_output = b.addCheckFile(helper_compilation.getOutput(), .{
.expected_exact = ".card{width:3px;color:#fff}",
});
check_helper_output.setName("verify build-helper CSS output");
const helper_test_module = b.createModule(.{
.root_source_file = b.path("build_helpers.zig"),
.target = target,
.optimize = optimize,
});
const helper_unit_tests = b.addTest(.{ .root_module = helper_test_module });
const run_helper_unit_tests = b.addRunArtifact(helper_unit_tests);
const helper_test_step = b.step(
"test-build-helpers",
"Test declared ZigCSS build inputs and outputs",
);
helper_test_step.dependOn(&check_helper_output.step);
helper_test_step.dependOn(&run_helper_unit_tests.step);
test_step.dependOn(&check_helper_output.step);
test_step.dependOn(&run_helper_unit_tests.step);
const bench_module = b.addModule("zigcss-bench", .{
.root_source_file = b.path("src/benchmarks.zig"),
.target = target,
.optimize = optimize,
});
bench_module.addAnonymousImport("benchmark-small-css", .{
.root_source_file = b.path("benchmarks/corpora/v1/small.css"),
});
bench_module.addAnonymousImport("benchmark-medium-css", .{
.root_source_file = b.path("benchmarks/corpora/v1/medium.css"),
});
bench_module.addAnonymousImport("benchmark-large-css", .{
.root_source_file = b.path("benchmarks/corpora/v1/large.css"),
});
bench_module.addImport("zigcss", library_module);
const bench_exe = b.addExecutable(.{
.name = "zigcss-bench",
.root_module = bench_module,
});
const install_bench = b.addInstallArtifact(bench_exe, .{});
const install_bench_step = b.step(
"install-benchmark-runner",
"Install the private benchmark measurement runner",
);
install_bench_step.dependOn(&install_bench.step);
const bench_tests = b.addTest(.{ .root_module = bench_module });
const run_bench_tests = b.addRunArtifact(bench_tests);
test_step.dependOn(&run_bench_tests.step);
const run_bench = b.addRunArtifact(bench_exe);
const bench_step = b.step("bench", "Smoke separated validated benchmark modes");
bench_step.dependOn(&run_bench.step);
}