MCPcopy Create free account
hub / github.com/expo/expo / createModuleMapWithUmbrellaHeaderFilesAsync

Function createModuleMapWithUmbrellaHeaderFilesAsync

tools/src/prebuilds/Frameworks.ts:704–922  ·  view source on GitHub ↗
(
  frameworkSlicePath: string,
  product: SPMProduct,
  umbrellaHeaderFiles: string[],
  hasSwiftTarget: boolean = false,
  targetModuleNames: Map<string, string[]> = new Map(),
  textualHeaderModules: Set<string> = new Set()
)

Source from the content-addressed store, hash-verified

702 * @param textualHeaderModules Set of module names that should use textual headers (not compiled as part of module)
703 */
704const 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) {

Callers 1

processXCFrameworkSlicesFunction · 0.85

Calls 11

isTextualHeaderFunction · 0.85
isExcludedFromUmbrellaFunction · 0.85
entriesMethod · 0.80
hasMethod · 0.80
joinMethod · 0.80
dirnameMethod · 0.80
writeFileMethod · 0.80
everyMethod · 0.80
mapMethod · 0.80
filterMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…