diff --git a/.gitignore b/.gitignore index 6cc630fde91..eee704bbf51 100644 --- a/.gitignore +++ b/.gitignore @@ -140,7 +140,10 @@ vendor/ /packages/react-native/sdks/hermes /packages/react-native/sdks/hermesc /packages/react-native/sdks/hermes-engine/hermes-engine-from-local-source-dir.tar.gz + +# iOS prebuilds /packages/react-native/third-party/ +fix_glog_0.3.5_apple_silicon.patch # Visual Studio Code (config dir - if present, this merges user defined # workspace settings on top of react-native.code-workspace) diff --git a/scripts/releases/prepare-ios-prebuilds.js b/scripts/releases/prepare-ios-prebuilds.js index 00523409832..cbc67fb6e0d 100644 --- a/scripts/releases/prepare-ios-prebuilds.js +++ b/scripts/releases/prepare-ios-prebuilds.js @@ -11,8 +11,11 @@ require('../babel-register').registerForScript(); +const {execSync} = require('child_process'); const fs = require('fs'); +const path = require('path'); const util = require('util'); + const exec = util.promisify(require('child_process').exec); /*:: @@ -20,14 +23,26 @@ type Dependency = $ReadOnly<{ name: string, version: string, url: URL, + prepareScript?: string, }>; */ +const dependencies /*: $ReadOnlyArray */ = [ + { + name: 'glog', + version: '0.3.5', + url: new URL( + 'https://github.com/google/glog/archive/refs/tags/v0.3.5.tar.gz', + ), + prepareScript: './packages/react-native/scripts/ios-configure-glog.sh', + }, +]; + async function downloadDependency( dependency /*: Dependency*/, ) /*: Promise */ { - const {name, version, url} = dependency; - const filename = `${name}-${version}.tgz`; + const {name, url} = dependency; + const filename = `${name}.tgz`; const archiveDestination = `/tmp/${filename}`; const command = `curl -L ${url.toString()} --output ${archiveDestination}`; @@ -38,15 +53,27 @@ async function downloadDependency( fs.mkdirSync(destination, {recursive: true}); console.log(`Extracting ${filename} to ${destination}...`); - await exec(`tar -xzf ${archiveDestination} -C ${destination}`); + await exec( + `tar -xzf ${archiveDestination} -C ${destination} --strip-components 1`, + ); console.log(`Cleaning up ${filename}...`); await exec(`rm ${archiveDestination}`); + + if (dependency.prepareScript) { + const scriptPath = dependency.prepareScript; + console.log(`Running ${scriptPath}...`); + const finalPath = path.join(destination, 'prepare.sh'); + fs.copyFileSync(scriptPath, finalPath); + execSync('./prepare.sh', {cwd: destination, stdio: 'inherit'}); + } } async function main() { console.log('Starting iOS prebuilds preparation...'); + await Promise.all(dependencies.map(downloadDependency)); + console.log('Done!'); }