Skip to content

Commit 3ecb3c5

Browse files
authored
Merge pull request #1180 from catarial/fix-setup
Minor fixes for setup_native.sh
2 parents cfa709f + 6dd71f1 commit 3ecb3c5

File tree

2 files changed

+67
-86
lines changed

2 files changed

+67
-86
lines changed

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,10 @@ builds with your configuration. That is almost certainly the source of the error
143143
144144
Installing (one time only)
145145
---
146-
Run the setup script for the platform you want to build
146+
Run the setup script
147147
148148
```
149-
bash setup/setup_android_native.sh
150-
```
151-
AND/OR
152-
```
153-
bash setup/setup_ios_native.sh
149+
bash setup/setup__native.sh
154150
```
155151
156152
### Activation (after install, and in every new shell)

setup/setup_native.sh

+65-80
Original file line numberDiff line numberDiff line change
@@ -3,100 +3,85 @@ set -e
33

44
source setup/setup_shared.sh
55

6-
export PLATFORMS=""
7-
8-
if [ $SETUP_IOS ] || ( [ !$SETUP_ANDROID ] && [ !$SETUP_IOS ] ); then
9-
OSX_MAJOR_VERSION=`sw_vers | grep ProductVersion | cut -d ':' -f 2 | cut -d '.' -f 1`
10-
echo "Found OSX major version" $OSX_MAJOR_VERSION
11-
12-
# The Homebrew pac-man is installed in different locations, depending on whether the processor
13-
# is an Intel or Apple Silicone chip. Intel uses x86_64, Apple chips are amd64, so we can
14-
# check the chip type using these hardware platforms.
15-
CHIP_ARC=`uname -m`
16-
INTEL="x86_64"
17-
APPLE_SILICONE="arm64"
18-
WORKING_DIR=""
19-
20-
if [ $CHIP_ARC == $INTEL ]; then
21-
echo "Found "$INTEL" chip"
22-
WORKING_DIR="/usr/local/"
23-
else
24-
if [ $CHIP_ARC == $APPLE_SILICONE ]; then
25-
echo "Found "$APPLE_SILICONE" chip"
26-
WORKING_DIR=$HOMEBREW_PREFIX
27-
fi
6+
7+
# The Homebrew pac-man is installed in different locations, depending on whether the processor
8+
# is an Intel or Apple Silicone chip. Intel uses x86_64, Apple chips are amd64, so we can
9+
# check the chip type using these hardware platforms.
10+
CHIP_ARC=`uname -m`
11+
INTEL="x86_64"
12+
APPLE_SILICONE="arm64"
13+
WORKING_DIR=""
14+
15+
if [ $CHIP_ARC == $INTEL ]; then
16+
echo "Found "$INTEL" chip"
17+
WORKING_DIR="/usr/local/"
18+
else
19+
if [ $CHIP_ARC == $APPLE_SILICONE ]; then
20+
echo "Found "$APPLE_SILICONE" chip"
21+
WORKING_DIR=$HOMEBREW_PREFIX
2822
fi
23+
fi
2924

30-
CURR_RUBY_VERSION=`ruby --version | cut -d ' ' -f 2 | cut -d '.' -f 1-2`
31-
echo "Found ruby version "$CURR_RUBY_VERSION
25+
CURR_RUBY_VERSION=`ruby --version | cut -d ' ' -f 2 | cut -d '.' -f 1-2`
26+
echo "Found ruby version "$CURR_RUBY_VERSION
3227

33-
if [ $CURR_RUBY_VERSION == $RUBY_VERSION ]; then
34-
echo "Found ruby version "$CURR_RUBY_VERSION" expected "$RUBY_VERSION" no need to upgrade"
28+
if [ $CURR_RUBY_VERSION == $RUBY_VERSION ]; then
29+
echo "Found ruby version "$CURR_RUBY_VERSION" expected "$RUBY_VERSION" no need to upgrade"
30+
else
31+
echo "Required ruby version not found, attempting to install through brew"
32+
if [ -x "${WORKING_DIR}/bin/brew" ]; then
33+
echo "Found brew installation with version" ` brew --version`
34+
echo "Installing ruby version to brew" $RUBY_VERSION
35+
brew install ruby@$RUBY_VERSION
3536
else
36-
if [ -x "${WORKING_DIR}/bin/brew" ]; then
37-
echo "Found brew installation with version" ` brew --version`
38-
echo "Installing ruby version to brew" $RUBY_VERSION
39-
brew install ruby@$RUBY_VERSION
40-
else
41-
if [ $OSX_MAJOR_VERSION -ge $OSX_EXP_VERSION ]; then
42-
echo "No brew installation found, but OSX major version "$OSX_MAJOR_VERSION" and expected version "$OSX_EXP_VERSION" so CocoaPods should work"
43-
else
44-
echo "No brew installation found, but OSX major version "$OSX_MAJOR_VERSION" != expected version "$OSX_EXP_VERSION" CocoaPods install will likely fail"
45-
echo "Found ruby version "`ruby --version`
46-
exit 1
47-
fi
48-
fi
37+
echo "No brew installation found"
38+
exit 1
4939
fi
40+
fi
5041

51-
echo "Adding $RUBY_PATH to the path before the install"
52-
export PATH=$RUBY_PATH:$PATH
42+
echo "Adding $RUBY_PATH to the path before the install"
43+
export PATH=$RUBY_PATH:$PATH
5344

54-
echo "Installing cocoapods"
55-
${WORKING_DIR}/opt/ruby@$RUBY_VERSION/bin/gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION
45+
echo "Installing cocoapods"
46+
${WORKING_DIR}/opt/ruby@$RUBY_VERSION/bin/gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION
5647

57-
export PLATFORMS+=" ios"
58-
fi
5948

60-
if [ $SETUP_ANDROID ] || ( [ !$SETUP_ANDROID ] && [ !$SETUP_IOS ] ); then
61-
# we can build android on both ubuntu and OSX
62-
# should try both since there may be subtle differences
63-
PLATFORM=`uname -a`
64-
65-
# both of these have java on Github Actions
66-
# but may not in docker, for example
67-
# should check for the existence of java and die if it doesn't exist
68-
echo "Checking for java in the path"
69-
JAVA_VERSION=`javac -version`
70-
echo "Found java in the path with version $JAVA_VERSION"
71-
72-
echo "Setting up SDK environment"
73-
MIN_SDK_VERSION=21
74-
TARGET_SDK_VERSION=28
75-
76-
if [ -z $ANDROID_HOME ] && [ -z $ANDROID_SDK_ROOT ];
77-
then
78-
echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found, exiting"
79-
exit 1
80-
else
81-
echo "ANDROID_HOME = $ANDROID_HOME; ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
82-
fi
49+
# we can build android on both ubuntu and OSX
50+
# should try both since there may be subtle differences
51+
PLATFORM=`uname -a`
52+
53+
# both of these have java on Github Actions
54+
# but may not in docker, for example
55+
# should check for the existence of java and die if it doesn't exist
56+
echo "Checking for java in the path"
57+
JAVA_VERSION=`javac -version`
58+
echo "Found java in the path with version $JAVA_VERSION"
59+
60+
echo "Setting up SDK environment"
61+
MIN_SDK_VERSION=21
62+
TARGET_SDK_VERSION=28
8363

84-
echo "Setting up sdkman"
85-
curl -s "https://get.sdkman.io" | bash
86-
source ~/.sdkman/bin/sdkman-init.sh
64+
if [ -z $ANDROID_HOME ] && [ -z $ANDROID_SDK_ROOT ];
65+
then
66+
echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found, exiting"
67+
exit 1
68+
else
69+
echo "ANDROID_HOME = $ANDROID_HOME; ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
70+
fi
8771

88-
CURR_GRADLE_VER=`sdk current gradle | cut -d " " -f 4 | xargs`
72+
echo "Setting up sdkman"
73+
curl -s "https://get.sdkman.io" | bash
74+
source ~/.sdkman/bin/sdkman-init.sh
8975

90-
echo "CURR_GRADLE_VER = '$CURR_GRADLE_VER', expected $GRADLE_VERSION"
76+
CURR_GRADLE_VER=`sdk current gradle | cut -d " " -f 4 | xargs`
9177

92-
if [[ $CURR_GRADLE_VER == $GRADLE_VERSION ]]; then
93-
echo "Already have gradle version $GRADLE_VERSION"
94-
else
95-
echo "Setting up gradle using SDKMan"
96-
sdk install gradle $GRADLE_VERSION
97-
fi
78+
echo "CURR_GRADLE_VER = '$CURR_GRADLE_VER', expected $GRADLE_VERSION"
9879

99-
export PLATFORMS+=" android"
80+
if [[ $CURR_GRADLE_VER == $GRADLE_VERSION ]]; then
81+
echo "Already have gradle version $GRADLE_VERSION"
82+
else
83+
echo "Setting up gradle using SDKMan"
84+
sdk install gradle $GRADLE_VERSION
10085
fi
10186

10287
./bin/configure_xml_and_json.js cordovabuild

0 commit comments

Comments
 (0)