Run prepare-for-desktop.sh in an impure shell

This commit is contained in:
Pedro Pombeiro 2019-05-07 17:57:30 +02:00
parent 62614a71d9
commit 93efc0cd05
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
9 changed files with 52 additions and 24 deletions

View File

@ -1,4 +1,4 @@
.PHONY: clean clean-nix react-native test release _list
.PHONY: clean clean-nix react-native-android react-native-ios react-native-desktop test release _list
help: ##@other Show this help
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
@ -81,7 +81,7 @@ release-windows-desktop: ##@build build release for desktop release
@$(MAKE) prod-build-desktop && \
scripts/build-desktop.sh
release-desktop: export TARGET_OS ?= $(HOST_OS)
prod-build: export TARGET_OS ?= all
prod-build:
scripts/prepare-for-platform.sh android && \
scripts/prepare-for-platform.sh ios && \
@ -89,18 +89,15 @@ prod-build:
prod-build-android: export TARGET_OS ?= android
prod-build-android:
scripts/prepare-for-platform.sh android && \
lein prod-build-android
prod-build-ios: export TARGET_OS ?= ios
prod-build-ios:
scripts/prepare-for-platform.sh ios && \
lein prod-build-ios
prod-build-android: export TARGET_OS ?= android
prod-build-desktop: export TARGET_OS ?= $(HOST_OS)
prod-build-desktop:
git clean -qdxf -f ./index.desktop.js desktop/ && \
scripts/prepare-for-platform.sh desktop && \
lein prod-build-desktop
#--------------
@ -110,7 +107,6 @@ prod-build-desktop:
_watch-%: ##@watch Start development for device
$(eval SYSTEM := $(word 2, $(subst -, , $@)))
$(eval DEVICE := $(word 3, $(subst -, , $@)))
scripts/prepare-for-platform.sh $(SYSTEM)
clj -R:dev build.clj watch --platform $(SYSTEM) --$(SYSTEM)-device $(DEVICE)
watch-ios-real: export TARGET_OS ?= ios
@ -130,12 +126,10 @@ watch-android-genymotion: _watch-android-genymotion ##@watch Start development f
watch-desktop: export TARGET_OS ?= $(HOST_OS)
watch-desktop: ##@watch Start development for Desktop
@scripts/prepare-for-platform.sh desktop && \
clj -R:dev build.clj watch --platform desktop
desktop-server: export TARGET_OS ?= $(HOST_OS)
desktop-server:
@scripts/prepare-for-platform.sh desktop && \
node ubuntu-server.js
#--------------
@ -143,12 +137,10 @@ desktop-server:
# -------------
_run-%:
$(eval SYSTEM := $(word 2, $(subst -, , $@)))
@scripts/prepare-for-platform.sh $(SYSTEM) && \
react-native run-$(SYSTEM)
run-android: export TARGET_OS ?= android
run-android: ##@run Run Android build
@scripts/prepare-for-platform.sh android && \
react-native run-android --appIdSuffix debug
run-desktop: export TARGET_OS ?= $(HOST_OS)
@ -158,10 +150,8 @@ SIMULATOR=
run-ios: export TARGET_OS ?= ios
run-ios: ##@run Run iOS build
ifneq ("$(SIMULATOR)", "")
@scripts/prepare-for-platform.sh ios && \
react-native run-ios --simulator="$(SIMULATOR)"
else
@scripts/prepare-for-platform.sh ios && \
react-native run-ios
endif
@ -178,8 +168,16 @@ test-auto: ##@test Run tests in interactive (auto) mode in NodeJS
#--------------
# Other
#--------------
run-desktop: export TARGET_OS ?= $(HOST_OS)
react-native: ##@other Start react native packager
react-native-desktop: export TARGET_OS ?= $(HOST_OS)
react-native-desktop: ##@other Start react native packager
@scripts/start-react-native.sh
react-native-android: export TARGET_OS ?= android
react-native-android: ##@other Start react native packager for Android client
@scripts/start-react-native.sh
react-native-ios: export TARGET_OS ?= ios
react-native-ios: ##@other Start react native packager for Android client
@scripts/start-react-native.sh
geth-connect: export TARGET_OS ?= android
@ -211,7 +209,6 @@ _unknown-startdev-target-%:
_startdev-%:
$(eval SYSTEM := $(word 2, $(subst -, , $@)))
$(eval DEVICE := $(word 3, $(subst -, , $@)))
scripts/prepare-for-platform.sh ${SYSTEM} || exit 1
@ if [ -z "$(DEVICE)" ]; then \
$(MAKE) watch-$(SYSTEM) || $(MAKE) _unknown-startdev-target-$@; \
else \

View File

@ -77,7 +77,7 @@ def prep(type = 'nightly') {
prepareTarget='desktop'
}
/* node deps, pods, and status-go download */
utils.nix_sh "scripts/prepare-for-platform.sh ${prepareTarget}"
utils.nix_impure_sh "scripts/prepare-for-platform.sh ${prepareTarget}"
}
return this

View File

