@@ -24,6 +24,8 @@ import func TSCBasic.topologicalSort
24
24
25
25
/// The parameters required by `PIFBuilder`.
26
26
struct PIFBuilderParameters {
27
+ let triple : Triple
28
+
27
29
/// Whether the toolchain supports `-package-name` option.
28
30
let isPackageAccessModifierSupported : Bool
29
31
@@ -427,7 +429,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
427
429
guid: product. pifTargetGUID,
428
430
name: self . targetName ( for: product) ,
429
431
productType: productType,
430
- productName: product. name
432
+ productName: " \( product. name) \( parameters . triple . executableExtension ) "
431
433
)
432
434
433
435
// We'll be infusing the product's main module target into the one for the product itself.
@@ -445,18 +447,19 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
445
447
var settings = PIF . BuildSettings ( )
446
448
settings [ . TARGET_NAME] = product. name
447
449
settings [ . PACKAGE_RESOURCE_TARGET_KIND] = " regular "
448
- settings [ . PRODUCT_NAME] = product . name
450
+ settings [ . PRODUCT_NAME] = " $(TARGET_NAME) "
449
451
settings [ . PRODUCT_MODULE_NAME] = mainTarget. c99name
450
452
settings [ . PRODUCT_BUNDLE_IDENTIFIER] = product. name
451
- settings [ . EXECUTABLE_NAME] = product. name
452
453
settings [ . CLANG_ENABLE_MODULES] = " YES "
453
454
settings [ . DEFINES_MODULE] = " YES "
454
455
455
456
if product. type == . executable || product. type == . test {
456
- settings [ . LIBRARY_SEARCH_PATHS] = [
457
- " $(inherited) " ,
458
- " \( self . parameters. toolchainLibDir. pathString) /swift/macosx " ,
459
- ]
457
+ if let darwinPlatform = parameters. triple. darwinPlatform {
458
+ settings [ . LIBRARY_SEARCH_PATHS] = [
459
+ " $(inherited) " ,
460
+ " \( self . parameters. toolchainLibDir. pathString) /swift/ \( darwinPlatform. platformName) " ,
461
+ ]
462
+ }
460
463
}
461
464
462
465
// Tests can have a custom deployment target based on the minimum supported by XCTest.
@@ -525,22 +528,19 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
525
528
}
526
529
527
530
private func addLibraryTarget( for product: ResolvedProduct ) {
531
+ // For the name of the product reference
528
532
let pifTargetProductName : String
529
- let executableName : String
530
533
let productType : PIF . Target . ProductType
531
534
if product. type == . library( . dynamic) {
532
535
if self . parameters. shouldCreateDylibForDynamicProducts {
533
- pifTargetProductName = " lib \( product. name) .dylib "
534
- executableName = pifTargetProductName
536
+ pifTargetProductName = " \( parameters. triple. dynamicLibraryPrefix) \( product. name) \( parameters. triple. dynamicLibraryExtension) "
535
537
productType = . dynamicLibrary
536
538
} else {
537
539
pifTargetProductName = product. name + " .framework "
538
- executableName = product. name
539
540
productType = . framework
540
541
}
541
542
} else {
542
- pifTargetProductName = " lib \( product. name) .a "
543
- executableName = pifTargetProductName
543
+ pifTargetProductName = " lib \( product. name) \( parameters. triple. staticLibraryExtension) "
544
544
productType = . packageProduct
545
545
}
546
546
@@ -582,18 +582,20 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
582
582
// Add other build settings when we're building an actual dylib.
583
583
if product. type == . library( . dynamic) {
584
584
settings [ . TARGET_NAME] = product. name
585
- settings [ . PRODUCT_NAME] = executableName
585
+ settings [ . PRODUCT_NAME] = " $(TARGET_NAME) "
586
586
settings [ . PRODUCT_MODULE_NAME] = product. name
587
587
settings [ . PRODUCT_BUNDLE_IDENTIFIER] = product. name
588
- settings [ . EXECUTABLE_NAME ] = executableName
588
+ settings [ . EXECUTABLE_PREFIX ] = parameters . triple . dynamicLibraryPrefix
589
589
settings [ . CLANG_ENABLE_MODULES] = " YES "
590
590
settings [ . DEFINES_MODULE] = " YES "
591
591
settings [ . SKIP_INSTALL] = " NO "
592
592
settings [ . INSTALL_PATH] = " /usr/local/lib "
593
- settings [ . LIBRARY_SEARCH_PATHS] = [
594
- " $(inherited) " ,
595
- " \( self . parameters. toolchainLibDir. pathString) /swift/macosx " ,
596
- ]
593
+ if let darwinPlatform = parameters. triple. darwinPlatform {
594
+ settings [ . LIBRARY_SEARCH_PATHS] = [
595
+ " $(inherited) " ,
596
+ " \( self . parameters. toolchainLibDir. pathString) /swift/ \( darwinPlatform. platformName) " ,
597
+ ]
598
+ }
597
599
598
600
if !self . parameters. shouldCreateDylibForDynamicProducts {
599
601
settings [ . GENERATE_INFOPLIST_FILE] = " YES "
@@ -622,16 +624,15 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
622
624
guid: target. pifTargetGUID,
623
625
name: target. name,
624
626
productType: . objectFile,
625
- productName: " \( target. name) .o "
627
+ productName: " \( target. name) _Module .o"
626
628
)
627
629
628
630
var settings = PIF . BuildSettings ( )
629
- settings [ . TARGET_NAME] = target. name
631
+ settings [ . TARGET_NAME] = target. name + " _Module "
630
632
settings [ . PACKAGE_RESOURCE_TARGET_KIND] = " regular "
631
- settings [ . PRODUCT_NAME] = " \( target . name ) .o "
633
+ settings [ . PRODUCT_NAME] = " $(TARGET_NAME) "
632
634
settings [ . PRODUCT_MODULE_NAME] = target. c99name
633
635
settings [ . PRODUCT_BUNDLE_IDENTIFIER] = target. name
634
- settings [ . EXECUTABLE_NAME] = " \( target. name) .o "
635
636
settings [ . CLANG_ENABLE_MODULES] = " YES "
636
637
settings [ . DEFINES_MODULE] = " YES "
637
638
settings [ . MACH_O_TYPE] = " mh_object "
@@ -898,7 +899,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
898
899
899
900
var settings = PIF . BuildSettings ( )
900
901
settings [ . TARGET_NAME] = bundleName
901
- settings [ . PRODUCT_NAME] = bundleName
902
+ settings [ . PRODUCT_NAME] = " $(TARGET_NAME) "
902
903
settings [ . PRODUCT_MODULE_NAME] = bundleName
903
904
let bundleIdentifier = " \( package . manifest. displayName) . \( target. name) .resources "
904
905
. spm_mangledToBundleIdentifier ( ) // TODO: use identity instead?
@@ -928,7 +929,7 @@ final class PackagePIFProjectBuilder: PIFProjectBuilder {
928
929
929
930
let targetGroup = groupTree. addGroup ( path: " / " , sourceTree: . group)
930
931
pifTarget. addResourceFile ( targetGroup. addFileReference (
931
- path: " \( bundleName) .bundle " ,
932
+ path: " \( bundleName) \( parameters . triple . nsbundleExtension ) " ,
932
933
sourceTree: . builtProductsDir
933
934
) )
934
935
0 commit comments