@@ -357,105 +357,132 @@ impl Merge for TomlConfig {
357
357
}
358
358
}
359
359
360
- /// TOML representation of various global build decisions.
361
- #[ derive( Deserialize , Default , Clone , Merge ) ]
362
- #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
363
- struct Build {
364
- build : Option < String > ,
365
- host : Option < Vec < String > > ,
366
- target : Option < Vec < String > > ,
367
- // This is ignored, the rust code always gets the build directory from the `BUILD_DIR` env variable
368
- build_dir : Option < String > ,
369
- cargo : Option < String > ,
370
- rustc : Option < String > ,
371
- rustfmt : Option < PathBuf > ,
372
- docs : Option < bool > ,
373
- compiler_docs : Option < bool > ,
374
- docs_minification : Option < bool > ,
375
- submodules : Option < bool > ,
376
- fast_submodules : Option < bool > ,
377
- gdb : Option < String > ,
378
- nodejs : Option < String > ,
379
- npm : Option < String > ,
380
- python : Option < String > ,
381
- locked_deps : Option < bool > ,
382
- vendor : Option < bool > ,
383
- full_bootstrap : Option < bool > ,
384
- extended : Option < bool > ,
385
- tools : Option < HashSet < String > > ,
386
- verbose : Option < usize > ,
387
- sanitizers : Option < bool > ,
388
- profiler : Option < bool > ,
389
- cargo_native_static : Option < bool > ,
390
- low_priority : Option < bool > ,
391
- configure_args : Option < Vec < String > > ,
392
- local_rebuild : Option < bool > ,
393
- print_step_timings : Option < bool > ,
394
- print_step_rusage : Option < bool > ,
395
- check_stage : Option < u32 > ,
396
- doc_stage : Option < u32 > ,
397
- build_stage : Option < u32 > ,
398
- test_stage : Option < u32 > ,
399
- install_stage : Option < u32 > ,
400
- dist_stage : Option < u32 > ,
401
- bench_stage : Option < u32 > ,
402
- patch_binaries_for_nix : Option < bool > ,
360
+ macro_rules! derive_merge {
361
+ ( $( #[ $attr: meta] ) * struct $name: ident {
362
+ $( $field: ident: $field_ty: ty, ) *
363
+ } ) => {
364
+ $( #[ $attr] ) *
365
+ struct $name {
366
+ $( $field: $field_ty, ) *
367
+ }
368
+
369
+ impl Merge for $name {
370
+ fn merge( & mut self , other: Self ) {
371
+ $(
372
+ Merge :: merge( & mut self . $field, other. $field) ;
373
+ ) *
374
+ }
375
+ }
376
+ }
403
377
}
404
378
405
- /// TOML representation of various global install decisions.
406
- #[ derive( Deserialize , Default , Clone , Merge ) ]
407
- #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
408
- struct Install {
409
- prefix : Option < String > ,
410
- sysconfdir : Option < String > ,
411
- docdir : Option < String > ,
412
- bindir : Option < String > ,
413
- libdir : Option < String > ,
414
- mandir : Option < String > ,
415
- datadir : Option < String > ,
379
+ derive_merge ! {
380
+ /// TOML representation of various global build decisions.
381
+ #[ derive( Deserialize , Default , Clone ) ]
382
+ #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
383
+ struct Build {
384
+ build: Option <String >,
385
+ host: Option <Vec <String >>,
386
+ target: Option <Vec <String >>,
387
+ // This is ignored, the rust code always gets the build directory from the `BUILD_DIR` env variable
388
+ build_dir: Option <String >,
389
+ cargo: Option <String >,
390
+ rustc: Option <String >,
391
+ rustfmt: Option <PathBuf >,
392
+ docs: Option <bool >,
393
+ compiler_docs: Option <bool >,
394
+ docs_minification: Option <bool >,
395
+ submodules: Option <bool >,
396
+ fast_submodules: Option <bool >,
397
+ gdb: Option <String >,
398
+ nodejs: Option <String >,
399
+ npm: Option <String >,
400
+ python: Option <String >,
401
+ locked_deps: Option <bool >,
402
+ vendor: Option <bool >,
403
+ full_bootstrap: Option <bool >,
404
+ extended: Option <bool >,
405
+ tools: Option <HashSet <String >>,
406
+ verbose: Option <usize >,
407
+ sanitizers: Option <bool >,
408
+ profiler: Option <bool >,
409
+ cargo_native_static: Option <bool >,
410
+ low_priority: Option <bool >,
411
+ configure_args: Option <Vec <String >>,
412
+ local_rebuild: Option <bool >,
413
+ print_step_timings: Option <bool >,
414
+ print_step_rusage: Option <bool >,
415
+ check_stage: Option <u32 >,
416
+ doc_stage: Option <u32 >,
417
+ build_stage: Option <u32 >,
418
+ test_stage: Option <u32 >,
419
+ install_stage: Option <u32 >,
420
+ dist_stage: Option <u32 >,
421
+ bench_stage: Option <u32 >,
422
+ patch_binaries_for_nix: Option <bool >,
423
+ }
416
424
}
417
425
418
- /// TOML representation of how the LLVM build is configured.
419
- #[ derive( Deserialize , Default , Merge ) ]
420
- #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
421
- struct Llvm {
422
- skip_rebuild : Option < bool > ,
423
- optimize : Option < bool > ,
424
- thin_lto : Option < bool > ,
425
- release_debuginfo : Option < bool > ,
426
- assertions : Option < bool > ,
427
- tests : Option < bool > ,
428
- plugins : Option < bool > ,
429
- ccache : Option < StringOrBool > ,
430
- version_check : Option < bool > ,
431
- static_libstdcpp : Option < bool > ,
432
- ninja : Option < bool > ,
433
- targets : Option < String > ,
434
- experimental_targets : Option < String > ,
435
- link_jobs : Option < u32 > ,
436
- link_shared : Option < bool > ,
437
- version_suffix : Option < String > ,
438
- clang_cl : Option < String > ,
439
- cflags : Option < String > ,
440
- cxxflags : Option < String > ,
441
- ldflags : Option < String > ,
442
- use_libcxx : Option < bool > ,
443
- use_linker : Option < String > ,
444
- allow_old_toolchain : Option < bool > ,
445
- polly : Option < bool > ,
446
- clang : Option < bool > ,
447
- download_ci_llvm : Option < StringOrBool > ,
426
+ derive_merge ! {
427
+ /// TOML representation of various global install decisions.
428
+ #[ derive( Deserialize , Default , Clone ) ]
429
+ #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
430
+ struct Install {
431
+ prefix: Option <String >,
432
+ sysconfdir: Option <String >,
433
+ docdir: Option <String >,
434
+ bindir: Option <String >,
435
+ libdir: Option <String >,
436
+ mandir: Option <String >,
437
+ datadir: Option <String >,
438
+ }
448
439
}
449
440
450
- #[ derive( Deserialize , Default , Clone , Merge ) ]
451
- #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
452
- struct Dist {
453
- sign_folder : Option < String > ,
454
- gpg_password_file : Option < String > ,
455
- upload_addr : Option < String > ,
456
- src_tarball : Option < bool > ,
457
- missing_tools : Option < bool > ,
458
- compression_formats : Option < Vec < String > > ,
441
+ derive_merge ! {
442
+ /// TOML representation of how the LLVM build is configured.
443
+ #[ derive( Deserialize , Default ) ]
444
+ #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
445
+ struct Llvm {
446
+ skip_rebuild: Option <bool >,
447
+ optimize: Option <bool >,
448
+ thin_lto: Option <bool >,
449
+ release_debuginfo: Option <bool >,
450
+ assertions: Option <bool >,
451
+ tests: Option <bool >,
452
+ plugins: Option <bool >,
453
+ ccache: Option <StringOrBool >,
454
+ version_check: Option <bool >,
455
+ static_libstdcpp: Option <bool >,
456
+ ninja: Option <bool >,
457
+ targets: Option <String >,
458
+ experimental_targets: Option <String >,
459
+ link_jobs: Option <u32 >,
460
+ link_shared: Option <bool >,
461
+ version_suffix: Option <String >,
462
+ clang_cl: Option <String >,
463
+ cflags: Option <String >,
464
+ cxxflags: Option <String >,
465
+ ldflags: Option <String >,
466
+ use_libcxx: Option <bool >,
467
+ use_linker: Option <String >,
468
+ allow_old_toolchain: Option <bool >,
469
+ polly: Option <bool >,
470
+ clang: Option <bool >,
471
+ download_ci_llvm: Option <StringOrBool >,
472
+ }
473
+ }
474
+
475
+ derive_merge ! {
476
+ #[ derive( Deserialize , Default , Clone ) ]
477
+ #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
478
+ struct Dist {
479
+ sign_folder: Option <String >,
480
+ gpg_password_file: Option <String >,
481
+ upload_addr: Option <String >,
482
+ src_tarball: Option <bool >,
483
+ missing_tools: Option <bool >,
484
+ compression_formats: Option <Vec <String >>,
485
+ }
459
486
}
460
487
461
488
#[ derive( Deserialize ) ]
@@ -471,80 +498,84 @@ impl Default for StringOrBool {
471
498
}
472
499
}
473
500
474
- /// TOML representation of how the Rust build is configured.
475
- #[ derive( Deserialize , Default , Merge ) ]
476
- #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
477
- struct Rust {
478
- optimize : Option < bool > ,
479
- debug : Option < bool > ,
480
- codegen_units : Option < u32 > ,
481
- codegen_units_std : Option < u32 > ,
482
- debug_assertions : Option < bool > ,
483
- debug_assertions_std : Option < bool > ,
484
- overflow_checks : Option < bool > ,
485
- overflow_checks_std : Option < bool > ,
486
- debug_logging : Option < bool > ,
487
- debuginfo_level : Option < u32 > ,
488
- debuginfo_level_rustc : Option < u32 > ,
489
- debuginfo_level_std : Option < u32 > ,
490
- debuginfo_level_tools : Option < u32 > ,
491
- debuginfo_level_tests : Option < u32 > ,
492
- run_dsymutil : Option < bool > ,
493
- backtrace : Option < bool > ,
494
- incremental : Option < bool > ,
495
- parallel_compiler : Option < bool > ,
496
- default_linker : Option < String > ,
497
- channel : Option < String > ,
498
- description : Option < String > ,
499
- musl_root : Option < String > ,
500
- rpath : Option < bool > ,
501
- verbose_tests : Option < bool > ,
502
- optimize_tests : Option < bool > ,
503
- codegen_tests : Option < bool > ,
504
- ignore_git : Option < bool > ,
505
- dist_src : Option < bool > ,
506
- save_toolstates : Option < String > ,
507
- codegen_backends : Option < Vec < String > > ,
508
- lld : Option < bool > ,
509
- use_lld : Option < bool > ,
510
- llvm_tools : Option < bool > ,
511
- deny_warnings : Option < bool > ,
512
- backtrace_on_ice : Option < bool > ,
513
- verify_llvm_ir : Option < bool > ,
514
- thin_lto_import_instr_limit : Option < u32 > ,
515
- remap_debuginfo : Option < bool > ,
516
- jemalloc : Option < bool > ,
517
- test_compare_mode : Option < bool > ,
518
- llvm_libunwind : Option < String > ,
519
- control_flow_guard : Option < bool > ,
520
- new_symbol_mangling : Option < bool > ,
521
- profile_generate : Option < String > ,
522
- profile_use : Option < String > ,
523
- // ignored; this is set from an env var set by bootstrap.py
524
- download_rustc : Option < StringOrBool > ,
501
+ derive_merge ! {
502
+ /// TOML representation of how the Rust build is configured.
503
+ #[ derive( Deserialize , Default ) ]
504
+ #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
505
+ struct Rust {
506
+ optimize: Option <bool >,
507
+ debug: Option <bool >,
508
+ codegen_units: Option <u32 >,
509
+ codegen_units_std: Option <u32 >,
510
+ debug_assertions: Option <bool >,
511
+ debug_assertions_std: Option <bool >,
512
+ overflow_checks: Option <bool >,
513
+ overflow_checks_std: Option <bool >,
514
+ debug_logging: Option <bool >,
515
+ debuginfo_level: Option <u32 >,
516
+ debuginfo_level_rustc: Option <u32 >,
517
+ debuginfo_level_std: Option <u32 >,
518
+ debuginfo_level_tools: Option <u32 >,
519
+ debuginfo_level_tests: Option <u32 >,
520
+ run_dsymutil: Option <bool >,
521
+ backtrace: Option <bool >,
522
+ incremental: Option <bool >,
523
+ parallel_compiler: Option <bool >,
524
+ default_linker: Option <String >,
525
+ channel: Option <String >,
526
+ description: Option <String >,
527
+ musl_root: Option <String >,
528
+ rpath: Option <bool >,
529
+ verbose_tests: Option <bool >,
530
+ optimize_tests: Option <bool >,
531
+ codegen_tests: Option <bool >,
532
+ ignore_git: Option <bool >,
533
+ dist_src: Option <bool >,
534
+ save_toolstates: Option <String >,
535
+ codegen_backends: Option <Vec <String >>,
536
+ lld: Option <bool >,
537
+ use_lld: Option <bool >,
538
+ llvm_tools: Option <bool >,
539
+ deny_warnings: Option <bool >,
540
+ backtrace_on_ice: Option <bool >,
541
+ verify_llvm_ir: Option <bool >,
542
+ thin_lto_import_instr_limit: Option <u32 >,
543
+ remap_debuginfo: Option <bool >,
544
+ jemalloc: Option <bool >,
545
+ test_compare_mode: Option <bool >,
546
+ llvm_libunwind: Option <String >,
547
+ control_flow_guard: Option <bool >,
548
+ new_symbol_mangling: Option <bool >,
549
+ profile_generate: Option <String >,
550
+ profile_use: Option <String >,
551
+ // ignored; this is set from an env var set by bootstrap.py
552
+ download_rustc: Option <StringOrBool >,
553
+ }
525
554
}
526
555
527
- /// TOML representation of how each build target is configured.
528
- #[ derive( Deserialize , Default , Merge ) ]
529
- #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
530
- struct TomlTarget {
531
- cc : Option < String > ,
532
- cxx : Option < String > ,
533
- ar : Option < String > ,
534
- ranlib : Option < String > ,
535
- default_linker : Option < PathBuf > ,
536
- linker : Option < String > ,
537
- llvm_config : Option < String > ,
538
- llvm_filecheck : Option < String > ,
539
- android_ndk : Option < String > ,
540
- sanitizers : Option < bool > ,
541
- profiler : Option < bool > ,
542
- crt_static : Option < bool > ,
543
- musl_root : Option < String > ,
544
- musl_libdir : Option < String > ,
545
- wasi_root : Option < String > ,
546
- qemu_rootfs : Option < String > ,
547
- no_std : Option < bool > ,
556
+ derive_merge ! {
557
+ /// TOML representation of how each build target is configured.
558
+ #[ derive( Deserialize , Default ) ]
559
+ #[ serde( deny_unknown_fields, rename_all = "kebab-case" ) ]
560
+ struct TomlTarget {
561
+ cc: Option <String >,
562
+ cxx: Option <String >,
563
+ ar: Option <String >,
564
+ ranlib: Option <String >,
565
+ default_linker: Option <PathBuf >,
566
+ linker: Option <String >,
567
+ llvm_config: Option <String >,
568
+ llvm_filecheck: Option <String >,
569
+ android_ndk: Option <String >,
570
+ sanitizers: Option <bool >,
571
+ profiler: Option <bool >,
572
+ crt_static: Option <bool >,
573
+ musl_root: Option <String >,
574
+ musl_libdir: Option <String >,
575
+ wasi_root: Option <String >,
576
+ qemu_rootfs: Option <String >,
577
+ no_std: Option <bool >,
578
+ }
548
579
}
549
580
550
581
impl Config {
0 commit comments