Skip to content

Commit

Permalink
First attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
takameyer committed Oct 10, 2023
1 parent fb9c9e4 commit 70161c9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 41 deletions.
14 changes: 14 additions & 0 deletions install-tests/react-native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# How to use

`npm install`

`npm run cli`


There are two commands for the cli tool:
`init` and `test`


`npm run cli init -- --react-native-version next --realm-version latest`

ran into issues using `bundle` to run pod install and so. Not looking into this right now
22 changes: 6 additions & 16 deletions install-tests/react-native/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const DEFAULT_APP_PATH = path.resolve(__dirname, "app");
const PATCHES_PATH = path.resolve(__dirname, "patches");
const APP_JS_PATH = path.resolve(PATCHES_PATH, "App.js");
const CCACHE_PODFILE_PATCH_PATH = path.resolve(PATCHES_PATH, "ccache-Podfile.patch");
const JSC_PODFILE_PATCH_PATH = path.resolve(PATCHES_PATH, "jsc-Podfile.patch");
const JSC_BUILD_GRADLE_PATCH_PATH = path.resolve(PATCHES_PATH, "jsc-build.gradle.patch");
const CCACHE_PODFILE_PATCH_PATH_PRE_73 = path.resolve(PATCHES_PATH, "ccache-Podfile-pre-73.patch");
const PORT = 3000;
const TIMEOUT = 5 * 60 * 1000; // 5 min should be plenty of time from app has launched until message gets received

Expand Down Expand Up @@ -160,26 +159,17 @@ yargs(hideBin(process.argv))
// We're using force to succeed on peer dependency issues
exec("npm", ["install", `realm@${realmVersion}`, "--force"], { cwd: appPath });

const podfilePath = path.resolve(appPath, "ios", "Podfile");
console.log(`Patching podfile to use ccache (${podfilePath})`);
applyPatch(CCACHE_PODFILE_PATCH_PATH, podfilePath);

const { version: resolvedReactNativeVersion } = readPackageJson(
path.resolve(appPath, "node_modules/react-native"),
);

// TODO: Delete this once 0.71.0 or above is latest
if (semver.satisfies(resolvedReactNativeVersion, "<0.71.0")) {
if (engine === "jsc") {
console.log(`Patching Podfile to use JSC (${podfilePath})`);
applyPatch(JSC_PODFILE_PATCH_PATH, podfilePath);
const podfilePath = path.resolve(appPath, "ios", "Podfile");
console.log(`Patching podfile to use ccache (${podfilePath})`);

const appGradleBuildPath = path.resolve(appPath, "android", "app", "build.gradle");
console.log(`Patching app/build.gradle to use JSC (${appGradleBuildPath})`);
applyPatch(JSC_BUILD_GRADLE_PATCH_PATH, appGradleBuildPath);
}
if (semver.satisfies(resolvedReactNativeVersion, "<0.73.0")) {
applyPatch(CCACHE_PODFILE_PATCH_PATH_PRE_73, podfilePath);
} else {
console.log("Skipping patch of Podfile to use JSC, relying on USE_HERMES env variable instead");
applyPatch(CCACHE_PODFILE_PATCH_PATH, podfilePath);
}

// Store Gradle properties for RN >=0.71.0
Expand Down
18 changes: 18 additions & 0 deletions install-tests/react-native/patches/ccache-Podfile-pre-73.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- app/ios/Podfile
+++ app/ios/Podfile
@@ -39,5 +39,15 @@
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
+ # Using ccache when building
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
+ # Using the un-qualified names means you can swap in different implementations, for example ccache
+ config.build_settings["CC"] = "clang"
+ config.build_settings["LD"] = "clang"
+ config.build_settings["CXX"] = "clang++"
+ config.build_settings["LDPLUSPLUS"] = "clang++"
+ end
+ end
end
end
8 changes: 4 additions & 4 deletions install-tests/react-native/patches/ccache-Podfile.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--- app/ios/Podfile
+++ app/ios/Podfile
@@ -39,5 +39,15 @@
--- Podfile.copy 2023-10-09 15:29:25
+++ Podfile 2023-10-09 15:29:42
@@ -51,5 +51,15 @@
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
+ # Using ccache when building
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
Expand Down
10 changes: 0 additions & 10 deletions install-tests/react-native/patches/jsc-Podfile.patch

This file was deleted.

11 changes: 0 additions & 11 deletions install-tests/react-native/patches/jsc-build.gradle.patch

This file was deleted.

0 comments on commit 70161c9

Please sign in to comment.