Skip to content

Commit

Permalink
Merge pull request #621 from wix/DevFrameworkBuild
Browse files Browse the repository at this point in the history
Internal: Add prod/dev awareness to scripts building Detox.framework for easier native development process
  • Loading branch information
rotemmiz committed Mar 14, 2018
2 parents fc34444 + 73393c3 commit b62db86
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
37 changes: 25 additions & 12 deletions detox/scripts/build_framework.ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,52 @@ detoxVersion=`node -p "require('${detoxRootPath}/package.json').version"`
sha1=`(echo "${detoxVersion}" && xcodebuild -version) | shasum | awk '{print $1}' #"${2}"`
detoxFrameworkDirPath="$HOME/Library/Detox/ios/${sha1}"
detoxFrameworkPath="${detoxFrameworkDirPath}/Detox.framework"
detoxSourcePath="${detoxRootPath}"/ios_src

function buildFramework {
echo "Extracting Detox sources..."

function prepareAndBuildFramework () {
if [ -d "$detoxRootPath"/ios ]; then
detoxSourcePath="${detoxRootPath}"/ios
echo "Dev mode, will build from ${detoxSourcePath}"
buildFramework "${detoxSourcePath}"
else
detoxSourcePath="${detoxRootPath}"/ios_src
extractSources "${detoxSourcePath}"
buildFramework "${detoxSourcePath}"
rm -fr "${detoxSourcePath}"
fi
}

function extractSources () {
detoxSourcePath="${1}"
echo "Extracting Detox sources..."
mkdir -p "${detoxSourcePath}"
tar -xjf "${detoxRootPath}"/Detox-ios-src.tbz -C "${detoxSourcePath}"
}

echo "Building Detox.framework..."

function buildFramework () {
detoxSourcePath="${1}"
echo "Building Detox.framework from ${detoxSourcePath}..."
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
rm -fr "${detoxSourcePath}"

echo "Done"
}


function main {
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
prepareAndBuildFramework
else
echo "Detox.framework was previously compiled, skipping..."
fi
else
buildFramework
prepareAndBuildFramework
fi

echo "Done"
}

main
5 changes: 0 additions & 5 deletions detox/scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/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
2 changes: 1 addition & 1 deletion docs/Guide.Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ git submodule update --init --recursive
### Installing and linking internal projects

```sh
scripts/bootstrap.sh
lerna bootstrap
```

### Building
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-native-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"e2e": "mocha e2e --opts ./e2e/mocha.opts"
},
"devDependencies": {
"mocha": "^3.2.0",
"detox": "^6.0.0"
"mocha": "^4.0.0",
"detox": "^7.0.0"
},
"detox": {}
}
4 changes: 2 additions & 2 deletions examples/demo-native-ios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.1",
"private": true,
"devDependencies": {
"mocha": "^3.2.0",
"detox": "^6.0.0"
"mocha": "^4.0.0",
"detox": "^7.0.0"
},
"detox": {
"specs": "e2e",
Expand Down
8 changes: 0 additions & 8 deletions scripts/bootstrap.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ ! -z ${REACT_NATIVE_VERSION} ]; then
node scripts/change_react_native_version.js "detox/test" ${REACT_NATIVE_VERSION}
fi

run_f "$(dirname "$0")/bootstrap.sh"
run_f "lerna bootstrap"

run_f "lerna run --ignore detox-demo* build"
run_f "lerna run --ignore detox-demo* test"
2 changes: 1 addition & 1 deletion scripts/demo-projects.ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source $(dirname "$0")/travis_logger.sh

run_f "$(dirname "$0")/bootstrap.sh"
run_f "lerna bootstrap"

pushd examples/demo-react-native
run_f "detox build -c ios.sim.release"
Expand Down

0 comments on commit b62db86

Please sign in to comment.