Permalink
Browse files

Added a packaging script.

Script will easily build Greenwich in release mode
and package all necessary resources for distribution.
  • Loading branch information...
1 parent 7d939b3 commit f471a1ad60788b3ff95145a7674dd548328173f1 @wbyoung committed Nov 18, 2011
View
@@ -2,3 +2,5 @@
*.pyc
build
xcuserdata
+greenwich.build
+greenwich_*.tbz
View
@@ -8,3 +8,5 @@ syntax: glob
syntax: regexp
^build$
+^greenwich.build$
+^greenwich_(\d+\.)+(dsym\.)?tbz$
@@ -40,3 +40,4 @@ COPY_PHASE_STRIP = NO
PREBINDING = NO
GREENWICH_LOCALIZATION_SYMBOL = FRLocalizedString
+GREENWICH_VERSION = 1.0
@@ -6,6 +6,21 @@
objectVersion = 46;
objects = {
+/* Begin PBXAggregateTarget section */
+ 8BB93D4F1474CAA90056EC71 /* Package */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = 8BB93D521474CAA90056EC71 /* Build configuration list for PBXAggregateTarget "Package" */;
+ buildPhases = (
+ 8BB93D561474CACB0056EC71 /* Package */,
+ );
+ dependencies = (
+ 8BB93D551474CAC00056EC71 /* PBXTargetDependency */,
+ );
+ name = Package;
+ productName = Package;
+ };
+/* End PBXAggregateTarget section */
+
/* Begin PBXBuildFile section */
8B0DCF0B14702CDE00DF8AC3 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8B0DCF0514702CDE00DF8AC3 /* Localizable.strings */; };
8B0DCF0C14702CDE00DF8AC3 /* Localization.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8B0DCF0714702CDE00DF8AC3 /* Localization.strings */; };
@@ -35,6 +50,16 @@
8BAD1EAD146F148500E16433 /* FRUntranslatedCountCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BAD1E9F146F148400E16433 /* FRUntranslatedCountCell.h */; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ 8BB93D541474CAC00056EC71 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 8BAD1E54146F114700E16433 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 8BAD1E6F146F11CB00E16433;
+ remoteInfo = Greenwich;
+ };
+/* End PBXContainerItemProxy section */
+
/* Begin PBXFileReference section */
8B0DCF0614702CDE00DF8AC3 /* en */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localizable.strings; sourceTree = "<group>"; };
8B0DCF0814702CDE00DF8AC3 /* en */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localization.strings; sourceTree = "<group>"; };
@@ -308,6 +333,7 @@
projectRoot = "";
targets = (
8BAD1E6F146F11CB00E16433 /* Greenwich */,
+ 8BB93D4F1474CAA90056EC71 /* Package */,
);
};
/* End PBXProject section */
@@ -356,6 +382,21 @@
shellScript = "localization verify";
showEnvVarsInLog = 0;
};
+ 8BB93D561474CACB0056EC71 /* Package */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = Package;
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "../package build";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -378,6 +419,14 @@
};
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ 8BB93D551474CAC00056EC71 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 8BAD1E6F146F11CB00E16433 /* Greenwich */;
+ targetProxy = 8BB93D541474CAC00056EC71 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin PBXVariantGroup section */
8B0DCF0514702CDE00DF8AC3 /* Localizable.strings */ = {
isa = PBXVariantGroup;
@@ -484,6 +533,20 @@
};
name = Release;
};
+ 8BB93D501474CAA90056EC71 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 8BB93D511474CAA90056EC71 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -505,6 +568,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 8BB93D521474CAA90056EC71 /* Build configuration list for PBXAggregateTarget "Package" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 8BB93D501474CAA90056EC71 /* Debug */,
+ 8BB93D511474CAA90056EC71 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 8BAD1E54146F114700E16433 /* Project object */;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -15,6 +15,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.0</string>
+ <string>${GREENWICH_VERSION}</string>
</dict>
</plist>
View
76 package
@@ -0,0 +1,76 @@
+#!/usr/bin/env ruby
+
+require 'fileutils'
+
+class Packager < Object
+ def run
+ puts "Building project (this may take a while)..."
+ command = %w(xcodebuild) +
+ %w(-target Package) +
+ %w(-configuration Release) +
+ %w(-project Framework/Greenwich.xcodeproj)
+ output = File.open "greenwich.build", :mode => "w"
+ result = IO.popen command + [:err=>[:child, :out]] do |io|
+ begin
+ while line = io.readline
+ output.write line
+ puts line if line =~ /^(Test|warning:)/
+ end
+ rescue EOFError
+ # finished reading
+ end
+ end
+ raise Exception.new("Build failed") if result != 0
+ end
+
+ def build
+ outdir = File.join ENV["PROJECT_DIR"], '..'
+ version = ENV["GREENWICH_VERSION"]
+ framework = File.join ENV["BUILT_PRODUCTS_DIR"], "Greenwich.framework"
+ scripts = File.join ENV["PROJECT_DIR"], "Scripts"
+ framework_archive = File.join outdir, "greenwich_#{version}.tbz"
+ dsym_archive = File.join outdir, "greenwich_#{version}.dsym.tbz"
+
+ if ENV["CONFIGURATION"] == "Release"
+ puts "creating packages..."
+ Dir.chdir ENV["BUILT_PRODUCTS_DIR"] do
+ FileUtils.rm_rf "Greenwich"
+ FileUtils.mkdir_p "Greenwich"
+ FileUtils.mv framework, "Greenwich"
+ FileUtils.cp_r scripts, "Greenwich", :preserve => true
+ tbz ["Greenwich"], :output => framework_archive
+ tbz Dir.glob("*.dSYM"), :output => dsym_archive
+ end
+ else
+ puts "need to build as a release!"
+ exit 1
+ end
+ end
+
+ private
+
+ def zip(files, options={})
+ output = options[:output]
+ output = File.basename(files[0]) unless output
+ command = %w(zip -ryq) + [output] + files
+ raise Exception.new("Archive failure") unless system *command
+ end
+
+ def tbz(files, options={})
+ output = options[:output]
+ output = File.basename(files[0]) unless output
+ command = %w(tar cjf) + [output] + files
+ raise Exception.new("Archive failure") unless system *command
+ end
+end
+
+if __FILE__ == $PROGRAM_NAME
+ if ARGV.length == 1 && ARGV[0] == "build"
+ Packager.new.build
+ elsif ARGV.length == 0
+ Packager.new.run
+ else
+ $stderr.puts "usage: package [build]"
+ exit 1
+ end
+end

0 comments on commit f471a1a

Please sign in to comment.