Skip to content

Commit

Permalink
[scripts] Add --xcode-version to ttmodule in order to override the pr…
Browse files Browse the repository at this point in the history
…oject version.

This is necessary for those wanting to upgrade their Three20 settings
in a Xcode 3.2.5 project to Xcode 4. Before, the script would look
at the project version and see that it was for 3.2.5 and only add the
3.2.5 settings. Now, it's possible to state --xcode-version=4 and this
will force ttmodule to treat the project file as though it were version
4.
  • Loading branch information
jverkoey committed Mar 11, 2011
1 parent 1796651 commit f1a486b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/scripts/Pbxproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ def relpath(p1, p2):
class Pbxproj(object):

@staticmethod
def get_pbxproj_by_name(name):
def get_pbxproj_by_name(name, xcode_version = None):
if name not in pbxproj_cache:
pbxproj_cache[name] = Pbxproj(name)
pbxproj_cache[name] = Pbxproj(name, xcode_version = xcode_version)

return pbxproj_cache[name]

# Valid names
# Three20
# Three20:Three20-Xcode3.2.5
# /path/to/project.xcodeproj/project.pbxproj
def __init__(self, name):
def __init__(self, name, xcode_version = None):
self._project_data = None

parts = name.split(':')
Expand All @@ -105,6 +105,7 @@ def __init__(self, name):

self._guid = None
self._deps = None
self._xcode_version = xcode_version
self._projectVersion = None
self.guid()

Expand Down Expand Up @@ -441,7 +442,11 @@ def add_header_search_path(self, configuration):
return did_add_build_setting

# Version 46 is Xcode 4's file format.
if self._projectVersion >= 46:
try:
primary_version = int(self._xcode_version.split('.')[0])
except ValueError, e:
primary_version = 0
if self._projectVersion >= 46 or primary_version >= 4:
did_add_build_setting = self.add_build_setting(configuration, 'HEADER_SEARCH_PATHS', '"$(BUILT_PRODUCTS_DIR)/../../three20"')
if not did_add_build_setting:
return did_add_build_setting
Expand Down
17 changes: 16 additions & 1 deletion src/scripts/ttmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import logging
import re
import os
import sys
from optparse import OptionParser

Expand Down Expand Up @@ -118,6 +119,9 @@ def main():
Most common use case:
> %prog -p path/to/myApp/myApp.xcodeproj Three20
For adding Xcode 4 support to an Xcode 3.2.# project:
> %prog -p path/to/myApp/myApp.xcodeproj Three20 --xcode-version=4
Print all dependencies for the Three20UI module
> %prog -d Three20UI
Expand Down Expand Up @@ -146,6 +150,9 @@ def main():

parser.add_option("-p", "--project", dest="projects",
help="Add the given modules to this project", action="append")

parser.add_option("--xcode-version", dest="xcode_version",
help="Set the xcode version you plan to open this project in. By default uses xcodebuild to determine your latest Xcode version.")

parser.add_option("-c", "--config", dest="configs",
help="Explicit configurations to add Three20 settings to (example: Debug). By default, ttmodule will add configuration settings to every configuration for the given target", action="append")
Expand All @@ -167,8 +174,16 @@ def main():

if options.projects is not None:
did_anything = True

if not options.xcode_version:
f=os.popen("xcodebuild -version")
xcodebuild_version = f.readlines()[0]
match = re.search('Xcode ([a-zA-Z0-9.]+)', xcodebuild_version)
if match:
(options.xcode_version, ) = match.groups()

for name in options.projects:
project = Pbxproj.get_pbxproj_by_name(name)
project = Pbxproj.get_pbxproj_by_name(name, xcode_version = options.xcode_version)
add_modules_to_project(args, project, options.configs)

if not did_anything:
Expand Down

0 comments on commit f1a486b

Please sign in to comment.