24
24
Target (platform) data for conditional dependencies.
25
25
This corresponds roughly to what buildRustCrate is setting.
26
26
*/
27
- makeDefaultTargetSpec = platform : {
27
+ makeDefaultTarget = platform : {
28
+ name = platform . rust . rustcTarget ;
29
+
28
30
unix = platform . isUnix ;
29
31
windows = platform . isWindows ;
30
32
fuchsia = true ;
@@ -309,22 +311,21 @@ rec {
309
311
, crateConfigs ? crates
310
312
, buildRustCrateForPkgsFunc
311
313
, runTests
312
- , makeTargetSpec ? makeDefaultTargetSpec
314
+ , makeTarget ? makeDefaultTarget
313
315
,
314
316
} @args :
315
317
assert ( builtins . isAttrs crateConfigs ) ;
316
318
assert ( builtins . isString packageId ) ;
317
319
assert ( builtins . isList features ) ;
318
- assert ( builtins . isAttrs ( makeTargetSpec stdenv . hostPlatform ) ) ;
320
+ assert ( builtins . isAttrs ( makeTarget stdenv . hostPlatform ) ) ;
319
321
assert ( builtins . isBool runTests ) ;
320
322
let
321
323
rootPackageId = packageId ;
322
324
mergedFeatures = mergePackageFeatures (
323
325
args
324
326
// {
325
327
inherit rootPackageId ;
326
- target = stdenv . hostPlatform . rust . rustcTarget ;
327
- targetSpec = makeTargetSpec stdenv . hostPlatform // {
328
+ target = makeTarget stdenv . hostPlatform // {
328
329
test = runTests ;
329
330
} ;
330
331
}
@@ -340,8 +341,7 @@ rec {
340
341
packageId : value : buildByPackageIdForPkgsImpl self pkgs packageId
341
342
)
342
343
crateConfigs ;
343
- target = pkgs . stdenv . hostPlatform . rust . rustcTarget ;
344
- targetSpec = makeTargetSpec pkgs . stdenv . hostPlatform ;
344
+ target = makeTarget pkgs . stdenv . hostPlatform ;
345
345
build = mkBuiltByPackageIdByPkgs pkgs . buildPackages ;
346
346
} ;
347
347
in
@@ -360,7 +360,7 @@ rec {
360
360
) ;
361
361
dependencies = dependencyDerivations {
362
362
inherit features ;
363
- inherit ( self ) target targetSpec ;
363
+ inherit ( self ) target ;
364
364
buildByPackageId =
365
365
depPackageId :
366
366
# proc_macro crates must be compiled for the build architecture
@@ -372,20 +372,20 @@ rec {
372
372
} ;
373
373
buildDependencies = dependencyDerivations {
374
374
inherit features ;
375
- inherit ( self . build ) target targetSpec ;
375
+ inherit ( self . build ) target ;
376
376
buildByPackageId = depPackageId : self . build . crates . ${ depPackageId } ;
377
377
dependencies = crateConfig . buildDependencies or [ ] ;
378
378
} ;
379
379
dependenciesWithRenames =
380
380
let
381
381
buildDeps = filterEnabledDependencies {
382
382
inherit features ;
383
- inherit ( self ) target targetSpec ;
383
+ inherit ( self ) target ;
384
384
dependencies = crateConfig . dependencies or [ ] ++ devDependencies ;
385
385
} ;
386
386
hostDeps = filterEnabledDependencies {
387
387
inherit features ;
388
- inherit ( self . build ) target targetSpec ;
388
+ inherit ( self . build ) target ;
389
389
dependencies = crateConfig . buildDependencies or [ ] ;
390
390
} ;
391
391
in
@@ -447,16 +447,14 @@ rec {
447
447
, features
448
448
, dependencies
449
449
, target
450
- , targetSpec
451
450
,
452
451
} :
453
452
assert ( builtins . isList features ) ;
454
453
assert ( builtins . isList dependencies ) ;
455
- assert ( builtins . isString target ) ;
456
- assert ( builtins . isAttrs targetSpec ) ;
454
+ assert ( builtins . isAttrs target ) ;
457
455
let
458
456
enabledDependencies = filterEnabledDependencies {
459
- inherit dependencies features target targetSpec ;
457
+ inherit dependencies features target ;
460
458
} ;
461
459
depDerivation = dependency : buildByPackageId dependency . packageId ;
462
460
in
@@ -480,8 +478,7 @@ rec {
480
478
# Returns various tools to debug a crate.
481
479
debugCrate =
482
480
{ packageId
483
- , target ? stdenv . hostPlatform . rust . rustcTarget
484
- , targetSpec ? makeDefaultTargetSpec stdenv . hostPlatform
481
+ , target ? makeDefaultTarget stdenv . hostPlatform
485
482
,
486
483
} :
487
484
assert ( builtins . isString packageId ) ;
@@ -503,10 +500,10 @@ rec {
503
500
} ) ;
504
501
mergedPackageFeatures = mergePackageFeatures {
505
502
features = rootFeatures ;
506
- inherit packageId target targetSpec ;
503
+ inherit packageId target ;
507
504
} ;
508
505
diffedDefaultPackageFeatures = diffDefaultPackageFeatures {
509
- inherit packageId target targetSpec ;
506
+ inherit packageId target ;
510
507
} ;
511
508
} ;
512
509
in
@@ -524,14 +521,13 @@ rec {
524
521
{ crateConfigs ? crates
525
522
, packageId
526
523
, target
527
- , targetSpec
528
524
,
529
525
} :
530
526
assert ( builtins . isAttrs crateConfigs ) ;
531
527
let
532
528
prefixValues = prefix : lib . mapAttrs ( n : v : { "${ prefix } " = v ; } ) ;
533
529
mergedFeatures = prefixValues "crate2nix" ( mergePackageFeatures {
534
- inherit crateConfigs packageId target targetSpec ;
530
+ inherit crateConfigs packageId target ;
535
531
features = [ "default" ] ;
536
532
} ) ;
537
533
configs = prefixValues "cargo" crateConfigs ;
@@ -572,7 +568,6 @@ rec {
572
568
, dependencyPath ? [ crates . ${ packageId } . crateName ]
573
569
, featuresByPackageId ? { }
574
570
, target
575
- , targetSpec
576
571
, # Adds devDependencies to the crate with rootPackageId.
577
572
runTests ? false
578
573
, ...
@@ -583,8 +578,7 @@ rec {
583
578
assert ( builtins . isList features ) ;
584
579
assert ( builtins . isList dependencyPath ) ;
585
580
assert ( builtins . isAttrs featuresByPackageId ) ;
586
- assert ( builtins . isString target ) ;
587
- assert ( builtins . isAttrs targetSpec ) ;
581
+ assert ( builtins . isAttrs target ) ;
588
582
assert ( builtins . isBool runTests ) ;
589
583
let
590
584
crateConfig = crateConfigs . "${ packageId } " or ( builtins . throw "Package not found: ${ packageId } " ) ;
@@ -605,7 +599,7 @@ rec {
605
599
assert ( builtins . isList dependencies ) ;
606
600
let
607
601
enabledDependencies = filterEnabledDependencies {
608
- inherit dependencies target targetSpec ;
602
+ inherit dependencies target ;
609
603
features = enabledFeatures ;
610
604
} ;
611
605
directDependencies = map depWithResolvedFeatures enabledDependencies ;
@@ -628,7 +622,6 @@ rec {
628
622
crateConfigs
629
623
packageId
630
624
target
631
- targetSpec
632
625
runTests
633
626
rootPackageId
634
627
;
@@ -658,21 +651,19 @@ rec {
658
651
{ dependencies
659
652
, features
660
653
, target
661
- , targetSpec
662
654
,
663
655
} :
664
656
assert ( builtins . isList dependencies ) ;
665
657
assert ( builtins . isList features ) ;
666
- assert ( builtins . isString target ) ;
667
- assert ( builtins . isAttrs targetSpec ) ;
658
+ assert ( builtins . isAttrs target ) ;
668
659
669
660
lib . filter
670
661
(
671
662
dep :
672
663
let
673
664
targetFunc = dep . target or ( features : true ) ;
674
665
in
675
- targetFunc { inherit features target targetSpec ; }
666
+ targetFunc { inherit features target ; }
676
667
&& ( ! ( dep . optional or false ) || builtins . any ( doesFeatureEnableDependency dep ) features )
677
668
)
678
669
dependencies ;
0 commit comments