diff options
author | stuconnolly <stuart02@gmail.com> | 2009-01-28 18:27:29 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-01-28 18:27:29 +0000 |
commit | 1787ebb430b61f487a993507ec8eed9f885dc066 (patch) | |
tree | eebe41f52d07bb646c0bd47d879b2fdba3b557d6 | |
parent | 8b7b5d15730e0586c531bf3867b8192d1e3689f4 (diff) | |
download | sequelpro-1787ebb430b61f487a993507ec8eed9f885dc066.tar.gz sequelpro-1787ebb430b61f487a993507ec8eed9f885dc066.tar.bz2 sequelpro-1787ebb430b61f487a993507ec8eed9f885dc066.zip |
Added shell script to trim application bundle on 'Release' builds. Saves a whole meg on current build.
-rwxr-xr-x | Scripts/trim-application.sh | 127 | ||||
-rw-r--r-- | sequel-pro.xcodeproj/project.pbxproj | 11 |
2 files changed, 135 insertions, 3 deletions
diff --git a/Scripts/trim-application.sh b/Scripts/trim-application.sh new file mode 100755 index 00000000..b42938e9 --- /dev/null +++ b/Scripts/trim-application.sh @@ -0,0 +1,127 @@ +#! /bin/ksh + +## $Id: trim-application.sh 118 2008-06-21 13:57:41Z stuart $ +## +## Author: Stuart Connolly <stuart@stuconnolly.com> +## Copyright (c) 2008 Stuart Connolly. All rights reserved. +## +## Paramters: -p -- The path to the application that is to be trimmed +## -d -- Remove unnecessary files (i.e. .DS_Store files, etc) (optional). +## -n -- Trim nib files (i.e. remove .info.nib, classes.nib, data.dependency and designable.nib) (optional). +## -s -- Strip debug symbols from application binary (optional). +## -t -- Compress tiff images using LZW compression (optional). +## -f -- Remove framework headers (optional). +## -r -- Remove resource forks (optional). +## -a -- All of above optional options. Equivalent to '-d -n -s -t -f -r'. +## +## Description: Trims an application bundle of unnecessary files and resources that are generally not required and otherwise +## waste disk space. + +usage() +{ + echo "Usage: `basename $0` -p application_path [-d -n -s -t -f -r]" + exit 1 +} + +while getopts ":p:dnstra" OPTION +do + case $OPTION in + p) APP_PATH="$OPTARG";; + d) REMOVE_FILES=1;; + n) TRIM_NIBS=1;; + s) STRIP_DEBUG=1;; + t) COMPRESS_TIFF=1;; + f) REMOVE_F_HEADERS=1;; + r) REMOVE_RSRC=1;; + a) REMOVE_FILES=1; + TRIM_NIBS=1; + STRIP_DEBUG=1; + COMPRESS_TIFF=1; + REMOVE_F_HEADERS=1; + REMOVE_RSRC=1;; + *) echo 'Unrecognised argument'; usage;; + esac +done + +if [ $# -eq 0 ] +then + echo 'Illegal number of arguments. I need the path to an application.' + usage +fi + +if [ ! -d "$APP_PATH" ] +then + echo "Invalid application path. Application at path '${APP_PATH}' doesn't seem to exist." + usage +fi + +if [ ! -w "$APP_PATH" ] +then + echo "Error: Application at path '${APP_PATH}' is not writeable." + usage +fi + +if [ $# -lt 2 ] +then + echo 'Illegal number of arguments. I need at least one trim option.' + usage +fi + +printf "Trimming application bundle '`basename $APP_PATH`' at '${APP_PATH}'...\n\n" + +# Remove unnecessary files +if [ $REMOVE_FILES ] +then + printf 'Removing unnecessary files...\n' + + find "$APP_PATH" \( -name '.DS_Store' -or -name 'pbdevelopment.plist' -type f \) | while read FILE; do; printf "\tRemoving file: ${FILE}\n"; rm "$FILE"; done; +fi + +# Trim nibs +if [ $TRIM_NIBS ] +then + printf '\nTrimming nibs...\n' + + find "$APP_PATH" \( -name 'info.nib' -or -name 'classes.nib' -or -name 'data.dependency' -or -name 'designable.nib' -type f \) | while read FILE; do; printf "\tRemoving nib file: ${FILE}\n"; rm "$FILE"; done; +fi + +# Strip debug symbols +if [ $STRIP_DEBUG ] +then + printf '\nStripping debug symbols...\n' + + find "${APP_PATH}/Contents/MacOS" -type f | while read FILE; do; printf "\tStripping binary: ${FILE}\n"; /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/Resources/pbxcp -resolve-src-symlinks -strip-debug-symbols "$FILE" '/tmp'; mv "/tmp/$(basename "$FILE")" "$FILE"; done; +fi + +# Compress tiff images +if [ $COMPRESS_TIFF ] +then + printf '\nCompressing tiff images...\n' + + find "$APP_PATH" \( -name "*.tif" -or -name "*.tiff" \) | while read FILE; do; printf "\tCompressing tiff: ${FILE}\n"; tiffutil -lzw "$FILE" -out "${FILE}.out" 2> /dev/null; mv "${FILE}.out" "$FILE"; done; +fi + +# Remove framework headers +if [ $REMOVE_F_HEADERS ] +then + printf '\nRemoving framework headers...\n' + + FRAMEWORK_PATH="${APP_PATH}/Contents/Frameworks" + + if [ -d "$FRAMEWORK_PATH" ] + then + find "$FRAMEWORK_PATH" \( -name "*.h" -type f \) | while read FILE; do; printf "\tRemoving header: ${FILE}\n"; rm "$FILE"; done; + fi +fi + +# Remove resource forks +if [ $REMOVE_RSRC ] +then + printf '\nRemoving resource forks...\n' + + find "$APP_PATH" -type f | while read FILE; do if [ -s "${FILE}/rsrc" ]; then; printf "\tRemoving reource: ${FILE}/rsrc\n"; cp /dev/null "${FILE}/rsrc"; fi; done; +fi + +printf "\nTrimming application bundle '`basename $APP_PATH`' complete\n" + +exit 0
\ No newline at end of file diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 4b7f7df6..75e194bd 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 1761FD480EF03A6F00331368 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1761FD460EF03A6F00331368 /* MainMenu.xib */; }; 1789343C0F30C1DD0097539A /* SPStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1789343B0F30C1DD0097539A /* SPStringAdditions.m */; }; + 178934990F30CDA10097539A /* trim-application.sh in Resources */ = {isa = PBXBuildFile; fileRef = 178934980F30CDA10097539A /* trim-application.sh */; }; 17E641460EF01EB5001BC333 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E641440EF01EB5001BC333 /* main.m */; }; 17E641560EF01EF6001BC333 /* CustomQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E641490EF01EF6001BC333 /* CustomQuery.m */; }; 17E641570EF01EF6001BC333 /* MainController.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E6414B0EF01EF6001BC333 /* MainController.m */; }; @@ -140,6 +141,7 @@ 1761FD9D0EF0488900331368 /* build-version.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "build-version.pl"; sourceTree = "<group>"; }; 1789343A0F30C1DD0097539A /* SPStringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPStringAdditions.h; sourceTree = "<group>"; }; 1789343B0F30C1DD0097539A /* SPStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPStringAdditions.m; sourceTree = "<group>"; }; + 178934980F30CDA10097539A /* trim-application.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "trim-application.sh"; sourceTree = "<group>"; }; 17E641440EF01EB5001BC333 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 17E641450EF01EB5001BC333 /* sequel-pro_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "sequel-pro_Prefix.pch"; sourceTree = "<group>"; }; 17E641480EF01EF6001BC333 /* CustomQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomQuery.h; sourceTree = "<group>"; }; @@ -327,6 +329,7 @@ isa = PBXGroup; children = ( 1761FD9D0EF0488900331368 /* build-version.pl */, + 178934980F30CDA10097539A /* trim-application.sh */, ); path = Scripts; sourceTree = "<group>"; @@ -569,7 +572,7 @@ 8D15AC300486D014006FF6A4 /* Sources */, 8D15AC330486D014006FF6A4 /* Frameworks */, 4DECC4940EC2B447008D359E /* CopyFiles */, - 1761FDAF0EF0496500331368 /* ShellScript */, + 1761FDAF0EF0496500331368 /* Run Scripts */, ); buildRules = ( ); @@ -663,24 +666,26 @@ 17E6423E0EF0218B001BC333 /* InfoPlist.strings in Resources */, 1761FD480EF03A6F00331368 /* MainMenu.xib in Resources */, B5E2C5FA0F2353B5007446E0 /* TablePropertyIcon.png in Resources */, + 178934990F30CDA10097539A /* trim-application.sh in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1761FDAF0EF0496500331368 /* ShellScript */ = { + 1761FDAF0EF0496500331368 /* Run Scripts */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); + name = "Run Scripts"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Add build/bundle version\n${SRCROOT}/Scripts/build-version.pl"; + shellScript = "# Add build/bundle version\n${SRCROOT}/Scripts/build-version.pl\n\n# Trim application if release build\nif [ \"$CONFIGURATION\" == 'Release' ]\nthen\n\t\"${SRCROOT}/Scripts/trim-application.sh\" -p \"${BUILT_PRODUCTS_DIR}/${TARGET_NAME}${WRAPPER_SUFFIX}\" -a\nfi"; }; /* End PBXShellScriptBuildPhase section */ |