From 87b286825bdec34ff879c47e9c8b9ceceb92afae Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Mon, 20 Jan 2025 18:21:24 +1100 Subject: [PATCH] Template fix for scripts - Fixes Clean (#8260) * osx fixes for scripts on build / clean work * Template osx fix quotes * oF script to route update and download commands - 0.1.0 - init update / download (cherry picked from commit c59fac7c4aa9a5fa42f0046f002906830cffb056) * downloader [4.4.0 ~ 4.5.0] - fix close connection for zero urls. shfmt formatted bash (cherry picked from commit 8488c4625017394a0c408e918bdcb40343f8960d) * Emscripten fix download 32 * of added upgrade command. scripts/dev/upgrade.sh added upgrade dev commands to find and replace strings from old versions automatically with sed. (cherry picked from commit 15fc36797aa62a46dffd7cf714e16669a0b10cbe) * of script fix variables (cherry picked from commit 7ee0b59a721918d56d1c75ac9e491f3efa291754) * osx template --- .../project.pbxproj | 21 - of | 8 + scripts/dev/download_libs.sh | 6 +- scripts/dev/downloader.sh | 416 +++++++++--------- scripts/dev/upgrade.sh | 63 +++ scripts/of.sh | 126 ++++++ .../emptyExample.xcodeproj/project.pbxproj | 4 +- 7 files changed, 409 insertions(+), 235 deletions(-) create mode 100755 of create mode 100755 scripts/dev/upgrade.sh create mode 100755 scripts/of.sh diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index bd4ab7c5e02..02a53b44c63 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -809,7 +809,6 @@ isa = PBXNativeTarget; buildConfigurationList = E4B27C3210CBEBB200536013 /* Build configuration list for PBXNativeTarget "openFrameworks" */; buildPhases = ( - BFEF3FA72C50AEC7009B3CD8 /* Run Script */, E4B27C1110CBEB8E00536013 /* Headers */, E4B27C1210CBEB8E00536013 /* Sources */, E4B27C1310CBEB8E00536013 /* Frameworks */, @@ -854,26 +853,6 @@ /* End PBXProject section */ /* Begin PBXShellScriptBuildPhase section */ - BFEF3FA72C50AEC7009B3CD8 /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = "/usr/bin/env bash"; - shellScript = "#!/usr/bin/env bash\nif [ ! -d \"${SRCROOT}/../../../freetype/lib/macos/freetype.xcframework\" ]; then\n\techo \"openFrameworks has missing xcFrameworks for osx. Downloading libaries now via scripts/osx/download_libs.sh\"\n ${SRCROOT}/../../../../scripts/osx/download_libs.sh\nelse\n\techo \"xcFrameworks found\"\nfi\n"; - showEnvVarsInLog = 0; - }; BFF80A5D2C50B2C300784E74 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; diff --git a/of b/of new file mode 100755 index 00000000000..56b9d95120b --- /dev/null +++ b/of @@ -0,0 +1,8 @@ +# pipe commands to core oF script +_OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +_OF_DIR="$(realpath "$_OF_DIR")" +_OF_SCRIPT="$(realpath "$_OF_DIR/scripts/of.sh")" +echo "$(date): [openFrameworks: $@]" +source "$_OF_SCRIPT" $@ +EXIT_CODE=$? +exit ${EXIT_CODE} diff --git a/scripts/dev/download_libs.sh b/scripts/dev/download_libs.sh index 780fb66b1d4..ce2888473f7 100755 --- a/scripts/dev/download_libs.sh +++ b/scripts/dev/download_libs.sh @@ -233,8 +233,8 @@ echo " openFrameworks download_libs.sh v$DL_VERSION args=$@" if [ "$PLATFORM" == "emscripten" ]; then if [[ $BLEEDING_EDGE = 1 ]] ; then - if [[ $ARCH = "64" ]] ; then - ARCH="_memory64" + if [[ $ARCH = "" ]] ; then + ARCH="32" fi fi fi @@ -303,7 +303,7 @@ elif [ "$ARCH" == "" ] && [ "$PLATFORM" == "android" ]; then fi elif [ "$PLATFORM" == "emscripten" ]; then if [[ $BLEEDING_EDGE = 1 ]] ; then - PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2" + PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}.tar.bz2" else PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2" fi diff --git a/scripts/dev/downloader.sh b/scripts/dev/downloader.sh index c0e6a2c20ff..b31f1f8c205 100755 --- a/scripts/dev/downloader.sh +++ b/scripts/dev/downloader.sh @@ -1,7 +1,7 @@ #!/bin/bash -VERSION=4.4.0 -printDownloaderHelp(){ -cat << EOF +VERSION=4.5.0 +printDownloaderHelp() { + cat </dev/null) - else - remote_ctime=$(date --date="$modified" +%s 2>/dev/null) - fi - if [ $? -ne 0 ]; then - echo " [downloader] Error in converting Remote modification time [report this openFrameworks devs]." - echo " [downloader] ... Proceeding with download" - CHECK_RESULT=0 - rm -f $LOCAL_FILE - return - fi - + if [[ "$OSTYPE" == "darwin"* ]]; then + remote_ctime=$(date -j -f "%a, %d %b %Y %H:%M:%S %Z" "$modified" "+%s" 2>/dev/null) + else + remote_ctime=$(date --date="$modified" +%s 2>/dev/null) + fi + if [ $? -ne 0 ]; then + echo " [downloader] Error in converting Remote modification time [report this openFrameworks devs]." + echo " [downloader] ... Proceeding with download" + CHECK_RESULT=0 + rm -f $LOCAL_FILE + return + fi + if [[ "$OSTYPE" == "darwin"* ]]; then # Get local file modification time local_ctime=$(stat -f "%Sm" -t "%a, %d %b %Y %H:%M:%S %Z" "$LOCAL_FILE" 2>/dev/null) local_ctime=$(date -j -f "%a, %d %b %Y %H:%M:%S %Z" "$local_ctime" "+%s" 2>/dev/null) @@ -117,32 +117,32 @@ check_remote_vs_local() { local_ctime=$(stat -c %y "$LOCAL_FILE" 2>/dev/null) local_ctime=$(date --date="$local_ctime" +%s 2>/dev/null) fi - if [ $? -ne 0 ]; then - echo " [downloader] Error in converting Local modification time [report this openFrameworks devs]." - echo " [downloader] ... Proceeding with download" - CHECK_RESULT=0 - rm -f $LOCAL_FILE - return - fi - if [ "$LocalSize" != "$RemoteSize" ]; then - echo " [downloader] Remote size bits:[${RemoteSize}] | Local size bits:[${LocalSize}]" - echo " [downloader] File sizes differ between remote and local file." - echo " [downloader] ... Proceeding with download" - CHECK_RESULT=0 - rm -f $LOCAL_FILE - return - fi - if [ "$local_ctime" -lt "$remote_ctime" ]; then - echo " [downloader] Remote modification Time:[${remote_ctime}] | Local modification Time:[${local_ctime}]" - echo " [downloader] Remote file is newer." - echo " [downloader] ... Proceeding with download" - CHECK_RESULT=0 - rm -f $LOCAL_FILE + if [ $? -ne 0 ]; then + echo " [downloader] Error in converting Local modification time [report this openFrameworks devs]." + echo " [downloader] ... Proceeding with download" + CHECK_RESULT=0 + rm -f $LOCAL_FILE + return + fi + if [ "$LocalSize" != "$RemoteSize" ]; then + echo " [downloader] Remote size bits:[${RemoteSize}] | Local size bits:[${LocalSize}]" + echo " [downloader] File sizes differ between remote and local file." + echo " [downloader] ... Proceeding with download" + CHECK_RESULT=0 + rm -f $LOCAL_FILE + return + fi + if [ "$local_ctime" -lt "$remote_ctime" ]; then + echo " [downloader] Remote modification Time:[${remote_ctime}] | Local modification Time:[${local_ctime}]" + echo " [downloader] Remote file is newer." + echo " [downloader] ... Proceeding with download" + CHECK_RESULT=0 + rm -f $LOCAL_FILE + return + fi + echo " [downloader] No need to download again. Every bit matters." + CHECK_RESULT=1 return - fi - echo " [downloader] No need to download again. Every bit matters." - CHECK_RESULT=1 - return } finalurl() { @@ -156,9 +156,9 @@ finalurl() { fi } -downloader() { +downloader() { echo " [openFrameworks downloader v${VERSION}] ... " - if [ -z "$1" ]; then + if [ -z "$1" ]; then printDownloaderHelp exit 1 fi @@ -179,63 +179,63 @@ downloader() { while [[ $# -gt 0 ]]; do key="$1" case $key in - -s|--silent) - SILENT=1 - shift - ;; - -k|--no-ssl) - NO_SSL=1 - shift - ;; - -z|--no-compression) - COMPRESSION=0 - shift - ;; - -v|--verbose) - VERBOSE=1 - shift - ;; - -x|--close-connection) - CLOSE_CONNECTION=1 - shift - ;; - -p|--keep-port-alive) - CLOSE_CONNECTION=0 - shift - ;; - -c|--curl) - WGET2=0 - CURL=1 - shift - ;; - -2|--wget2) - WGET2=1 - CURL=1 - shift - ;; - -w|--wget) - WGET2=0 - CURL=0 - WGET=1 - shift - ;; - -g|--man) - shift - ;; - -h|--help) - printDownloaderHelp - exit 0 - ;; + -s | --silent) + SILENT=1 + shift + ;; + -k | --no-ssl) + NO_SSL=1 + shift + ;; + -z | --no-compression) + COMPRESSION=0 + shift + ;; + -v | --verbose) + VERBOSE=1 + shift + ;; + -x | --close-connection) + CLOSE_CONNECTION=1 + shift + ;; + -p | --keep-port-alive) + CLOSE_CONNECTION=0 + shift + ;; + -c | --curl) + WGET2=0 + CURL=1 + shift + ;; + -2 | --wget2) + WGET2=1 + CURL=1 + shift + ;; + -w | --wget) + WGET2=0 + CURL=0 + WGET=1 + shift + ;; + -g | --man) + shift + ;; + -h | --help) + printDownloaderHelp + exit 0 + ;; *) - if validate_url "$1"; then - URLS+=("$1") - else - if [ $1 != "0" ] && [ $1 != "1" ]; then - echoError " [downloader] Invalid URL: [$1]" + if validate_url "$1"; then + URLS+=("$1") + else + if [ $1 != "0" ] && [ $1 != "1" ]; then + echoError " [downloader] Invalid URL: [$1]" + fi fi - fi - shift - ;; + shift + ;; esac done # if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "cygwin"* || "$OSTYPE" == "win32"* ]]; then @@ -244,7 +244,7 @@ downloader() { # WGET2_INSTALLED=0 # fi # [wget2] - if command -v wget2 > /dev/null 2>&1; then + if command -v wget2 >/dev/null 2>&1; then WGET2_INSTALLED=1 if [[ "$COMPRESSION" == "1" ]] && [[ $WGET2 == 1 ]]; then COMPRESS=0 @@ -262,20 +262,20 @@ downloader() { WGET2_INSTALLED=0 WGET2=0 fi - + # [cURL] - if command -v curl > /dev/null 2>&1; then + if command -v curl >/dev/null 2>&1; then CURL_INSTALLED=1 CURL_VERSION=$(curl -V | head -n 1 | awk '{print $2}') CURL_MIN=7.71.0 if [ "$(printf '%s\n' "$CURL_MIN" "$CURL_VERSION" | sort -V | head -n1)" = "$CURL_MIN" ] && [ "$CURL_VERSION" != "$CURL_MIN" ]; then - if [[ $CURL == 1 && $CURL_INSTALLED == 1 ]] && [[ $WGET2 == 0 ]]; then + if [[ $CURL == 1 && $CURL_INSTALLED == 1 ]] && [[ $WGET2 == 0 ]]; then EXTRA_ARGS+="--retry-all-errors " fi fi CURL_MIN=7.83.0 if [ "$(printf '%s\n' "$CURL_MIN" "$CURL_VERSION" | sort -V | head -n1)" = "$CURL_MIN" ] && [ "$CURL_VERSION" != "$CURL_MIN" ]; then - if [[ $CURL == 1 && $CURL_INSTALLED == 1 ]] && [[ $WGET2 == 0 ]]; then + if [[ $CURL == 1 && $CURL_INSTALLED == 1 ]] && [[ $WGET2 == 0 ]]; then EXTRA_ARGS+="--remove-on-error " fi fi @@ -285,10 +285,10 @@ downloader() { else CURL_SUPPORTS_HTTP2=0 fi - if [[ "$COMPRESSION" == "1" ]] && [[ $CURL == 1 ]] && [[ $WGET2 == 0 || $WGET2_INSTALLED == 0 ]]; then + if [[ "$COMPRESSION" == "1" ]] && [[ $CURL == 1 ]] && [[ $WGET2 == 0 || $WGET2_INSTALLED == 0 ]]; then if curl -V | grep -q "brotli"; then FINAL_EXTRA_ARGS+="--compressed " - else + else COMPRESSION=0 fi fi @@ -297,9 +297,9 @@ downloader() { CURL=0 fi # [wget] - if command -v wget > /dev/null 2>&1; then + if command -v wget >/dev/null 2>&1; then WGET_INSTALLED=1 - if [[ "$COMPRESSION" == "1" ]] && [[ $CURL == 0 || $CURL_INSTALLED == 0 ]] && [[ $WGET2 == 0 || $WGET2_INSTALLED == 0 ]]; then + if [[ "$COMPRESSION" == "1" ]] && [[ $CURL == 0 || $CURL_INSTALLED == 0 ]] && [[ $WGET2 == 0 || $WGET2_INSTALLED == 0 ]]; then if wget -V | grep -q "zlib"; then EXTRA_ARGS+="--compression " else @@ -310,13 +310,13 @@ downloader() { WGET_INSTALLED=0 fi # [options] - if [[ "$COMPRESSION" == "1" ]]; then - echo " [downloader] enabled brotli/zlib losslesss compression response" - elif [[ "$COMPRESSION" == "0" ]] && [[ $CURL == 1 && $CURL_INSTALLED == 1 ]] && [[ $WGET2 == 0 || $WGET2_INSTALLED == 0 ]]; then + if [[ "$COMPRESSION" == "1" ]]; then + echo " [downloader] enabled brotli/zlib losslesss compression response" + elif [[ "$COMPRESSION" == "0" ]] && [[ $CURL == 1 && $CURL_INSTALLED == 1 ]] && [[ $WGET2 == 0 || $WGET2_INSTALLED == 0 ]]; then EXTRA_ARGS+="-Z " fi - if [[ "$NO_SSL" == "1" ]]; then - if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]] || [[ $WGET == 1 && $WGET_INSTALLED == 1 && $CURL == 0 ]]; then + if [[ "$NO_SSL" == "1" ]]; then + if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]] || [[ $WGET == 1 && $WGET_INSTALLED == 1 && $CURL == 0 ]]; then FINAL_EXTRA_ARGS+="--no-check-certificate" elif [[ $CURL == 1 ]] && [[ $CURL_INSTALLED == 1 ]]; then FINAL_EXTRA_ARGS+="--insecure " @@ -334,53 +334,53 @@ downloader() { for ((i = 0; i < ${#URLS[@]}; i++)); do URL="${URLS[$i]}" FILENAME=$(basename "$URL") - if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]]; then - if [[ "$CURL_INSTALLED" == "1" ]]; then - LOCAL_FILE=$FILENAME - REMOTE_URL=$URL - FORWARDED=$(finalurl "$URL") - FORWARDED_URLS+=($FORWARDED) - FINAL_URLS+="$FORWARDED" - check_remote_vs_local "$LOCAL_FILE" "$REMOTE_URL" 1 - if [ $CHECK_RESULT -eq 0 ]; then - URLS_TO_DOWNLOAD+="${URL}" - if [ $((i + 1)) -lt ${#URLS[@]} ]; then - URLS_TO_DOWNLOAD+=" "; - fi - fi - else - URLS_TO_DOWNLOAD+="${URL} " - fi + if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]]; then + if [[ "$CURL_INSTALLED" == "1" ]]; then + LOCAL_FILE=$FILENAME + REMOTE_URL=$URL + FORWARDED=$(finalurl "$URL") + FORWARDED_URLS+=($FORWARDED) + FINAL_URLS+="$FORWARDED" + check_remote_vs_local "$LOCAL_FILE" "$REMOTE_URL" 1 + if [ $CHECK_RESULT -eq 0 ]; then + URLS_TO_DOWNLOAD+="${URL}" + if [ $((i + 1)) -lt ${#URLS[@]} ]; then + URLS_TO_DOWNLOAD+=" " + fi + fi + else + URLS_TO_DOWNLOAD+="${URL} " + fi elif [[ $CURL == 1 ]] && [[ $CURL_INSTALLED == 1 ]]; then - LOCAL_FILE=$FILENAME - REMOTE_URL=$URL - if validate_url "$URL"; then - FORWARDED=$(finalurl "$URL") - FORWARDED_URLS+=($FORWARDED) - FINAL_URLS+="$FORWARDED" - check_remote_vs_local "$LOCAL_FILE" "$REMOTE_URL" 0 - if [ $CHECK_RESULT -eq 0 ]; then - URLS_TO_DOWNLOAD+="${URL} -o ${FILENAME}" - if [ $((i + 1)) -lt ${#URLS[@]} ]; then - URLS_TO_DOWNLOAD+=" "; - FINAL_URLS+=" " - fi - fi - else - if [ $1 != "0" ]; then - echoError " [downloader] Invalid URL: [$1]" - fi - fi + LOCAL_FILE=$FILENAME + REMOTE_URL=$URL + if validate_url "$URL"; then + FORWARDED=$(finalurl "$URL") + FORWARDED_URLS+=($FORWARDED) + FINAL_URLS+="$FORWARDED" + check_remote_vs_local "$LOCAL_FILE" "$REMOTE_URL" 0 + if [ $CHECK_RESULT -eq 0 ]; then + URLS_TO_DOWNLOAD+="${URL} -o ${FILENAME}" + if [ $((i + 1)) -lt ${#URLS[@]} ]; then + URLS_TO_DOWNLOAD+=" " + FINAL_URLS+=" " + fi + fi + else + if [ $1 != "0" ]; then + echoError " [downloader] Invalid URL: [$1]" + fi + fi else - URLS_TO_DOWNLOAD+="${URL} " + URLS_TO_DOWNLOAD+="${URL} " fi done CONNECTION_EXTRA_ARGS=("Connection: close") - if [[ "$CLOSE_CONNECTION" == "0" ]]; then + if [[ "$CLOSE_CONNECTION" == "0" ]]; then CONNECTION_EXTRA_ARGS="" fi - + if [[ $VERBOSE == 1 ]]; then EXTRA_ARGS+=" --verbose " fi @@ -392,7 +392,7 @@ downloader() { echo " [downloader] No URLS to download, continue..." else if [[ "${SILENT}" == 1 ]]; then - if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]]; then + if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]]; then echo "" wget2 -N -nv --no-tcp-fastopen --progress=bar --tries=${RETRY_MAX} --max-redirect=${MAX_REDIRECTS} --retry-connrefused --timeout=1500 --waitretry=${RETRY_DELAY_S} ${EXTRA_ARGS} ${FINAL_EXTRA_ARGS} ${URLS_TO_DOWNLOAD} elif [[ $CURL == 1 ]] && [[ $CURL_INSTALLED == 1 ]]; then @@ -401,12 +401,12 @@ downloader() { elif [[ $WGET == 1 ]] && [[ $WGET_INSTALLED == 1 ]]; then echo wget -nv -N --tries=${RETRY_MAX} --retry-connrefused --waitretry=${RETRY_DELAY_S} ${EXTRA_ARGS} ${FINAL_EXTRA_ARGS} ${URLS_TO_DOWNLOAD} - else - echo $ERROR_MSG; - exit 1; - fi; + else + echo $ERROR_MSG + exit 1 + fi else - if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]]; then + if [[ $WGET2 == 1 ]] && [[ $WGET2_INSTALLED == 1 ]]; then echo " [downloader] [wget2] urls:[$URLS_TO_DOWNLOAD] args:[$EXTRA_ARGS $FINAL_EXTRA_ARGS" echo "" wget2 -N -c --no-tcp-fastopen --progress=bar --force-progress --tries=${RETRY_MAX} --max-redirect=${MAX_REDIRECTS} --retry-connrefused --waitretry=${RETRY_DELAY_S} --timeout=1500 ${EXTRA_ARGS} ${FINAL_EXTRA_ARGS} ${URLS_TO_DOWNLOAD} @@ -414,30 +414,28 @@ downloader() { echo " [downloader] [cURL] urls:[$URLS_TO_DOWNLOAD] args:[$EXTRA_ARGS $FINAL_EXTRA_ARGS ${CONNECTION_EXTRA_ARGS[@]}]" echo curl -Z -L --retry ${RETRY_MAX} --retry-delay ${RETRY_DELAY_S} --max-redirs ${MAX_REDIRECTS} --progress-bar --header "Connection: close" ${EXTRA_ARGS} ${FINAL_EXTRA_ARGS} ${URLS_TO_DOWNLOAD} - + elif [[ $WGET == 1 ]] && [[ $WGET_INSTALLED == 1 ]]; then echo " [downloader] [wget] [$FILENAME] urls:[$URLS_TO_DOWNLOAD] args:[$EXTRA_ARGS $FINAL_EXTRA_ARGS]" echo wget -nv --progress=bar -N --tries=${RETRY_MAX} --retry-connrefused --waitretry=${RETRY_DELAY_S} ${EXTRA_ARGS} ${FINAL_EXTRA_ARGS} ${URLS_TO_DOWNLOAD} - else - echo $ERROR_MSG; - exit 1; + else + echo $ERROR_MSG + exit 1 fi fi - fi - - if [[ "$CLOSE_CONNECTION" == "1" ]]; then - if [[ $CURL == 1 ]] && [[ $CURL_INSTALLED == 1 ]] || [[ $CURL == 1 && $WGET2 == 1 ]]; then - FIRST_URL=$FORWARDED_URLS[1] - if [[ ${#FORWARDED_URLS[@]} -eq 0 ]]; then - echo " [downloader] No active connections to close" - else - FIRST_URL="${FORWARDED_URLS[0]}" - FIRST_URL=$(echo "$FIRST_URL" | sed 's/[[:space:]]*$//') - echo " [downloader] Closing the ports yarr url:[$FIRST_URL]" - curl -I -L --retry-connrefused --insecure --silent --head --max-time 1 --retry ${RETRY_MAX} ${CLOSE_EXTRA_ARGS} --no-keepalive --header "Connection: close" --retry-delay ${RETRY_DELAY_S} --max-redirs ${MAX_REDIRECTS} ${FIRST_URL} - fi + if [[ "$CLOSE_CONNECTION" == "1" ]]; then + if [[ $CURL == 1 ]] && [[ $CURL_INSTALLED == 1 ]] || [[ $CURL == 1 && $WGET2 == 1 ]]; then + if [[ ${#FORWARDED_URLS[@]} -eq 0 ]]; then + echo " [downloader] No active connections to close" + else + FIRST_URL="${FORWARDED_URLS[0]}" + FIRST_URL=$(echo "$FIRST_URL" | sed 's/[[:space:]]*$//') + echo " [downloader] Closing the ports yarr url:[$FIRST_URL]" + curl -I -L --retry-connrefused --insecure --silent --head --max-time 1 --retry ${RETRY_MAX} ${CLOSE_EXTRA_ARGS} --no-keepalive --header "Connection: close" --retry-delay ${RETRY_DELAY_S} --max-redirs ${MAX_REDIRECTS} ${FIRST_URL} + fi + fi fi fi - + } diff --git a/scripts/dev/upgrade.sh b/scripts/dev/upgrade.sh new file mode 100755 index 00000000000..788fa5fcf44 --- /dev/null +++ b/scripts/dev/upgrade.sh @@ -0,0 +1,63 @@ +#!/bin/bash +UP_VERSION=0.0.1 + +local BASE_DIR=$1 + +OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +OF_DIR="$(realpath "$OF_DIR/../../")" +OF_CORE_SCRIPT_DIR="$(realpath "$OF_DIR/scripts")" +OF_CORE_CI_SCRIPT_DIR="$(realpath "$OF_DIR/scripts/ci")" +OF_PG_INSTALLED_DIR="$(realpath "$OF_DIR/projectGenerator")" + +read -p "Enter the base directory to search for addon_config.mk files: " BASE_DIR +if [[ ! -d "${OF_DIR}/$BASE_DIR" ]]; then + echo "Error: Directory $BASE_DIR does not exist." + exit 1 +fi + +echo "Warning: This script will modify addon_config.mk files in the specified path." +echo "Please backup your projects before proceeding." +read -p "Do you want to continue? (Y/n): " CONFIRM + +if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then + echo "Upgrade cancelled. No changes were made." + exit 0 +fi + +echo "Searching for addon_config.mk files in $BASE_DIR..." +ADDON_CONFIG_FILES=$(find "$BASE_DIR" -type f -name "addon_config.mk") +if [[ -z "$ADDON_CONFIG_FILES" ]]; then + echo "No addon_config.mk files found in the specified directory." + exit 0 +fi +echo "Processing addons_config.mk files..." +for FILE in $ADDON_CONFIG_FILES; do + echo "Updating [$FILE]..." + sed -i.bak \ + -e 's/linux64:/linux\/64:/g' \ + -e 's/linuxarmv7l:/linux\/armv7l:/g' \ + -e 's/linuxaarch64:/linux\/aarch64:/g' \ + -e 's/linuxarmv6l:/linux\/armv6l:/g' \ + -e 's|/lib/linuxarmv6l/|/lib/linux/armv6l/|g' \ + -e 's|/lib/linuxarmv7l/|/lib/linux/armv7l/|g' \ + -e 's|/lib/linuxaarch64/|/lib/linux/aarch64/|g' \ + -e 's|/lib/linux64/|/lib/linux/64/|g' \ + "$FILE" + + echo "Backup created: [${FILE}.bak]" +done + +echo "Upgrade complete. Backup files have been created with a .bak extension." + +echo "Remove *.bak backup files?" +read -p "Do you want to continue? (Y/n): " CONFIRM +if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then + echo "Upgrade cancelled. No changes were made." + exit 0 +fi +for FILE in $ADDON_CONFIG_FILES; do + rm ${FILE}.bak + echo "Removed created: ${FILE}.bak" +done + + diff --git a/scripts/of.sh b/scripts/of.sh new file mode 100755 index 00000000000..3760afa0bc6 --- /dev/null +++ b/scripts/of.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# pipe commands to core openFrameworks scripts +OF_SCRIPT_VERSION=0.1.1 +# Dan Rosser 2025 +OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +OF_DIR="$(realpath "$OF_DIR/../")" +OF_CORE_SCRIPT_DIR="$(realpath "$OF_DIR/scripts")" +OF_CORE_CI_SCRIPT_DIR="$(realpath "$OF_DIR/scripts/ci")" +OF_PG_INSTALLED_DIR="$(realpath "$OF_DIR/projectGenerator")" +echo "$(date): [openFrameworks: $@]" +autoDetectOS() { + if [[ -z "$PLATFORM" ]]; then + export OF_OS=$(uname -s | tr '[:upper:]' '[:lower:]') + case "$OF_OS" in + darwin | Dawin) + export OF_PLATFORM="macos" + export OF_ARCH=$(uname -m) + ;; + linux | Linux) + export OF_PLATFORM="linux" + export OF_ARCH=$(uname -m) + ;; + mingw* | cygwin* | msys*) + export OF_PLATFORM="vs" + export OF_ARCH=${MSYSTEM,,} + ;; + *) + echo "Unsupported platform: $OF_OS" + exit 1 + ;; + esac + else + export OF_OS=$(${OF_PLATFORM} | tr '[:upper:]' '[:lower:]') + export OF_ARCH="" + fi +} + +coreScriptPath() { + case "$OF_PLATFORM" in + linux) + case "$OF_ARCH" in + arm64 | jetson | armv7l | armv8l | aarch64) + export OF_SCRIPT_PATH="${OF_CORE_SCRIPT_DIR}/${OF_PLATFORM}/${OF_ARCH}/" + ;; + *) + export OF_SCRIPT_PATH="${OF_CORE_SCRIPT_DIR}/${OF_PLATFORM}" + ;; + esac + ;; + macos | vs | emscripten | msys2 | android) + export OF_SCRIPT_PATH="${OF_CORE_SCRIPT_DIR}/${OF_PLATFORM}" + ;; + *) + echo " Error: Unsupported platform: $OF_PLATFORM" + exit 1 + ;; + esac +} + +autoDetectOS +echo " platfrom:[$OF_PLATFORM] arch:[$OF_ARCH]" +coreScriptPath +echo " coreScriptPath: [$OF_SCRIPT_PATH]" + +runCommand() { + local CMD=$1 + local SUBCMD=$2 + local SCRIPT + + case "$CMD" in + setup) + echo "openFrameworks setup" + SCRIPT="${OF_SCRIPT_PATH}/setup.sh" + ;; + update) + echo "openFrameworks update" + SCRIPT="${OF_SCRIPT_PATH}/download_libs.sh" + ;; + upgrade) + echo "openFrameworks upgrade" + case "$SUBCMD" in + addons) + echo "Upgrading addons" + SCRIPT="${OF_SCRIPT_PATH}/dev/upgrade.sh" + ;; + apps) + echo "Upgrading apps" + echo "Warning: This script will modify files in the Apps folder. Stop and back up the folder. Commit all to local repos before proceeding." + read -p "Do you want to continue? (Y/n): " CONFIRM + if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then + echo "Upgrade cancelled. No changes were made." + exit 0 + fi + SCRIPT="${OF_SCRIPT_PATH}/dev/upgrade.sh" + ;; + *) + echo "Unknown upgrade action: $SUBCMD" + echo "Valid upgrade actions: addons, apps" + exit 1 + ;; + esac + ;; + *) + echo "Unknown command: $CMD" + echo "Valid commands: setup, update, upgrade" + exit 1 + ;; + esac + + if [[ -x "$SCRIPT" ]]; then + echo "runCommand: [$SCRIPT]" + "$SCRIPT" "${@:2}" + else + echo "Error: Script for ['$CMD'] not found or not executable at: [$SCRIPT]" + exit 1 + fi +} +if [[ $# -eq 0 ]]; then + echo "Usage: $0 [args...]" + echo "Valid commands: setup, build, clean, etc." + exit 1 +fi +runCommand $@ +EXIT_CODE=$? +echo "$EXIT_CODE" +exit ${EXIT_CODE} diff --git a/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj b/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj index 4edb140812f..d932ff798b2 100644 --- a/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj +++ b/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj @@ -31,8 +31,8 @@ "outputPaths": [], "runOnlyForDeploymentPostprocessing": "0", "shellPath": "/usr/bin/env bash", - "showEnvVarsInLog": "0", - "shellScript": "#!/usr/bin/env bash\nif [ ! -d \"${OF_PATH}/libs/freetype/lib/macos/freetype.xcframework\" ]; then\n\techo \"openFrameworks has missing xcFrameworks for osx. Downloading libaries now via scripts/osx/download_libs.sh\"\n ${OF_PATH}/scripts/osx/download_libs.sh\nelse\n\techo \"xcFrameworks found\"\nfi\n" + "shellScript": "#!/usr/bin/env bash\n\n# Determine the Xcode build directory\nTARGET_DIR=\"${BUILT_PRODUCTS_DIR:-$SRCROOT/bin}\"\n\n# Check if the directory exists\nif [ ! -d \"$TARGET_DIR\" ]; then\n echo \"Error: Target directory $TARGET_DIR does not exist.\"\n exit 1\nfi\n\n# Check and set the com.apple.xcode.CreatedByBuildSystem attribute\nATTRIBUTE_CHECK=$(xattr -p com.apple.xcode.CreatedByBuildSystem \"$TARGET_DIR\" 2>/dev/null)\nif [ -z \"$ATTRIBUTE_CHECK\" ]; then\n xattr -w com.apple.xcode.CreatedByBuildSystem true \"$TARGET_DIR\"\n echo \"Attribute com.apple.xcode.CreatedByBuildSystem set to true for $TARGET_DIR\"\nelse\n echo \"Attribute com.apple.xcode.CreatedByBuildSystem already set for $TARGET_DIR\"\nfi\n", + "showEnvVarsInLog": "0" }, "E42962A92163ECCD00A6A9E2": { "alwaysOutOfDate": "1",