( frameworkSlicePath: string, product: SPMProduct, umbrellaHeaderFiles: string[], hasSwiftTarget: boolean = false, targetModuleNames: Map<string, string[]> = new Map(), textualHeaderModules: Set<string> = new Set() )
| 702 | * @param textualHeaderModules Set of module names that should use textual headers (not compiled as part of module) |
| 703 | */ |
| 704 | const createModuleMapWithUmbrellaHeaderFilesAsync = async ( |
| 705 | frameworkSlicePath: string, |
| 706 | product: SPMProduct, |
| 707 | umbrellaHeaderFiles: string[], |
| 708 | hasSwiftTarget: boolean = false, |
| 709 | targetModuleNames: Map<string, string[]> = new Map(), |
| 710 | textualHeaderModules: Set<string> = new Set() |
| 711 | ): Promise<void> => { |
| 712 | const hasObjCHeaders = umbrellaHeaderFiles.length > 0; |
| 713 | const productName = product.name; |
| 714 | |
| 715 | // If no ObjC headers and no Swift target, nothing to generate |
| 716 | if (!hasObjCHeaders && !hasSwiftTarget) { |
| 717 | return; |
| 718 | } |
| 719 | |
| 720 | const umbrellaName = `${productName}_umbrella.h`; |
| 721 | |
| 722 | // Check if product has textualHeaders patterns configured |
| 723 | const textualHeaderPatterns = product.textualHeaders ?? []; |
| 724 | const hasTextualPatterns = textualHeaderPatterns.length > 0; |
| 725 | |
| 726 | // Check if product has excludeFromUmbrella patterns configured |
| 727 | const excludeFromUmbrellaPatterns = product.excludeFromUmbrella ?? []; |
| 728 | |
| 729 | // Helper to check if a header matches any pattern in a list |
| 730 | const matchesPattern = (headerName: string, patterns: string[]): boolean => { |
| 731 | if (patterns.length === 0) return false; |
| 732 | return patterns.some((pattern) => { |
| 733 | // Convert glob pattern to regex |
| 734 | // First escape all regex special characters, then convert glob wildcards |
| 735 | const regexPattern = pattern |
| 736 | .replace(/[.+^${}()|[\]\\]/g, '\\$&') |
| 737 | .replace(/\*/g, '.*') |
| 738 | .replace(/\?/g, '.'); |
| 739 | return new RegExp(`^${regexPattern}$`).test(headerName); |
| 740 | }); |
| 741 | }; |
| 742 | |
| 743 | // Helper to check if a header matches any textual pattern |
| 744 | const isTextualHeader = (headerName: string): boolean => { |
| 745 | return matchesPattern(headerName, textualHeaderPatterns); |
| 746 | }; |
| 747 | |
| 748 | // Helper to check if a header should be excluded from umbrella |
| 749 | const isExcludedFromUmbrella = (headerName: string): boolean => { |
| 750 | return matchesPattern(headerName, excludeFromUmbrellaPatterns); |
| 751 | }; |
| 752 | |
| 753 | // Build the module map content |
| 754 | let moduleMapContent = ''; |
| 755 | |
| 756 | moduleMapContent += `framework module ${productName} {\n`; |
| 757 | |
| 758 | // Add `use` directives for external dependencies (like React) |
| 759 | // This tells the module system that this module requires these dependencies to compile |
| 760 | const externalDeps = product.externalDependencies ?? []; |
| 761 | for (const dep of externalDeps) { |
no test coverage detected
searching dependent graphs…