@ -84,7 +84,7 @@ def bundleMacOS(type = 'nightly') {
string(credentialsId: 'desktop-gpg-inner-pass', variable: 'GPG_PASS_INNER'),
string(credentialsId: 'desktop-keychain-pass', variable: 'KEYCHAIN_PASS')
]) {
utils.nix_sh """
utils.nix_impure_sh """
../scripts/sign-macos-pkg.sh Status.app ../deployment/macos/macos-developer-id.keychain-db.gpg && \
../node_modules/appdmg/bin/appdmg.js ../deployment/macos/status-dmg.json ${pkg} && \
../scripts/sign-macos-pkg.sh ${pkg} ../deployment/macos/macos-developer-id.keychain-db.gpg

View File

@ -15,8 +15,16 @@ def getToolVersion(name) {
return version
}
def nix_impure_sh(cmd) {
_nix_sh(cmd, true)
}
def nix_sh(cmd) {
def isPure = env.TARGET_OS != 'windows' && env.TARGET_OS != 'ios' && !cmd.contains('prepare-for-platform.sh')
_nix_sh(cmd, false)
}
def _nix_sh(cmd, forceImpure) {
def isPure = !forceImpure && env.TARGET_OS != 'windows' && env.TARGET_OS != 'ios'
def pureFlag = isPure ? '--pure --keep LOCALE_ARCHIVE_2_27 --keep REALM_DISABLE_ANALYTICS --keep STATUS_RELEASE_STORE_FILE --keep STATUS_RELEASE_STORE_PASSWORD --keep STATUS_RELEASE_KEY_ALIAS --keep STATUS_RELEASE_KEY_PASSWORD --keep GPG_PASS_OUTER --keep GPG_PASS_INNER --keep KEYCHAIN_PASS --keep VERBOSE_LEVEL' : ''
sh """

View File

@ -13,7 +13,7 @@ shift # we remove the first -c from arguments
if ! command -v "nix" >/dev/null 2>&1; then
if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then
. ~/.nix-profile/etc/profile.d/nix.sh
else
elif [ "$IN_NIX_SHELL" != 'pure' ]; then
echo -e "${GREEN}Setting up environment...${NC}"
./scripts/setup
@ -22,8 +22,13 @@ if ! command -v "nix" >/dev/null 2>&1; then
fi
if command -v "nix" >/dev/null 2>&1; then
platform=${TARGET_OS:=all}
if [ "$platform" != 'all' ]; then
# This is a dirty workaround to the fact that 'yarn install' is an impure operation, so we need to call it from an impure shell. Hopefull we'll be able to fix this later on with something like yarn2nix
nix-shell --show-trace --argstr target-os ${TARGET_OS} --run "scripts/prepare-for-platform.sh $platform"
fi
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS:=all}'...${NC}"
echo -e "${GREEN}Configuring Nix shell for target '${TARGET_OS}'...${NC}"
exec nix-shell --show-trace --argstr target-os ${TARGET_OS}
else
is_pure=''
@ -31,7 +36,7 @@ if command -v "nix" >/dev/null 2>&1; then
is_pure='--pure'
pure_desc='pure '
fi
echo -e "${GREEN}Configuring ${pure_desc}Nix shell for target '${TARGET_OS:=all}'...${NC}"
echo -e "${GREEN}Configuring ${pure_desc}Nix shell for target '${TARGET_OS}'...${NC}"
exec nix-shell ${is_pure} --show-trace --argstr target-os ${TARGET_OS} --run "$@"
fi
fi

View File

@ -15,6 +15,14 @@ function is_nixos() {
}
function exit_unless_os_supported() {
if [ "$IN_NIX_SHELL" == 'pure' ]; then
cecho "@red[[This install script is not supported in a pure Nix shell]]
echo
exit 1
fi
if ! is_macos && ! is_linux; then
cecho "@red[[This install script currently supports Mac OS X and Linux \
via apt. To manually install, please visit the docs for more information:]]

View File

@ -1,5 +1,11 @@
#!/usr/bin/env bash
###################################################################################################
#
# Impure setup (any setup here should be minimized and instead be moved to Nix for a pure setup)
#
###################################################################################################
set -e
GIT_ROOT=$(git rev-parse --show-toplevel)
@ -16,7 +22,7 @@ RCTSTATUS_DIR="$GIT_ROOT/modules/react-native-status/ios/RCTStatus"
#if no arguments passed, inform user about possible ones
if [ $# -eq 0 ]; then
echo -e "${GREEN}This script should be invoked with platform argument: 'android', 'ios', or 'desktop'${NC}"
echo -e "${GREEN}This script should be invoked with platform argument: 'android', 'ios', 'desktop', 'windows', 'linux', 'macos' or 'darwin'${NC}"
echo "If invoked with 'android' argument it will link: "
echo "mobile_files/package.json.orig -> package.json"
echo "etc.."
@ -26,6 +32,9 @@ else
android | ios)
PLATFORM='mobile'
;;
windows | linux | macos | darwin)
PLATFORM='desktop'
;;
*)
PLATFORM=$1
;;

View File

@ -3,6 +3,7 @@
########################################################################
# This install script will setup your development dependencies on OS X
# or Ubuntu. Ubuntu 18.04 is the only tested version.
# It is not required or supported in NixOS.
#
# Usage: scripts/setup
########################################################################

View File

@ -43,7 +43,7 @@ in mkShell' {
${projectDeps.shellHook}
${lib.optionalString useFastlanePkg fastlane'.shellHook}
if [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then
if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then
$STATUS_REACT_HOME/scripts/setup
touch $STATUS_REACT_HOME/.ran-setup
fi