Release/Makefile
author Zachary West <zacw@adium.im>
Sat Oct 24 18:29:49 2009 -0400 (2009-10-24)
changeset 2645 cdc1b3a12cf7
parent 2643 7ae6496e17bc
child 2690 c59d32e913bd
permissions -rw-r--r--
Version up to b12.
     1 ###########
     2 # What to do before running this script:
     3 # - openUp needs to be installed.
     4 # - Set VERSION, BUILD_IN_DEBUG_MODE, BETA, and OFFICIAL_BUILD below.
     5 #    * The Adium plists will automatically updated to match these values.
     6 #    * BETA should be TRUE for all beta builds and FALSE for all releases.
     7 #      It primarily affects the appcast used by Adium for detecting updates.
     8 #    * BUILD_IN_DEBUG_MODE should be set to FALSE for the last beta
     9 #      in addition to the release itself. If FALSE, debug logging is disabled
    10 #      and certain space optimizations for nibs and strings are done which
    11 #      also prevent modification.
    12 #    * OFFICIAL_BUILD is TRUE for the benefit of our Adium build machine, which signs 
    13 #      official release builds. When building a release yourself, set this to FALSE, 
    14 #      since you don't have the Adium certificate on your machine.
    15 #
    16 # How to run this script:
    17 # - make all
    18 ###########
    19 
    20 VERSION=1.4b12
    21 BUILD_IN_DEBUG_MODE?=TRUE
    22 BETA?=TRUE
    23 OFFICIAL_BUILD?=TRUE
    24 
    25 # Always builds in debug mode.
    26 NIGHTLY?=FALSE
    27 
    28 ###########
    29 # To release!
    30 # Releasing requires cachefly access and adiumx.com access.
    31 #
    32 # First upload to cachefly. If you don't have access and need to do a release, get with Evan or Chris (tick).
    33 # Triggering the version checker once the release is up:
    34 # 1) Build Adium
    35 # 2) Get the number out of the 'buildnum' file in Adium.app/Contents/Resources
    36 # 3) Paste that number into the appropriate place (adium version or adium-beta version, depending on which you're triggering) in the version.plist file in our public_html folder.  *** (2) and (3) are to support the old version checker, in Adium 0.8x and earlier ***
    37 # 4) Update and commit the appcast.xml file in the adium checkout root
    38 # 5) Run the appcast update php script.
    39 ###########
    40 
    41 ###########
    42 # No need for changes below this point
    43 ###########
    44 
    45 ###########
    46 # Variables
    47 ###########
    48 SRC_DIR=..
    49 BUILD_DIR=build
    50 ART_DIR=Artwork
    51 ADIUM_DIR=$(BUILD_DIR)/Adium
    52 RELEASE_NAME=Adium_$(VERSION)
    53 VERSION_ESCAPED=$(VERSION)
    54 RELEASE_NAME_ESCAPED=Adium_$(VERSION_ESCAPED)
    55 TARBALL_DIR=adium-$(VERSION)
    56 
    57 REVISION = r$(shell hg parent --template {rev})
    58 
    59 ifeq ($(NIGHTLY),TRUE)
    60 	BETA=FALSE
    61 	ADIUM_DIR:=$(ADIUM_DIR)\ $(REVISION)
    62 	VERSION_ESCAPED:=$(VERSION_ESCAPED)\ $(REVISION)
    63 	VERSION:=$(VERSION)$(REVISION)
    64 	BUILD_IN_DEBUG_MODE=TRUE
    65 	BUILDFLAGS+="ADIUM_CFLAGS=-DNIGHTLY_RELEASE"
    66 endif
    67 
    68 ifeq ($(BUILD_IN_DEBUG_MODE),TRUE)
    69     BUILDSTYLE=Release-Debug
    70 else
    71     BUILDSTYLE=Release
    72 endif
    73 
    74 BUILDFLAGS+="BUILDCONFIGURATION=$(BUILDSTYLE)"
    75 ifeq ($(BETA),TRUE)
    76 	BUILDFLAGS+="ADIUM_CFLAGS=-DBETA_RELEASE"
    77 endif
    78 
    79 PRODUCT_DIR=$(shell defaults read com.apple.Xcode PBXApplicationwideBuildSettings 2> /dev/null > XcodeBuildSettings.plist && defaults read $PWD/XcodeBuildSettings SYMROOT 2> /dev/null; rm XcodeBuildSettings.plist)
    80 
    81 ifeq ($(strip $(PRODUCT_DIR)),)
    82 	ADIUM_BUILD_DIR=$(SRC_DIR)/build/$(BUILDSTYLE)
    83 else
    84 	TARGET_BUILD_DIR=$(PRODUCT_DIR)/$(BUILDSTYLE)
    85 	ADIUM_BUILD_DIR=$(TARGET_BUILD_DIR)
    86 endif
    87 
    88 PLIST_DIR=`pwd`/../Plists
    89 ADIUM_PLIST=$(PLIST_DIR)/Info
    90 
    91 ###########
    92 # Targets
    93 ###########
    94 .PHONY: all all-withlocalchanges all-withlocalchanges-noclean all-nopackage-noclean all-nightly update assertnochanges assertnoconflicts version compile clean release source prepare-release-bundle createfolder diskimage nightly tarball
    95 
    96 all: update assertnochanges version clean compile release
    97 all-withlocalchanges: update assertnoconflicts version clean compile release
    98 all-withlocalchanges-noclean: update assertnoconflicts version compile release
    99 
   100 #doesn't bother putting things in a dmg
   101 #useful for builds not intended for distribution
   102 all-nopackage-noclean: update assertnoconflicts version compile createfolder prepare-release-bundle
   103 
   104 update:
   105 	hg pull -uf
   106 
   107 assertnochanges: assertnoconflicts
   108 	if [[ 0 -ne `hg st $(SRC_DIR) | egrep --invert-match '\?|Info\.plist' | wc -l` ]]; then \
   109 		echo 'You have local changes. Please do not build releases from an unclean checkout. You must revert the changes, commit them, or check out another working copy and build from that.' 1>&2; \
   110 		exit 1; \
   111 	fi
   112 assertnoconflicts:
   113 	if [[ 0 -ne `hg st $(SRC_DIR) | egrep '^C' | wc -l` ]]; then \
   114 		echo 'You have conflicts in your checkout. You will not be able to build until these are resolved. Also, remember that even after you have fixed all conflict marks, you must use "hg resolve"; otherwise, hg will still believe the files are conflicted.' 1>&2; \
   115 		exit 2; \
   116 	fi
   117 
   118 version:
   119 	@# update the plists
   120 	defaults write $(ADIUM_PLIST) CFBundleGetInfoString "$(VERSION), Copyright 2001-2009 The Adium Team"
   121 	defaults write $(ADIUM_PLIST) CFBundleVersion "$(VERSION)"
   122 	defaults write $(ADIUM_PLIST) CFBundleShortVersionString "$(VERSION)"
   123 	plutil -convert xml1 $(ADIUM_PLIST).plist
   124 
   125 compile:
   126 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR)
   127 
   128 testcompile:
   129 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR)
   130 
   131 clean:
   132 	rm -rf $(BUILD_DIR)
   133 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR) clean
   134 
   135 release: createfolder prepare-release-bundle diskimage
   136 
   137 prepare-release-bundle:
   138 	@# Convert all nibs to the smaller binary format
   139 	@echo Converting nibs to binary format...
   140 	find $(BUILD_DIR) -name keyedobjects.nib -print0 | xargs -0 plutil -convert binary1
   141 
   142 	@# delete unneeded nib files for non-beta builds
   143 	@echo Cleaning Adium.app for release
   144 ifeq ($(BUILD_IN_DEBUG_MODE),FALSE)
   145 	find $(BUILD_DIR) \( -name classes.nib -or -name info.nib \) -type f -delete
   146 endif
   147 	
   148 	@# delete backup files
   149 	find $(BUILD_DIR) \( -name "*~" -or -name .DS_Store \) -type f -delete
   150 	
   151 	@# delete header files
   152 	find $(BUILD_DIR) \( -name "*.h" \) -type f -delete
   153 
   154 	@# sign the executable
   155 ifeq ($(OFFICIAL_BUILD),TRUE)
   156 	if [ -e ~/adium-password ]; then \
   157 		security unlock-keychain -p `cat ~/adium-password`; \
   158 	fi
   159 	codesign -v -s Adium $(ADIUM_DIR)/Adium.app/Contents/MacOS/Adium
   160 endif
   161 
   162 createfolder:
   163 	@# clean build directory
   164 	rm -rf $(BUILD_DIR)
   165 	mkdir $(BUILD_DIR)
   166 
   167 	mkdir $(ADIUM_DIR)
   168 	
   169 	@# copy the app
   170 	cp -R "$(ADIUM_BUILD_DIR)/Adium.app" $(ADIUM_DIR)
   171 
   172 	@# copy the text files
   173 	cp $(SRC_DIR)/ChangeLogs/Changes.txt $(ADIUM_DIR)
   174 	cp $(SRC_DIR)/License.txt $(ADIUM_DIR)
   175 	
   176 	@# symlink /Applications
   177 	./mkalias -r /Applications $(ADIUM_DIR)/Applications
   178 
   179 diskimage:
   180 	rm "$(BUILD_DIR)/$(RELEASE_NAME).dmg" || true
   181 	@# make Adium disk image
   182 	mkdir -p $(ADIUM_DIR)/.background
   183 	cp $(ART_DIR)/dmgBackground.png $(ADIUM_DIR)/.background
   184 
   185 	./ensureCustomIconsExtracted $(ART_DIR)
   186 	./make-diskimage.sh $(BUILD_DIR)/$(RELEASE_NAME).dmg $(ADIUM_DIR) "Adium $(VERSION)" dmg_adium.scpt $(ART_DIR)
   187 	
   188 ifeq ($(OFFICIAL_BUILD),TRUE)
   189 	@echo DSA for Sparkle: `ruby sign_update.rb $(BUILD_DIR)/$(RELEASE_NAME_ESCAPED).dmg ~/adium-dsa-sign/dsa_priv.pem`
   190 endif
   191 
   192 	@echo Build finished. `md5 $(BUILD_DIR)/$(RELEASE_NAME_ESCAPED).dmg`
   193 
   194 #This is what nightly builds use. Does not update because buildbot does.
   195 nightly: version clean compile createfolder prepare-release-bundle diskimage
   196 	echo $(RELEASE_NAME) > $(BUILD_DIR)/latest.info
   197 	echo $(REVISION) >> $(BUILD_DIR)/latest.info
   198 	md5 -q $(BUILD_DIR)/$(RELEASE_NAME).dmg >> $(BUILD_DIR)/latest.info
   199 	md5 -q $(BUILD_DIR)/$(RELEASE_NAME).dmg >> $(BUILD_DIR)/$(RELEASE_NAME).dmg.md5
   200 	ls -l $(BUILD_DIR)/$(RELEASE_NAME).dmg | awk '{print $$5}' >>$(BUILD_DIR)/latest.info
   201 	echo $(VERSION) >> $(BUILD_DIR)/latest.info
   202 ifeq ($(OFFICIAL_BUILD),TRUE)
   203 	ruby sign_update.rb $(BUILD_DIR)/$(RELEASE_NAME).dmg ~/adium-dsa-sign/dsa_priv.pem >> $(BUILD_DIR)/latest.info
   204 endif
   205 
   206 tarballapp:
   207 	rm $(BUILD_DIR)/$(RELEASE_NAME).tgz || true
   208 	cd $(BUILD_DIR) && tar zcf $(RELEASE_NAME).tgz Adium*/ && cd ..
   209 
   210 tarball:
   211 	hg archive -t tgz ($TARBALL_DIR).tgz