From b444e94f0c856b43d4fe43a840f6b5ffa50c0231 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Mon, 17 Mar 2025 11:00:53 +0100 Subject: [PATCH 1/3] [ios][prebuild] fixed inclusion of resources in swift package We had some issues with the Swift package build step where we saw an error message when we included resources and couldn't find out why this was happening. After systematically going through the generated swift package file and looking for a reason I found a mistake. When we generate the Package.swift file we pass all compilerFlags from the configuration of the target to both cpp/c flags - which in the case of the folly target ends up being passed to the dependency scanner which isn't too happy about this c++ flag. The solution is to break out the c++ stdlib version as a separate setting in the configuration and pass it only to the `cxxSettings` section in our final Package.swift file. This commit fixes this by: - Adding a new field in the dependency settings struct called `cppVersion` - Updated configuration with correct resources and cppVersion for relevant targets - Now emits the correct cppVersion to the cxxSettings section - Fixed issue with the copy bundles step that didn't copy the directory in some cases. --- .../releases/ios-prebuild/compose-framework.js | 4 +++- scripts/releases/ios-prebuild/configuration.js | 15 ++++++++------- scripts/releases/ios-prebuild/swift-package.js | 7 +++++++ scripts/releases/ios-prebuild/types.js | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/releases/ios-prebuild/compose-framework.js b/scripts/releases/ios-prebuild/compose-framework.js index 6fb050de1c5dca..d78f14ccdd795d 100644 --- a/scripts/releases/ios-prebuild/compose-framework.js +++ b/scripts/releases/ios-prebuild/compose-framework.js @@ -113,6 +113,7 @@ function copyBundles( targetArchFolder, `${scheme}.framework`, 'Resources', + bundleName, ); if ( !fs.existsSync(path.join(targetArchFolder, `${scheme}.framework`)) @@ -123,7 +124,8 @@ function copyBundles( console.warn("Source bundle doesn't exist", sourceBundlePath); } // A bundle is a directory, so we need to copy the whole directory - execSync(`cp -r ${sourceBundlePath} ${targetBundlePath}`); + execSync(`mkdir -p "${targetBundlePath}"`); + execSync(`cp -r "${sourceBundlePath}/" "${targetBundlePath}"`); }); } else { console.warn(`Bundle ${sourceBundlePath} not found`); diff --git a/scripts/releases/ios-prebuild/configuration.js b/scripts/releases/ios-prebuild/configuration.js index 805d5d1e6dd48a..efd6577289bd39 100644 --- a/scripts/releases/ios-prebuild/configuration.js +++ b/scripts/releases/ios-prebuild/configuration.js @@ -48,7 +48,7 @@ const dependencies /*: $ReadOnlyArray */ = [ 'src/vlog_is_on.cc', ], headers: ['src/glog/*.h'], - // resources: ['../third-party-podspecs/glog/PrivacyInfo.xcprivacy'], + resources: ['../third-party-podspecs/glog/PrivacyInfo.xcprivacy'], headerSkipFolderNames: 'src', }, settings: { @@ -94,7 +94,8 @@ const dependencies /*: $ReadOnlyArray */ = [ publicHeaderFiles: './include', headerSearchPaths: ['include'], linkedLibraries: ['c++'], - compilerFlags: ['-Wno-everything', `-std=${CPP_STANDARD}`], + compilerFlags: ['-Wno-everything'], + cppVersion: CPP_STANDARD, }, }, { @@ -107,7 +108,7 @@ const dependencies /*: $ReadOnlyArray */ = [ files: { sources: ['boost/**/*.hpp', 'dummy.cc'], headers: ['boost/**/*.hpp'], - // resources: ['../third-party-podspecs/boost/PrivacyInfo.xcprivacy'], + resources: ['../third-party-podspecs/boost/PrivacyInfo.xcprivacy'], }, settings: { publicHeaderFiles: './', @@ -130,7 +131,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './include', headerSearchPaths: ['include'], - compilerFlags: ['-Wno-everything', `-std=${CPP_STANDARD}`], + compilerFlags: ['-Wno-everything'], + cppVersion: CPP_STANDARD, linkedLibraries: ['c++'], }, }, @@ -245,8 +247,7 @@ const dependencies /*: $ReadOnlyArray */ = [ 'folly/portability/*.h', 'folly/system/*.h', ], - // TODO: When including this we get "failed to scan dependencies" error - // resources: ['../third-party-podspecs/RCT-Folly/PrivacyInfo.xcprivacy'], + resources: ['../third-party-podspecs/RCT-Folly/PrivacyInfo.xcprivacy'], }, dependencies: [ 'glog', @@ -261,11 +262,11 @@ const dependencies /*: $ReadOnlyArray */ = [ headerSearchPaths: ['./'], compilerFlags: [ '-Wno-everything', - `-std=${CPP_STANDARD}`, '-faligned-new', '-Wno-shorten-64-to-32', '-Wno-comma', ], + cppVersion: CPP_STANDARD, defines: [ {name: 'USE_HEADERMAP', value: 'NO'}, {name: 'DEFINES_MODULE', value: 'YES'}, diff --git a/scripts/releases/ios-prebuild/swift-package.js b/scripts/releases/ios-prebuild/swift-package.js index 725b4315618524..038c1ef82a2b95 100644 --- a/scripts/releases/ios-prebuild/swift-package.js +++ b/scripts/releases/ios-prebuild/swift-package.js @@ -73,6 +73,12 @@ function createSwiftTarget(dependency /* :Dependency */) { unsafeCAndCxxSettings = `.unsafeFlags([${dependency.settings.compilerFlags.map(flag => `"${flag}"`).join(', ')}]),`; } + // Add c++ version to c++ settings if provided + let unsafeCxxSettings = ''; + if (dependency.settings.cppVersion != null) { + unsafeCxxSettings = `.unsafeFlags(["-std=${dependency.settings.cppVersion}"]),`; + } + // Setup defines let defines = ''; if (dependency.settings.defines != null) { @@ -127,6 +133,7 @@ function createSwiftTarget(dependency /* :Dependency */) { ${headerSearchPaths} ${unsafeCAndCxxSettings} ${defines} + ${unsafeCxxSettings} ], linkerSettings: [ ${linkedLibraries} diff --git a/scripts/releases/ios-prebuild/types.js b/scripts/releases/ios-prebuild/types.js index 2d842afca77a72..434837a0114d6e 100644 --- a/scripts/releases/ios-prebuild/types.js +++ b/scripts/releases/ios-prebuild/types.js @@ -32,6 +32,7 @@ export type Settings = $ReadOnly<{ headerSearchPaths?: $ReadOnlyArray, defines?: $ReadOnlyArray, compilerFlags?: $ReadOnlyArray, + cppVersion?: string, linkedLibraries?: $ReadOnlyArray, publicHeaderFiles: string, linkerSettings?: $ReadOnlyArray From ff753e3e4e31ef796e585f24ec4429ac42ad6098 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Mon, 17 Mar 2025 11:19:50 +0100 Subject: [PATCH 2/3] [ios][prebuild] split configuration in c and c++ flags Instead of passing the compilerFlags settings to both c and cxx these are now split in two so that it is easy to provide different flags to the cxx compiler (setting the correcct std-lib version f.ex). --- .../releases/ios-prebuild/configuration.js | 30 ++++++++++++------- .../releases/ios-prebuild/swift-package.js | 15 +++++----- scripts/releases/ios-prebuild/types.js | 4 +-- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/scripts/releases/ios-prebuild/configuration.js b/scripts/releases/ios-prebuild/configuration.js index efd6577289bd39..5397a0b8ae9178 100644 --- a/scripts/releases/ios-prebuild/configuration.js +++ b/scripts/releases/ios-prebuild/configuration.js @@ -54,7 +54,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './headers', headerSearchPaths: ['src'], - compilerFlags: ['-Wno-shorten-64-to-32', '-Wno-everything'], + cCompilerFlags: ['-Wno-shorten-64-to-32', '-Wno-everything'], + cxxCompilerFlags: ['-Wno-shorten-64-to-32', '-Wno-everything'], defines: [ {name: 'DEFINES_MODULE', value: 'YES'}, {name: 'USE_HEADERMAP', value: 'NO'}, @@ -76,7 +77,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './headers', headerSearchPaths: ['src'], - compilerFlags: ['-Wno-everything'], + cCompilerFlags: ['-Wno-everything'], + cxxCompilerFlags: ['-Wno-everything'], }, }, { @@ -94,8 +96,8 @@ const dependencies /*: $ReadOnlyArray */ = [ publicHeaderFiles: './include', headerSearchPaths: ['include'], linkedLibraries: ['c++'], - compilerFlags: ['-Wno-everything'], - cppVersion: CPP_STANDARD, + cCompilerFlags: ['-Wno-everything'], + cxxCompilerFlags: ['-Wno-everything', `-std=${CPP_STANDARD}`], }, }, { @@ -113,7 +115,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './', headerSearchPaths: ['./'], - compilerFlags: ['-Wno-everything', '-Wno-documentation'], + cCompilerFlags: ['-Wno-everything', '-Wno-documentation'], + cxxCompilerFlags: ['-Wno-everything', '-Wno-documentation'], }, }, { @@ -131,8 +134,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './include', headerSearchPaths: ['include'], - compilerFlags: ['-Wno-everything'], - cppVersion: CPP_STANDARD, + cCompilerFlags: ['-Wno-everything'], + cxxCompilerFlags: ['-Wno-everything', `-std=${CPP_STANDARD}`], linkedLibraries: ['c++'], }, }, @@ -160,7 +163,8 @@ const dependencies /*: $ReadOnlyArray */ = [ 'SocketRocket/Internal/Security', 'SocketRocket/Internal/Utilities', ], - compilerFlags: ['-Wno-everything'], + cCompilerFlags: ['-Wno-everything'], + cxxCompilerFlags: ['-Wno-everything'], }, }, { @@ -260,13 +264,19 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './', headerSearchPaths: ['./'], - compilerFlags: [ + cCompilerFlags: [ '-Wno-everything', '-faligned-new', '-Wno-shorten-64-to-32', '-Wno-comma', ], - cppVersion: CPP_STANDARD, + cxxCompilerFlags: [ + '-Wno-everything', + '-faligned-new', + '-Wno-shorten-64-to-32', + '-Wno-comma', + `-std=${CPP_STANDARD}`, + ], defines: [ {name: 'USE_HEADERMAP', value: 'NO'}, {name: 'DEFINES_MODULE', value: 'YES'}, diff --git a/scripts/releases/ios-prebuild/swift-package.js b/scripts/releases/ios-prebuild/swift-package.js index 038c1ef82a2b95..7c3cd3d20fb926 100644 --- a/scripts/releases/ios-prebuild/swift-package.js +++ b/scripts/releases/ios-prebuild/swift-package.js @@ -68,15 +68,15 @@ ${dependencies.map(d => createSwiftTarget(d)).join('')} */ function createSwiftTarget(dependency /* :Dependency */) { // Setup unsafe flags - let unsafeCAndCxxSettings = ''; - if (dependency.settings.compilerFlags != null) { - unsafeCAndCxxSettings = `.unsafeFlags([${dependency.settings.compilerFlags.map(flag => `"${flag}"`).join(', ')}]),`; + let unsafeCSettings = ''; + if (dependency.settings.cCompilerFlags != null) { + unsafeCSettings = `.unsafeFlags([${dependency.settings.cCompilerFlags.map(flag => `"${flag}"`).join(', ')}]),`; } // Add c++ version to c++ settings if provided let unsafeCxxSettings = ''; - if (dependency.settings.cppVersion != null) { - unsafeCxxSettings = `.unsafeFlags(["-std=${dependency.settings.cppVersion}"]),`; + if (dependency.settings.cxxCompilerFlags != null) { + unsafeCxxSettings = `.unsafeFlags([${dependency.settings.cxxCompilerFlags.map(flag => `"${flag}"`).join(', ')}]),`; } // Setup defines @@ -126,14 +126,13 @@ function createSwiftTarget(dependency /* :Dependency */) { publicHeadersPath: "${dependency.settings.publicHeaderFiles}", cSettings: [ ${headerSearchPaths} - ${unsafeCAndCxxSettings} + ${unsafeCSettings} ${defines} ], cxxSettings: [ ${headerSearchPaths} - ${unsafeCAndCxxSettings} - ${defines} ${unsafeCxxSettings} + ${defines} ], linkerSettings: [ ${linkedLibraries} diff --git a/scripts/releases/ios-prebuild/types.js b/scripts/releases/ios-prebuild/types.js index 434837a0114d6e..4a805b79cf4a27 100644 --- a/scripts/releases/ios-prebuild/types.js +++ b/scripts/releases/ios-prebuild/types.js @@ -31,8 +31,8 @@ export type Define = $ReadOnly<{ export type Settings = $ReadOnly<{ headerSearchPaths?: $ReadOnlyArray, defines?: $ReadOnlyArray, - compilerFlags?: $ReadOnlyArray, - cppVersion?: string, + cCompilerFlags?: $ReadOnlyArray, + cxxCompilerFlags?: $ReadOnlyArray, linkedLibraries?: $ReadOnlyArray, publicHeaderFiles: string, linkerSettings?: $ReadOnlyArray From f771711024dae6d84f13fa095c6deaabb8bc8043 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Mon, 17 Mar 2025 11:35:12 +0100 Subject: [PATCH 3/3] [ios][prebuild] cleanup configuration - Added c++ standard to all targets - Removed -Wno-everything from all targets --- .../releases/ios-prebuild/configuration.js | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/scripts/releases/ios-prebuild/configuration.js b/scripts/releases/ios-prebuild/configuration.js index 5397a0b8ae9178..3cd64cfe80e78e 100644 --- a/scripts/releases/ios-prebuild/configuration.js +++ b/scripts/releases/ios-prebuild/configuration.js @@ -54,8 +54,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './headers', headerSearchPaths: ['src'], - cCompilerFlags: ['-Wno-shorten-64-to-32', '-Wno-everything'], - cxxCompilerFlags: ['-Wno-shorten-64-to-32', '-Wno-everything'], + cCompilerFlags: ['-Wno-shorten-64-to-32'], + cxxCompilerFlags: ['-Wno-shorten-64-to-32', `-std=${CPP_STANDARD}`], defines: [ {name: 'DEFINES_MODULE', value: 'YES'}, {name: 'USE_HEADERMAP', value: 'NO'}, @@ -77,8 +77,6 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './headers', headerSearchPaths: ['src'], - cCompilerFlags: ['-Wno-everything'], - cxxCompilerFlags: ['-Wno-everything'], }, }, { @@ -96,8 +94,7 @@ const dependencies /*: $ReadOnlyArray */ = [ publicHeaderFiles: './include', headerSearchPaths: ['include'], linkedLibraries: ['c++'], - cCompilerFlags: ['-Wno-everything'], - cxxCompilerFlags: ['-Wno-everything', `-std=${CPP_STANDARD}`], + cxxCompilerFlags: [`-std=${CPP_STANDARD}`], }, }, { @@ -115,8 +112,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './', headerSearchPaths: ['./'], - cCompilerFlags: ['-Wno-everything', '-Wno-documentation'], - cxxCompilerFlags: ['-Wno-everything', '-Wno-documentation'], + cCompilerFlags: ['-Wno-documentation'], + cxxCompilerFlags: ['-Wno-documentation', `-std=${CPP_STANDARD}`], }, }, { @@ -134,8 +131,7 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './include', headerSearchPaths: ['include'], - cCompilerFlags: ['-Wno-everything'], - cxxCompilerFlags: ['-Wno-everything', `-std=${CPP_STANDARD}`], + cxxCompilerFlags: [`-std=${CPP_STANDARD}`], linkedLibraries: ['c++'], }, }, @@ -163,8 +159,6 @@ const dependencies /*: $ReadOnlyArray */ = [ 'SocketRocket/Internal/Security', 'SocketRocket/Internal/Utilities', ], - cCompilerFlags: ['-Wno-everything'], - cxxCompilerFlags: ['-Wno-everything'], }, }, { @@ -264,14 +258,8 @@ const dependencies /*: $ReadOnlyArray */ = [ settings: { publicHeaderFiles: './', headerSearchPaths: ['./'], - cCompilerFlags: [ - '-Wno-everything', - '-faligned-new', - '-Wno-shorten-64-to-32', - '-Wno-comma', - ], + cCompilerFlags: ['-faligned-new', '-Wno-shorten-64-to-32', '-Wno-comma'], cxxCompilerFlags: [ - '-Wno-everything', '-faligned-new', '-Wno-shorten-64-to-32', '-Wno-comma',