-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Detox.framework compilation to postinstall (#373)
* Move Detox.framework compilation to postinstall rather than driver prepare to attemp to fix #356 (Timeouts while running detox.init()). * fixed postinstall issues * only build iOS source package on mac
- Loading branch information
Showing
11 changed files
with
99 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const cp = require('child_process'); | ||
|
||
cp.execSync(path.join(__dirname, '../scripts/build_framework.ios.sh'), {stdio: 'inherit'}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
#!/bin/bash -e | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "usage: build_framework_ios.sh detoxIosSourceTarballDirPath detoxFrameworkDirPath" | ||
exit 1 | ||
fi | ||
|
||
detoxIosSourceTarballDirPath="${1}" | ||
detoxFrameworkDirPath="${2}" | ||
detoxVersion=`node -p "require('./package.json').version"` | ||
detoxIosSourceTarballDirPath="$(dirname $(dirname ${0}))" | ||
sha1=`(echo "${detoxVersion}" && xcodebuild -version) | shasum | awk '{print $1}' #"${2}"` | ||
detoxFrameworkDirPath="$HOME/Library/Detox/ios/${sha1}" | ||
detoxFrameworkPath="${detoxFrameworkDirPath}/Detox.framework" | ||
detoxSourcePath="${detoxIosSourceTarballDirPath}"/ios_src | ||
|
||
function buildFramework { | ||
echo "Extracting Detox sources..." | ||
|
||
echo "###############################" | ||
echo "Extracting Detox sources..." | ||
mkdir -p "${detoxSourcePath}" | ||
tar -xjf "${detoxIosSourceTarballDirPath}"/Detox-ios-src.tbz -C "${detoxSourcePath}" | ||
|
||
mkdir -p "${detoxSourcePath}" | ||
tar -xjf "${detoxIosSourceTarballDirPath}"/Detox-ios-src.tbz -C "${detoxSourcePath}" | ||
echo "Building Detox.framework..." | ||
|
||
echo "###############################" | ||
mkdir -p "${detoxFrameworkDirPath}" | ||
xcodebuild build -project "${detoxSourcePath}"/Detox.xcodeproj -scheme DetoxFramework -configuration Release -derivedDataPath "${detoxFrameworkDirPath}"/DetoxBuild BUILD_DIR="${detoxFrameworkDirPath}"/DetoxBuild/Build/Products &> "${detoxFrameworkDirPath}"/detox_ios.log | ||
mv "${detoxFrameworkDirPath}"/DetoxBuild/Build/Products/Release-universal/Detox.framework "${detoxFrameworkDirPath}" | ||
rm -fr "${detoxFrameworkDirPath}"/DetoxBuild | ||
|
||
echo "Done" | ||
} | ||
|
||
echo "###############################" | ||
echo "Extracting Detox sources..." | ||
|
||
mkdir -p "${detoxFrameworkDirPath}" | ||
xcodebuild build -project "${detoxSourcePath}"/Detox.xcodeproj -scheme DetoxFramework -configuration Release -derivedDataPath "${detoxFrameworkDirPath}"/DetoxBuild BUILD_DIR="${detoxFrameworkDirPath}"/DetoxBuild/Build/Products &> "${detoxFrameworkDirPath}"/detox_ios.log | ||
mv "${detoxFrameworkDirPath}"/DetoxBuild/Build/Products/Release-universal/Detox.framework "${detoxFrameworkDirPath}" | ||
rm -fr "${detoxFrameworkDirPath}"/DetoxBuild | ||
function main { | ||
if [ -d "${detoxFrameworkDirPath}" ]; then | ||
if [ ! -d "${detoxFrameworkPath}" ]; then | ||
echo "${detoxFrameworkDirPath} was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted. | ||
deleting ${detoxFrameworkDirPath} and trying to rebuild." | ||
rm -rf "${detoxFrameworkDirPath}" | ||
buildFramework | ||
else | ||
echo "Detox.framework was previously compiled, skipping..." | ||
fi | ||
else | ||
buildFramework | ||
fi | ||
} | ||
|
||
echo "###############################" | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash -e | ||
|
||
if [ "$__DETOX_DEV" = true ]; then | ||
echo "Running postinstall for detox dev mode, exiting" | ||
exit 0 | ||
fi | ||
|
||
if [ `uname` == "Darwin" ]; then | ||
source "$(dirname ${0})/build_framework.ios.sh" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash -e | ||
|
||
# Detox package runs a postinstall script when installed as a dependency in order to compile Detox.framework (iOS). | ||
# In order to install it, the framework sources must be already packaged in Detox-ios-src.tbz. An issue arises when developing Detox, | ||
# since postinstall runs before prepublish, causing the compilation script to start running before the sources are available, | ||
# so we had to add a hack :( to the dev process, skipping postinstall and then manually triggering it. | ||
__DETOX_DEV=true lerna bootstrap | ||
npm run postinstall --prefix detox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters