From 8d3a6f4a17fe07dcede6cf78865133a2f334436f Mon Sep 17 00:00:00 2001 From: Aria Nolan Date: Mon, 16 Sep 2024 10:48:50 -0400 Subject: [PATCH 1/6] Fix and simplify choosing between android or ios setup --- setup/setup_native.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/setup_native.sh b/setup/setup_native.sh index 05624a693..1aaa5bfc9 100644 --- a/setup/setup_native.sh +++ b/setup/setup_native.sh @@ -5,7 +5,7 @@ source setup/setup_shared.sh export PLATFORMS="" -if [ $SETUP_IOS ] || ( [ !$SETUP_ANDROID ] && [ !$SETUP_IOS ] ); then +if [ $SETUP_IOS ]; then OSX_MAJOR_VERSION=`sw_vers | grep ProductVersion | cut -d ':' -f 2 | cut -d '.' -f 1` echo "Found OSX major version" $OSX_MAJOR_VERSION @@ -57,7 +57,7 @@ if [ $SETUP_IOS ] || ( [ !$SETUP_ANDROID ] && [ !$SETUP_IOS ] ); then export PLATFORMS+=" ios" fi -if [ $SETUP_ANDROID ] || ( [ !$SETUP_ANDROID ] && [ !$SETUP_IOS ] ); then +if [ $SETUP_ANDROID ]; then # we can build android on both ubuntu and OSX # should try both since there may be subtle differences PLATFORM=`uname -a` From 0be35b40a8326a3a1943ab7193cd6dbd58c72573 Mon Sep 17 00:00:00 2001 From: Aria Nolan Date: Mon, 16 Sep 2024 10:49:24 -0400 Subject: [PATCH 2/6] Remove check for OSX version --- setup/setup_native.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/setup/setup_native.sh b/setup/setup_native.sh index 1aaa5bfc9..f0c9b5205 100644 --- a/setup/setup_native.sh +++ b/setup/setup_native.sh @@ -33,18 +33,14 @@ if [ $SETUP_IOS ]; then if [ $CURR_RUBY_VERSION == $RUBY_VERSION ]; then echo "Found ruby version "$CURR_RUBY_VERSION" expected "$RUBY_VERSION" no need to upgrade" else + echo "Required ruby version not found, attempting to install through brew" if [ -x "${WORKING_DIR}/bin/brew" ]; then echo "Found brew installation with version" ` brew --version` echo "Installing ruby version to brew" $RUBY_VERSION brew install ruby@$RUBY_VERSION else - if [ $OSX_MAJOR_VERSION -ge $OSX_EXP_VERSION ]; then - echo "No brew installation found, but OSX major version "$OSX_MAJOR_VERSION" and expected version "$OSX_EXP_VERSION" so CocoaPods should work" - else - echo "No brew installation found, but OSX major version "$OSX_MAJOR_VERSION" != expected version "$OSX_EXP_VERSION" CocoaPods install will likely fail" - echo "Found ruby version "`ruby --version` - exit 1 - fi + echo "No brew installation found" + exit 1 fi fi From b3fb4089a604f4ec948425fe4ea6bc0639cd74d0 Mon Sep 17 00:00:00 2001 From: Aria Nolan Date: Mon, 16 Sep 2024 10:52:00 -0400 Subject: [PATCH 3/6] Update README for changed setup script --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d75b62f6f..a6d814d8e 100644 --- a/README.md +++ b/README.md @@ -143,14 +143,10 @@ builds with your configuration. That is almost certainly the source of the error Installing (one time only) --- -Run the setup script for the platform you want to build +Run the setup script for the platform(s) you want to build ``` -bash setup/setup_android_native.sh -``` -AND/OR -``` -bash setup/setup_ios_native.sh +SETUP_ANDROID=1 SETUP_IOS=1 bash setup/setup__native.sh ``` ### Activation (after install, and in every new shell) From 4bc017a4010621933df766152b57a26c54ec8ebc Mon Sep 17 00:00:00 2001 From: Aria Nolan Date: Mon, 16 Sep 2024 10:53:37 -0400 Subject: [PATCH 4/6] Update CI for new setup script --- .github/workflows/android-build.yml | 2 +- .github/workflows/ios-build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 571c516fc..154358983 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -54,7 +54,7 @@ jobs: shell: bash -l {0} run: | export JAVA_HOME=$JAVA_HOME_17_arm64 - bash setup/setup_native.sh + SETUP_ANDROID=1 bash setup/setup_native.sh - name: Check tool versions shell: bash -l {0} diff --git a/.github/workflows/ios-build.yml b/.github/workflows/ios-build.yml index c64ea49f1..ee53766b5 100644 --- a/.github/workflows/ios-build.yml +++ b/.github/workflows/ios-build.yml @@ -50,7 +50,7 @@ jobs: - name: Setup the cordova environment shell: bash -l {0} run: | - bash setup/setup_native.sh + SETUP_IOS=1 bash setup/setup_native.sh - name: Check tool versions shell: bash -l {0} From b5e23e1cbd851ce800dc776221b71d9355cf8118 Mon Sep 17 00:00:00 2001 From: Aria Nolan Date: Mon, 16 Sep 2024 10:56:32 -0400 Subject: [PATCH 5/6] Remove unnecessary variable from setup script --- setup/setup_native.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup/setup_native.sh b/setup/setup_native.sh index f0c9b5205..43f56081d 100644 --- a/setup/setup_native.sh +++ b/setup/setup_native.sh @@ -6,9 +6,6 @@ source setup/setup_shared.sh export PLATFORMS="" if [ $SETUP_IOS ]; then - OSX_MAJOR_VERSION=`sw_vers | grep ProductVersion | cut -d ':' -f 2 | cut -d '.' -f 1` - echo "Found OSX major version" $OSX_MAJOR_VERSION - # The Homebrew pac-man is installed in different locations, depending on whether the processor # is an Intel or Apple Silicone chip. Intel uses x86_64, Apple chips are amd64, so we can # check the chip type using these hardware platforms. From 6dd71f18321c77cfaf3f67ba19911b4bc282396d Mon Sep 17 00:00:00 2001 From: Aria Nolan Date: Wed, 18 Sep 2024 11:14:28 -0400 Subject: [PATCH 6/6] Setup both android and ios --- .github/workflows/android-build.yml | 2 +- .github/workflows/ios-build.yml | 2 +- README.md | 4 +- setup/setup_native.sh | 138 +++++++++++++--------------- 4 files changed, 69 insertions(+), 77 deletions(-) diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 154358983..571c516fc 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -54,7 +54,7 @@ jobs: shell: bash -l {0} run: | export JAVA_HOME=$JAVA_HOME_17_arm64 - SETUP_ANDROID=1 bash setup/setup_native.sh + bash setup/setup_native.sh - name: Check tool versions shell: bash -l {0} diff --git a/.github/workflows/ios-build.yml b/.github/workflows/ios-build.yml index ee53766b5..c64ea49f1 100644 --- a/.github/workflows/ios-build.yml +++ b/.github/workflows/ios-build.yml @@ -50,7 +50,7 @@ jobs: - name: Setup the cordova environment shell: bash -l {0} run: | - SETUP_IOS=1 bash setup/setup_native.sh + bash setup/setup_native.sh - name: Check tool versions shell: bash -l {0} diff --git a/README.md b/README.md index a6d814d8e..2dc97042e 100644 --- a/README.md +++ b/README.md @@ -143,10 +143,10 @@ builds with your configuration. That is almost certainly the source of the error Installing (one time only) --- -Run the setup script for the platform(s) you want to build +Run the setup script ``` -SETUP_ANDROID=1 SETUP_IOS=1 bash setup/setup__native.sh +bash setup/setup__native.sh ``` ### Activation (after install, and in every new shell) diff --git a/setup/setup_native.sh b/setup/setup_native.sh index 43f56081d..ca606f472 100644 --- a/setup/setup_native.sh +++ b/setup/setup_native.sh @@ -3,93 +3,85 @@ set -e source setup/setup_shared.sh -export PLATFORMS="" - -if [ $SETUP_IOS ]; then - # The Homebrew pac-man is installed in different locations, depending on whether the processor - # is an Intel or Apple Silicone chip. Intel uses x86_64, Apple chips are amd64, so we can - # check the chip type using these hardware platforms. - CHIP_ARC=`uname -m` - INTEL="x86_64" - APPLE_SILICONE="arm64" - WORKING_DIR="" - - if [ $CHIP_ARC == $INTEL ]; then - echo "Found "$INTEL" chip" - WORKING_DIR="/usr/local/" - else - if [ $CHIP_ARC == $APPLE_SILICONE ]; then - echo "Found "$APPLE_SILICONE" chip" - WORKING_DIR=$HOMEBREW_PREFIX - fi + +# The Homebrew pac-man is installed in different locations, depending on whether the processor +# is an Intel or Apple Silicone chip. Intel uses x86_64, Apple chips are amd64, so we can +# check the chip type using these hardware platforms. +CHIP_ARC=`uname -m` +INTEL="x86_64" +APPLE_SILICONE="arm64" +WORKING_DIR="" + +if [ $CHIP_ARC == $INTEL ]; then + echo "Found "$INTEL" chip" + WORKING_DIR="/usr/local/" +else + if [ $CHIP_ARC == $APPLE_SILICONE ]; then + echo "Found "$APPLE_SILICONE" chip" + WORKING_DIR=$HOMEBREW_PREFIX fi +fi - CURR_RUBY_VERSION=`ruby --version | cut -d ' ' -f 2 | cut -d '.' -f 1-2` - echo "Found ruby version "$CURR_RUBY_VERSION +CURR_RUBY_VERSION=`ruby --version | cut -d ' ' -f 2 | cut -d '.' -f 1-2` +echo "Found ruby version "$CURR_RUBY_VERSION - if [ $CURR_RUBY_VERSION == $RUBY_VERSION ]; then - echo "Found ruby version "$CURR_RUBY_VERSION" expected "$RUBY_VERSION" no need to upgrade" +if [ $CURR_RUBY_VERSION == $RUBY_VERSION ]; then + echo "Found ruby version "$CURR_RUBY_VERSION" expected "$RUBY_VERSION" no need to upgrade" +else + echo "Required ruby version not found, attempting to install through brew" + if [ -x "${WORKING_DIR}/bin/brew" ]; then + echo "Found brew installation with version" ` brew --version` + echo "Installing ruby version to brew" $RUBY_VERSION + brew install ruby@$RUBY_VERSION else - echo "Required ruby version not found, attempting to install through brew" - if [ -x "${WORKING_DIR}/bin/brew" ]; then - echo "Found brew installation with version" ` brew --version` - echo "Installing ruby version to brew" $RUBY_VERSION - brew install ruby@$RUBY_VERSION - else - echo "No brew installation found" - exit 1 - fi + echo "No brew installation found" + exit 1 fi +fi - echo "Adding $RUBY_PATH to the path before the install" - export PATH=$RUBY_PATH:$PATH +echo "Adding $RUBY_PATH to the path before the install" +export PATH=$RUBY_PATH:$PATH - echo "Installing cocoapods" - ${WORKING_DIR}/opt/ruby@$RUBY_VERSION/bin/gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION +echo "Installing cocoapods" +${WORKING_DIR}/opt/ruby@$RUBY_VERSION/bin/gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION - export PLATFORMS+=" ios" -fi -if [ $SETUP_ANDROID ]; then - # we can build android on both ubuntu and OSX - # should try both since there may be subtle differences - PLATFORM=`uname -a` - - # both of these have java on Github Actions - # but may not in docker, for example - # should check for the existence of java and die if it doesn't exist - echo "Checking for java in the path" - JAVA_VERSION=`javac -version` - echo "Found java in the path with version $JAVA_VERSION" - - echo "Setting up SDK environment" - MIN_SDK_VERSION=21 - TARGET_SDK_VERSION=28 - - if [ -z $ANDROID_HOME ] && [ -z $ANDROID_SDK_ROOT ]; - then - echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found, exiting" - exit 1 - else - echo "ANDROID_HOME = $ANDROID_HOME; ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" - fi +# we can build android on both ubuntu and OSX +# should try both since there may be subtle differences +PLATFORM=`uname -a` + +# both of these have java on Github Actions +# but may not in docker, for example +# should check for the existence of java and die if it doesn't exist +echo "Checking for java in the path" +JAVA_VERSION=`javac -version` +echo "Found java in the path with version $JAVA_VERSION" + +echo "Setting up SDK environment" +MIN_SDK_VERSION=21 +TARGET_SDK_VERSION=28 - echo "Setting up sdkman" - curl -s "https://get.sdkman.io" | bash - source ~/.sdkman/bin/sdkman-init.sh +if [ -z $ANDROID_HOME ] && [ -z $ANDROID_SDK_ROOT ]; +then + echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found, exiting" + exit 1 +else + echo "ANDROID_HOME = $ANDROID_HOME; ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" +fi - CURR_GRADLE_VER=`sdk current gradle | cut -d " " -f 4 | xargs` +echo "Setting up sdkman" +curl -s "https://get.sdkman.io" | bash +source ~/.sdkman/bin/sdkman-init.sh - echo "CURR_GRADLE_VER = '$CURR_GRADLE_VER', expected $GRADLE_VERSION" +CURR_GRADLE_VER=`sdk current gradle | cut -d " " -f 4 | xargs` - if [[ $CURR_GRADLE_VER == $GRADLE_VERSION ]]; then - echo "Already have gradle version $GRADLE_VERSION" - else - echo "Setting up gradle using SDKMan" - sdk install gradle $GRADLE_VERSION - fi +echo "CURR_GRADLE_VER = '$CURR_GRADLE_VER', expected $GRADLE_VERSION" - export PLATFORMS+=" android" +if [[ $CURR_GRADLE_VER == $GRADLE_VERSION ]]; then + echo "Already have gradle version $GRADLE_VERSION" +else + echo "Setting up gradle using SDKMan" + sdk install gradle $GRADLE_VERSION fi ./bin/configure_xml_and_json.js cordovabuild