Release/Makefile
author Stephen Holt <sholt@adium.im>
Sat Dec 03 10:20:27 2011 -0800 (5 months ago)
changeset 4345 45eb40ad9991
parent 4318 b08eeb55787a
child 4347 5be91264f5d8
permissions -rw-r--r--
Level up! (1.5b6)
     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.5b6
    21 BUILD_IN_DEBUG_MODE?=TRUE
    22 BETA?=TRUE
    23 OFFICIAL_BUILD?=TRUE
    24 
    25 # Always builds in debug mode.
    26 NIGHTLY?=FALSE
    27 NIGHTLY_REPO?=adium #change to adium-1.4 on the 1.4 branch
    28 NIGHTLY_BRANCH?=default
    29 
    30 ###########
    31 # To release!
    32 # Releasing requires cachefly access and adiumx.com access.
    33 #
    34 # First upload to cachefly. If you don't have access and need to do a release, get with Evan or Chris (tick).
    35 # Triggering the version checker once the release is up:
    36 # 1) Build Adium
    37 # 2) Get the number out of the 'buildnum' file in Adium.app/Contents/Resources
    38 # 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 ***
    39 # 4) Update and commit the appcast.xml file in the adium checkout root
    40 # 5) Run the appcast update php script.
    41 ###########
    42 
    43 ###########
    44 # No need for changes below this point
    45 ###########
    46 
    47 ###########
    48 # Variables
    49 ###########
    50 SRC_DIR=..
    51 BUILD_DIR=build
    52 ART_DIR=Artwork
    53 ADIUM_DIR=$(BUILD_DIR)/Adium
    54 RELEASE_NAME=Adium_$(VERSION)
    55 VERSION_ESCAPED=$(VERSION)
    56 RELEASE_NAME_ESCAPED=Adium_$(VERSION_ESCAPED)
    57 TARBALL_DIR=adium-$(VERSION)
    58 
    59 REVISION = r$(shell hg parent --template {rev})
    60 
    61 ifeq ($(NIGHTLY),TRUE)
    62 	BETA=FALSE
    63 	ADIUM_DIR:=$(ADIUM_DIR)\ $(REVISION)
    64 	VERSION_ESCAPED:=$(VERSION_ESCAPED)\ $(REVISION)
    65 	VERSION:=$(VERSION)$(REVISION)
    66 	BUILD_IN_DEBUG_MODE=TRUE
    67 	BUILDFLAGS+="ADIUM_CFLAGS=-DNIGHTLY_RELEASE"
    68 endif
    69 
    70 ifeq ($(BUILD_IN_DEBUG_MODE),TRUE)
    71     BUILDSTYLE=Release-Debug
    72 else
    73     BUILDSTYLE=Release
    74 endif
    75 
    76 BUILDFLAGS+="BUILDCONFIGURATION=$(BUILDSTYLE)"
    77 ifeq ($(BETA),TRUE)
    78 	BUILDFLAGS+="ADIUM_CFLAGS=-DBETA_RELEASE"
    79 endif
    80 
    81 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)
    82 
    83 ifeq ($(strip $(PRODUCT_DIR)),)
    84 	ADIUM_BUILD_DIR=$(SRC_DIR)/build/$(BUILDSTYLE)
    85 else
    86 	TARGET_BUILD_DIR=$(PRODUCT_DIR)/$(BUILDSTYLE)
    87 	ADIUM_BUILD_DIR=$(TARGET_BUILD_DIR)
    88 endif
    89 
    90 PLIST_DIR=`pwd`/../Plists
    91 ADIUM_PLIST=$(PLIST_DIR)/Info
    92 
    93 ###########
    94 # Targets
    95 ###########
    96 .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
    97 
    98 all: update assertnochanges version clean compile release
    99 all-withlocalchanges: update assertnoconflicts version clean compile release
   100 all-withlocalchanges-noclean: update assertnoconflicts version compile release
   101 
   102 #doesn't bother putting things in a dmg
   103 #useful for builds not intended for distribution
   104 all-nopackage-noclean: update assertnoconflicts version compile createfolder prepare-release-bundle
   105 
   106 update:
   107 	hg pull -uf
   108 
   109 assertnochanges: assertnoconflicts
   110 	if [[ 0 -ne `hg st $(SRC_DIR) | egrep --invert-match '\?|Info\.plist' | wc -l` ]]; then \
   111 		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; \
   112 		exit 1; \
   113 	fi
   114 assertnoconflicts:
   115 	if [[ 0 -ne `hg st $(SRC_DIR) | egrep '^C' | wc -l` ]]; then \
   116 		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; \
   117 		exit 2; \
   118 	fi
   119 
   120 version:
   121 	@# update the plists
   122 	defaults write $(ADIUM_PLIST) CFBundleGetInfoString "$(VERSION), Copyright 2001-$(shell date +"%Y") The Adium Team"
   123 	defaults write $(ADIUM_PLIST) CFBundleVersion "$(VERSION)"
   124 	defaults write $(ADIUM_PLIST) CFBundleShortVersionString "$(VERSION)"
   125 ifeq ($(NIGHTLY),TRUE)
   126 	defaults write $(ADIUM_PLIST) AINightlyRepo "$(NIGHTLY_REPO)"
   127 	defaults write $(ADIUM_PLIST) AINightlyBranch "$(NIGHTLY_BRANCH)"
   128 endif
   129 	plutil -convert xml1 $(ADIUM_PLIST).plist
   130 
   131 compile:
   132 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR)
   133 
   134 testcompile:
   135 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR)
   136 
   137 clean:
   138 	rm -rf $(BUILD_DIR)
   139 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR) clean
   140 
   141 release: createfolder prepare-release-bundle diskimage
   142 
   143 prepare-release-bundle:
   144 	@# Convert all nibs to the smaller binary format
   145 	@echo Converting nibs to binary format...
   146 	find $(BUILD_DIR) -name keyedobjects.nib -print0 | xargs -0 plutil -convert binary1
   147 
   148 	@# delete unneeded nib files for non-beta builds
   149 	@echo Cleaning Adium.app for release
   150 ifeq ($(BUILD_IN_DEBUG_MODE),FALSE)
   151 	find $(BUILD_DIR) \( -name classes.nib -or -name info.nib -or -name designable.nib \) -type f -delete
   152 endif
   153 
   154 	@# delete backup files
   155 	find $(BUILD_DIR) \( -name "*~" -or -name .DS_Store \) -type f -delete
   156 
   157 	@# delete header files
   158 	find $(BUILD_DIR) \( -name "*.h" \) -type f -delete
   159 
   160 	@# sign the executable
   161 ifeq ($(OFFICIAL_BUILD),TRUE)
   162 	if [ -e ~/adium-password ]; then \
   163 		security unlock-keychain -p `cat ~/adium-password`; \
   164 	fi
   165 	codesign -v -s Adium $(ADIUM_DIR)/Adium.app/Contents/MacOS/Adium
   166 endif
   167 
   168 createfolder:
   169 	@# clean build directory
   170 	rm -rf $(BUILD_DIR)
   171 	mkdir $(BUILD_DIR)
   172 
   173 	mkdir $(ADIUM_DIR)
   174 
   175 	@# copy the app
   176 	cp -R "$(ADIUM_BUILD_DIR)/Adium.app" $(ADIUM_DIR)
   177 
   178 	@# copy the text files
   179 	cp $(SRC_DIR)/ChangeLogs/Changes.txt $(ADIUM_DIR)
   180 	cp $(SRC_DIR)/License.txt $(ADIUM_DIR)
   181 
   182 	@# symlink /Applications
   183 	./mkalias -r /Applications $(ADIUM_DIR)/Applications
   184 
   185 diskimage:
   186 	rm "$(BUILD_DIR)/$(RELEASE_NAME).dmg" || true
   187 	@# make Adium disk image
   188 	mkdir -p $(ADIUM_DIR)/.background
   189 	cp $(ART_DIR)/dmgBackground.png $(ADIUM_DIR)/.background
   190 
   191 	./ensureCustomIconsExtracted $(ART_DIR)
   192 	./make-diskimage.sh $(BUILD_DIR)/$(RELEASE_NAME).dmg $(ADIUM_DIR) "Adium $(VERSION)" dmg_adium.scpt $(ART_DIR)
   193 
   194 ifeq ($(OFFICIAL_BUILD),TRUE)
   195 	@echo DSA for Sparkle: `ruby sign_update.rb $(BUILD_DIR)/$(RELEASE_NAME_ESCAPED).dmg ~/adium-dsa-sign/dsa_priv.pem`
   196 endif
   197 
   198 	@echo Build finished. `md5 $(BUILD_DIR)/$(RELEASE_NAME_ESCAPED).dmg`
   199 
   200 #This is what nightly builds use. Does not update because buildbot does.
   201 nightly: version clean compile createfolder prepare-release-bundle diskimage
   202 	echo $(RELEASE_NAME) > $(BUILD_DIR)/latest.info
   203 	echo $(REVISION) >> $(BUILD_DIR)/latest.info
   204 	md5 -q $(BUILD_DIR)/$(RELEASE_NAME).dmg >> $(BUILD_DIR)/latest.info
   205 	md5 -q $(BUILD_DIR)/$(RELEASE_NAME).dmg >> $(BUILD_DIR)/$(RELEASE_NAME).dmg.md5
   206 	ls -l $(BUILD_DIR)/$(RELEASE_NAME).dmg | awk '{print $$5}' >>$(BUILD_DIR)/latest.info
   207 	echo $(VERSION) >> $(BUILD_DIR)/latest.info
   208 ifeq ($(OFFICIAL_BUILD),TRUE)
   209 	ruby sign_update.rb $(BUILD_DIR)/$(RELEASE_NAME).dmg ~/adium-dsa-sign/dsa_priv.pem >> $(BUILD_DIR)/latest.info
   210 endif
   211 
   212 tarballapp:
   213 	rm $(BUILD_DIR)/$(RELEASE_NAME).tgz || true
   214 	cd $(BUILD_DIR) && tar zcf $(RELEASE_NAME).tgz Adium*/ && cd ..
   215 
   216 tarball:
   217 	hg archive -t tgz ($TARBALL_DIR).tgz