summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create_framework.sh15
-rwxr-xr-xscripts/project_file_header_fix.sh227
-rwxr-xr-xscripts/release.sh203
3 files changed, 371 insertions, 74 deletions
diff --git a/scripts/create_framework.sh b/scripts/create_framework.sh
index 84d3f0a06..a24b7c160 100755
--- a/scripts/create_framework.sh
+++ b/scripts/create_framework.sh
@@ -57,6 +57,8 @@ if [ -z $1 ]; then
echo "No version number entered. Skipping..."
new_version_number=$current_version_number
fi
+ else
+ new_version_number=$current_version_number
fi
else
new_version_number=$1
@@ -71,15 +73,13 @@ xcodebuild -create-xcframework -framework './SmartDeviceLink-Device.xcarchive/Pr
# TODO - is there a way we can test that the build was successful.
-folder="SmartDeviceLink.xcframework"
+framework_folder="SmartDeviceLink.xcframework"
zip_file_name="SmartDeviceLink-$new_version_number.xcframework.zip"
# Kill the old zip if present. Useful for re-running the script
if [ -f $zip_file_name ]; then rm $zip_file_name; fi
-# Verify folder exists before acting on it.
-if [ -d "$folder" ]; then
- zip $zip_file_name $folder
- # Check to see if the zip exists, and then remove old files.
- if [ -f "$zip_file_name" ]; then rm -r $folder; fi
+# Verify framework_folder exists and create a zip from it.
+if [ -d "$framework_folder" ]; then
+ tar -cf $zip_file_name $framework_folder
fi
# Cleanup artifacts
@@ -89,5 +89,8 @@ if [ -d "$folder" ]; then rm -r $folder; fi
folder="SmartDeviceLink-Simulator.xcarchive"
if [ -d "$folder" ]; then rm -r $folder; fi
+# Check to see if the zip exists, and then remove old files.
+if [ -f "$zip_file_name" ]; then rm -r $framework_folder; fi
+
echo
echo "The xcframework zip file was created at $zip_file_name." \ No newline at end of file
diff --git a/scripts/project_file_header_fix.sh b/scripts/project_file_header_fix.sh
new file mode 100755
index 000000000..03e31b164
--- /dev/null
+++ b/scripts/project_file_header_fix.sh
@@ -0,0 +1,227 @@
+#!/bin/bash
+
+# George Miller
+# 6-10-2022
+# If you do not have permission to run, try: chmod u+x project_file_header_fix.sh
+#
+# The purpose of this script is to update the location of header files in an xcode project by their public attribute.
+# It goes backwards, finding the paths to the header files first, then backtracking to find the attributes for file.
+# This was more reliable because files marked private/project have a path, but do not always have attributes.
+# This script also identifies and moves any associated code files for the headers
+#
+# Also,
+# Any file in public/ needs to be referenced in the project header
+# Any file located in private/ needs to NOT be referenced in the project header
+
+project_file="SmartDeviceLink-iOS.xcodeproj/project.pbxproj"
+target_path="SmartDeviceLink"
+project_header=$target_path"/public/SmartDeviceLink.h"
+
+
+# A utility function for prompting the user Y/N
+# This takes in a string prompt for the input
+# This returns 1 for yes/true or 0 for no/false
+prompt_user() {
+ user_input="g"
+ echo
+ echo $1" (Y/N)?"
+ read user_input
+ while [[ ! $user_input == [YyNn] ]]; do
+ echo $1" (Y/N)?"
+ read user_input
+ done
+ if [[ ! $user_input == [Nn] ]]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+# Make sure we are in the correct directory.
+# If we are running from the scripts directory, we want to pop back to the project root to do everything.
+if [[ $PWD == *"scripts" ]]; then
+ cd ..
+fi
+# If, for some reason, we are not now in the correct working directory, exit.
+if [[ $PWD != *"sdl_ios" ]]; then
+ echo "Please run this from the sdl_ios project root or the sdl_ios/scripts directory"
+ exit 0
+fi
+
+
+# Find the lines in the project file with "path".
+path_lines=$(sed -n '/path/{s/[[:space:]]*//;s/\/\*.*\*\///g;s/{.*path//;p;}' $project_file)
+# Filter to get only the lines with the header_filepath and fileref.
+header_files=$(sed -n '/\.h/{s/[[:space:]]*//g;s/\"//g;s/\;.*//g;s/==/=/;p;}' <<< "$path_lines")
+
+echo "Checking files for public / private correctness..."
+
+for line in $header_files
+do
+ # Pick out the fileref and the header_filepath.
+ fileref=$(sed -n 's/=.*//;p;' <<< $line)
+ header_filepath=$(sed -n 's/.*=//;p;' <<< $line)
+
+ # Use the fileref to get the attributes.
+ attributes=$(sed -n '/fileRef[[:space:]]*=[[:space:]]*'$fileref'/{s/.*fileRef[[:space:]]*=[[:space:]]*'$fileref'//;s/\/\*.*\*\///g;p;};' $project_file)
+
+ # Determine public or private.
+ # Save off the opposite for the file path change later.
+ if [[ $attributes == *"Public"* ]]; then
+ header_type="public"
+ else
+ header_type="private"
+ fi
+
+
+ # Only look at entries where the attributes line is not empty.
+ if [ ! -z "$attributes" ]; then
+ # Find the real location of the file.
+ file_found_location=$(find "$target_path" -name "$(basename "$header_filepath")" -maxdepth 2)
+
+ # If file is found.
+ if [ ! -z "$file_found_location" ]; then
+
+ # Test to see if the file is where it should be. (Does the path contain the correct folder)
+ if [[ ! $file_found_location == *"/$header_type/"* ]]; then
+ # Add the file to the list of files that are in the wrong location.
+ broken_file_list+=$file_found_location"=="$header_type"=="$fileref" "
+ fi
+ fi
+ fi
+done
+
+# If the broken file list is not empty.
+if [ ! -z "$broken_file_list" ]; then
+ echo
+ # List the files found for the user.
+ for header_file in $broken_file_list
+ do
+ if [ ! -z "$header_file" ]; then
+ header_filepath="${header_file%%==*}"
+ header_type1="${header_file%==*}"
+ header_type="${header_type1##*==}"
+ fileref="${header_file##*==}"
+ code_file=$(sed -n 's/\.h/\.m/p' <<< "$header_filepath")
+ echo $header_filepath" and "$code_file" are marked "$header_type
+ fi
+ done
+
+ # Prompt the user to move the files.
+ prompt_user "These files were found to be out of place. Would you like to move them automatically"
+ if [[ $? == 1 ]]; then
+ for header_file in $broken_file_list
+ do
+ echo
+ header_filepath="${header_file%%==*}"
+ header_type1="${header_file%==*}"
+ header_type="${header_type1##*==}"
+ fileref="${header_file##*==}"
+
+ # Figure out where the file should be located
+ destiny=$target_path"/"$header_type"/"
+
+ # Move the file to the correct destination
+ mv -f $header_filepath $destiny
+ echo "File "$header_filepath" moved to "$destiny
+
+ # Figure out the opposite of the type
+ if [[ $header_type == "public" ]]; then
+ header_opp="private"
+ else
+ header_opp="public"
+ fi
+
+ # Fix path in the project file.
+ # Output to a second file, then overwrite the first with the second.
+ # This is done because sed does not like writing to the file it is currently reading.
+ sed '/'$fileref'/{s/'$header_opp'/'$header_type'/;}' $project_file > $project_file"2"
+ mv -f $project_file"2" $project_file
+
+ # Identify associated implementation file.
+ code_file=$(sed -n 's/\.h/\.m/p' <<< "$header_filepath")
+
+ code_file_basename=$(basename "$code_file")
+ code_file_found_location=$(find "$target_path" -name "$code_file_basename" -maxdepth 2)
+ if [ ! -z "$code_file_found_location" ]; then
+ if [[ ! $code_file_found_location -ef $destiny$code_file_basename ]]; then
+ # Move associated implementation file.
+ mv -f $code_file_found_location $destiny
+ echo "File "$code_file" moved to "$destiny
+
+ # Fix path in the project file.
+ # Output to a second file, then overwrite the first with the second.
+ # This is done because sed does not like writing to the file it is currently reading.
+ sed '/'$code_file_basename'/{s/'$header_opp'/'$header_type'/;}' $project_file > $project_file"2"
+ mv -f $project_file"2" $project_file
+ else
+ echo $code_file_found_location" does not need to be moved"
+ fi
+ fi
+ done
+ fi
+
+else
+ echo "All files are in the correct folder..."
+fi
+
+# Find all header files in public/
+public_file_list=$(find "$target_path"/public -name '*.h')
+
+if [ ! -z "$public_file_list" ]; then
+ for header_file in $public_file_list
+ do
+ file_basename=$(basename "$header_file")
+ # Use sed to check to see if the file is in the project header
+ found=$(sed -n '/'$file_basename'/{p;}' $project_header)
+ if [ -z "$found" ]; then
+ project_header_not_found_list+=$header_file" "
+ fi
+ done
+fi
+
+# List the files found.
+if [ ! -z "$project_header_not_found_list" ]; then
+ echo
+ echo "These files are public and were not found in "$project_header
+ for header_file in $project_header_not_found_list
+ do
+ echo $header_file
+ done
+ echo "Please add them to the project header, then press enter to continue..."
+ read user_input
+else
+ echo "All public header files were found in "$project_header
+fi
+
+# Find all header files in private/
+private_file_list=$(find "$target_path"/private -name '*.h')
+
+if [ ! -z "$private_file_list" ]; then
+ for private_header_file in $private_file_list
+ do
+ file_basename=$(basename "$private_header_file")
+
+ # Use sed to check to see if the file is NOT in the project header
+ found=$(sed -n '/'$file_basename'/{p;}' $project_header)
+ if [ ! -z "$found" ]; then
+ private_file_found_list+=$private_header_file" "
+ fi
+ done
+fi
+
+# List the files found.
+if [ ! -z "$private_file_found_list" ]; then
+ echo
+ echo "These files are private and were found in "$project_header
+ for private_header_file in $private_file_found_list
+ do
+ echo $private_header_file
+ done
+ echo "Please remove them from the project header, then press enter to continue..."
+ read user_input
+else
+ echo "No private header files were found in "$project_header
+fi
+
+echo "Done checking public / private headers for correctness"
diff --git a/scripts/release.sh b/scripts/release.sh
index 443a24aa4..fd66a86ea 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -23,8 +23,6 @@ prompt_user() {
fi
}
-# TODO - phase 4 - github cli "gh" needs to be installed before we can use those commands. We could automate this or at least check if gh is installed.
-
# Script start
echo
echo "Starting SDL release script..."
@@ -43,23 +41,68 @@ fi
develop_branch="develop"
main_branch="master"
-# Stash any local changes to avoid errors during checkout
-git status
-prompt_user "Would you like to stash any local changes"
-if [[ $? == 1 ]]; then
- # Stash local changes to prevent issues with checkout
- git stash
- echo "use \"git stash pop\" when this script is complete to restore your changes"
+# Checkout develop - so we can update versions.
+# We need to checkout the branch before we start modifying files.
+current_branch=$(git branch --show-current)
+if [ $current_branch == $develop_branch ]; then
+ echo
+ echo "$develop_branch is already checked out."
else
- # Dump local changes to prevent issues with checkout
- git reset --hard
+ echo
+ echo "Checkout of $develop_branch is required for some steps"
+ prompt_user "Would you like to automatically checkout $develop_branch"
+ if [[ $? == 1 ]]; then
+
+ # Stash any local changes to avoid errors during checkout
+ git_status=$(git status)
+ git_uncommitted_changes=$(sed -n '/Changes not staged for commit:/{p;}' <<< "$git_status")
+ if [ ! -z "$git_uncommitted_changes" ]; then
+ echo "There are uncommitted changes in these files"
+ file_changes=$(git diff-files)
+ file_changes=$(sed -n '/^[[:space:]]*/{s/^.*[[:space:]]//g;p;q;}' <<< "$file_changes")
+ echo $file_changes
+ prompt_user "Would you like to stash these local changes before checkout of $develop_branch"
+ if [[ $? == 1 ]]; then
+ # Stash local changes to prevent issues with checkout
+ git stash
+ echo "Local changes have been stashed."
+ echo "Use \"git stash pop\" when this script is complete to restore your changes"
+ else
+ # Dump local changes to prevent issues with checkout. Reset cleans up any uncommitted changes to the index.
+ echo "Local changes were not stashed."
+ git reset --hard
+ fi
+ fi
+
+ # Do a pull to make sure we are up to date.
+ pull_response=$(git pull --ff)
+
+ # Check that the pull was successful If we did not get a response, then we know the pull failed.
+ if [ -z "$pull_response" ]; then
+ echo "git pull for automatic checkout has failed. Abort."
+ exit 0
+ fi
+
+ # Now do the checkout
+ git checkout $develop_branch
+
+ # check if the checkout was successful
+ current_branch=$(git branch --show-current)
+ if [ $current_branch == $develop_branch ]; then
+ develop_checked_out=1
+ else
+ echo "Automatic checkout has failed. Abort."
+ exit 0
+ fi
+ fi
fi
-# Checkout develop
-# We need to checkout the branch before we start modifying files.
-echo
-echo "Checking out $develop_branch"
-git checkout $develop_branch
+# Fix any header files that are in the wrong location according to the project file
+prompt_user "Would you like to run the project file header fixer"
+if [[ $? == 1 ]]; then
+ chmod u+x ./scripts/project_file_header_fix.sh
+ ./scripts/project_file_header_fix.sh
+fi
# Bump version in projectFile
echo
@@ -107,11 +150,11 @@ fi
echo
echo "Checking SDLGlobals.m for RPC and Protocol versions"
file="SmartDeviceLink/private/SDLGlobals.m"
-current_rpc_version=$(sed -n '/SDLMaxProxyProtocolVersion/{s/^.*@//;s/[\;]//;s/[\"]//g;p;q;}' $file)
-current_protocol_version=$(sed -n '/SDLMaxProxyRPCVersion/{s/^.*@//;s/[\;]//;s/[\"]//g;p;q;}' $file)
+current_rpc_version=$(sed -n '/SDLMaxProxyRPCVersion/{s/^.*@//;s/[\;]//;s/[\"]//g;p;q;}' $file)
+current_protocol_version=$(sed -n '/SDLMaxProxyProtocolVersion/{s/^.*@//;s/[\;]//;s/[\"]//g;p;q;}' $file)
echo "Current RPC Version: "$current_rpc_version
echo "Current Protocol Version: "$current_protocol_version
-echo "If these are not correct, please update protocol versions in /SmartDeviceLink/private/SDLGlobals.m. Then press enter..."
+echo "If these are not correct, please update versions in /SmartDeviceLink/private/SDLGlobals.m. Then press enter..."
read user_input
# Update to the newest BSON submodule. Update Package.swift and CocoaPods dependency files to point to latest if necessary.
@@ -139,12 +182,11 @@ if [ ! -z "$submodule_info" ]; then
fi
# Update changelog
-# TODO - insert a template into the changelog that includes the version the users have selected above.
-#echo "A template for this release has been inserted into the changelog. Please update it."
+# TODO - we could insert a template into the changelog that includes the version the users have selected above.
echo
echo "Please update CHANGELOG.md, then return here and press enter..."
read user_input
-# TODO - check modified info before and after so we can detect if the user failed to update the file.
+# TODO - check modified info before and after so we can detect if the user updated the file.
# Generate documentation
prompt_user "Would you like to automatically generate documentation with Jazzy"
@@ -157,7 +199,15 @@ if [[ $? == 1 ]]; then
# This runs Jazzy to generate the documentation.
echo "Running Jazzy to generate documentation..."
- jazzy --clean --objc --framework-root SmartDeviceLink --sdk iphonesimulator --umbrella-header SmartDeviceLink/public/SmartDeviceLink.h --theme theme --output docs
+ # generate-documentation.sh throws an error if we are not in the correct directory when we run it.
+ cd scripts
+ chmod u+x ./generate-documentation.sh
+ if [ $(uname -m) == "x86_64" ]; then
+ ./generate-documentation.sh
+ else
+ arch -x86_64 /bin/bash ./generate-documentation.sh
+ fi
+ cd ..
fi
# Ensure that the RPC_SPEC has released to the master branch and update the submodule to point to the new release tag (or to the HEAD of master, if no release of the RPC_SPEC is occurring).
@@ -167,63 +217,77 @@ echo "If there is, please update the rpc_spec submodule to point to the newest c
read user_input
# Git commands
-echo
-echo "$develop_branch has already been checked out for you."
-
-prompt_user "Would you like to walk through the git commands for this release"
-if [[ $? == 1 ]]; then
-
- # commit release to develop
- prompt_user "Would you like to commit and push these changes to the develop branch"
- if [[ $? == 1 ]]; then
- # Add, commit, and push changes
- git add -A
- git commit -m "Update for release $new_version_number"
- git push --set-upstream origin $develop_branch
- else
- echo "Aborting script!"
- exit 0
- fi
+# Check to make sure the correct branch is checked out.
+current_branch=$(git branch --show-current)
+if [ $current_branch == $develop_branch ]; then
+ echo
+ echo "$develop_branch has already been checked out for you."
- # Merge release to master
- prompt_user "Would you like to merge this release to master? (This will not push to master)"
+ prompt_user "Would you like to walk through the git commands for this release"
if [[ $? == 1 ]]; then
- # Checkout master
- git checkout $main_branch
+ prompt_user "Would you like to commit and push the changes made so far to the develop branch"
+ if [[ $? == 1 ]]; then
+ # Add, commit, and push changes to develop
+ git add -A
+ git commit -m "Update for release $new_version_number"
+ git push --set-upstream origin $develop_branch
+ else
+ echo "Aborting script!"
+ exit 0
+ fi
- # Merge develop with master
- git merge $main_branch $develop_branch
- echo "Please check that everything is correct. Then, assuming you have permissions, push to master, then press enter..."
- else
- echo "Aborting script!"
- exit 0
- fi
+ # Merge release to master (update master from develop)
+ prompt_user "Would you like to merge this release from develop to master? (This will not push to master)"
+ if [[ $? == 1 ]]; then
+ # Checkout master
+ git checkout $main_branch
+
+ # Merge develop with master.
+ # This updates the checked out master with the contents of develop
+ git merge $develop_branch $main_branch
+
+ echo "Please check that everything is correct."
+
+ # Tag it
+ prompt_user "Would you like to tag this release with $new_version_number? (This will not push the tag)"
+ if [[ $? == 1 ]]; then
+ git tag $new_version_number
+ fi
+
+ echo "If these changes are correct, please commit them manually and then push them to master..."
+ read user_input
+ # TODO - here are the commands if we decide to automate this.
+ # git commit -m "commit message here "
+ # git push --set-upstream origin $main_branch
+ else
+ echo "Aborting script!"
+ exit 0
+ fi
- # Tag it
- prompt_user "Would you like to tag this release with $new_version_number? (This will not push the tag)"
- if [[ $? == 1 ]]; then
- git tag $new_version_number
- # IDEA - else condition that allows the user to enter a different tag
+ # Merge master back to develop
+ prompt_user "Would you like to merge master back into develop (You will need to push manually)"
+ if [[ $? == 1 ]]; then
+ git checkout $develop_branch
+ git merge $main_branch $develop_branch
+ else
+ echo "Aborting script!"
+ exit 0
+ fi
fi
- # Merge master back to develop
- prompt_user "Would you like to merge master back into develop (This will not push the branch)"
- if [[ $? == 1 ]]; then
- git merge $develop_branch $main_branch
- else
- echo "Aborting script!"
- exit 0
- fi
+else
+ echo "You do not have $develop_branch currently checked out."
fi
+# TODO - can we provide templates for the release based on the changelog?
+# TODO - can we open directories for drag and drop to the release?
# Create new release for tag
prompt_user "Would you like to open to the Github releases page to create a release"
if [[ $? == 1 ]]; then
open "https://github.com/smartdevicelink/sdl_ios/releases"
fi
-echo
# Push new release to primary and secondary cocoapod using command line:
prompt_user "Would you like to push the release to CocoaPods"
if [[ $? == 1 ]]; then
@@ -237,7 +301,11 @@ if [[ $? == 1 ]]; then
# We pass in the version so that the framework script does not need to ask
# Give the user permissions to the framework script, then run the script.
chmod u+x ./scripts/create_framework.sh
- ./scripts/create_framework.sh $new_version_number
+ if [ $(uname -m) == "x86_64" ]; then
+ ./scripts/create_framework.sh $new_version_number
+ else
+ arch -x86_64 /bin/bash ./scripts/create_framework.sh $new_version_number
+ fi
echo
zip_file_name="SmartDeviceLink-$new_version_number.xcframework.zip"
@@ -255,7 +323,6 @@ if [[ $? == 1 ]]; then
echo
echo "Please add the docset at $docset_tar_file_name to the Github release, then press enter..."
read user_input
- # TODO - phase 4 - adding the docset to the release should also be automatic
fi
echo
-echo "Release complete." \ No newline at end of file
+echo "Release complete."