Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Add ttmodule script.
Browse files Browse the repository at this point in the history
Implemented a pbxproj python script for adding dependencies to projects
via the command line.

It's built upon a collection of incredibly simple regular expressions
and a basic understanding of the pbxproj file format.

For help: python ttmodule.py -h
  • Loading branch information
jverkoey committed Oct 20, 2010
1 parent fbb1eda commit 0814b1c
Show file tree
Hide file tree
Showing 4 changed files with 1,046 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/scripts/Paths.py
@@ -0,0 +1,25 @@
#!/usr/bin/env python
# encoding: utf-8
"""
Paths.py
Created by Jeff Verkoeyen on 2010-10-18.
Copyright 2009-2010 Facebook
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import os

script_dir = os.path.dirname(os.path.realpath(__file__))
src_dir = os.path.dirname(script_dir)
161 changes: 161 additions & 0 deletions src/scripts/Pbxproj.html
@@ -0,0 +1,161 @@

<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module Pbxproj</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>Pbxproj</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Users/featherless/workbench/ios/three20/src/scripts/Pbxproj.py">/Users/featherless/workbench/ios/three20/src/scripts/Pbxproj.py</a></font></td></tr></table>
<p><tt><a href="#Pbxproj">Pbxproj</a>.py<br>
&nbsp;<br>
Working&nbsp;with&nbsp;the&nbsp;pbxproj&nbsp;file&nbsp;format&nbsp;is&nbsp;a&nbsp;pain&nbsp;in&nbsp;the&nbsp;ass.<br>
&nbsp;<br>
This&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;provides&nbsp;a&nbsp;couple&nbsp;basic&nbsp;features&nbsp;for&nbsp;parsing&nbsp;pbxproj&nbsp;files:<br>
&nbsp;<br>
*&nbsp;Getting&nbsp;a&nbsp;dependency&nbsp;list<br>
*&nbsp;Adding&nbsp;one&nbsp;pbxproj&nbsp;to&nbsp;another&nbsp;pbxproj&nbsp;as&nbsp;a&nbsp;dependency<br>
&nbsp;<br>
Version&nbsp;1.0.<br>
&nbsp;<br>
History:<br>
1.0&nbsp;-&nbsp;October&nbsp;20,&nbsp;2010:&nbsp;Initial&nbsp;hacked-together&nbsp;version&nbsp;finished.&nbsp;It&nbsp;is&nbsp;alive!<br>
&nbsp;<br>
Created&nbsp;by&nbsp;Jeff&nbsp;Verkoeyen&nbsp;on&nbsp;2010-10-18.<br>
Copyright&nbsp;2009-2010&nbsp;Facebook<br>
&nbsp;<br>
Licensed&nbsp;under&nbsp;the&nbsp;Apache&nbsp;License,&nbsp;Version&nbsp;2.0&nbsp;(the&nbsp;"License");<br>
you&nbsp;may&nbsp;not&nbsp;use&nbsp;this&nbsp;file&nbsp;except&nbsp;in&nbsp;compliance&nbsp;with&nbsp;the&nbsp;License.<br>
You&nbsp;may&nbsp;obtain&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;License&nbsp;at<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a><br>
&nbsp;<br>
Unless&nbsp;required&nbsp;by&nbsp;applicable&nbsp;law&nbsp;or&nbsp;agreed&nbsp;to&nbsp;in&nbsp;writing,&nbsp;software<br>
distributed&nbsp;under&nbsp;the&nbsp;License&nbsp;is&nbsp;distributed&nbsp;on&nbsp;an&nbsp;"AS&nbsp;IS"&nbsp;BASIS,<br>
WITHOUT&nbsp;WARRANTIES&nbsp;OR&nbsp;CONDITIONS&nbsp;OF&nbsp;ANY&nbsp;KIND,&nbsp;either&nbsp;express&nbsp;or&nbsp;implied.<br>
See&nbsp;the&nbsp;License&nbsp;for&nbsp;the&nbsp;specific&nbsp;language&nbsp;governing&nbsp;permissions&nbsp;and<br>
limitations&nbsp;under&nbsp;the&nbsp;License.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>

<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="Paths.html">Paths</a><br>
<a href="hashlib.html">hashlib</a><br>
</td><td width="25%" valign=top><a href="logging.html">logging</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="re.html">re</a><br>
<a href="sys.html">sys</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>

<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="Pbxproj.html#Pbxproj">Pbxproj</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Pbxproj">class <strong>Pbxproj</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>

<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Pbxproj-__init__"><strong>__init__</strong></a>(self, name)</dt><dd><tt>#&nbsp;Valid&nbsp;names<br>
#&nbsp;Three20<br>
#&nbsp;Three20:Three20-Xcode3.2.5<br>
#&nbsp;/path/to/project.xcodeproj/project.pbxproj</tt></dd></dl>

<dl><dt><a name="Pbxproj-__str__"><strong>__str__</strong></a>(self)</dt></dl>

<dl><dt><a name="Pbxproj-add_build_setting"><strong>add_build_setting</strong></a>(self, configuration, setting_name, value)</dt></dl>

<dl><dt><a name="Pbxproj-add_buildfile"><strong>add_buildfile</strong></a>(self, name, file_ref_hash, default_guid)</dt><dd><tt>#&nbsp;Add&nbsp;a&nbsp;line&nbsp;to&nbsp;the&nbsp;PBXBuildFile&nbsp;section.<br>
#<br>
#&nbsp;&lt;default_guid&gt;&nbsp;/*&nbsp;&lt;name&gt;&nbsp;in&nbsp;Frameworks&nbsp;*/&nbsp;=&nbsp;{isa&nbsp;=&nbsp;PBXBuildFile;&nbsp;fileRef&nbsp;=&nbsp;&lt;file_ref_hash&gt;&nbsp;/*&nbsp;&lt;name&gt;&nbsp;*/;&nbsp;};<br>
#<br>
#&nbsp;Returns:&nbsp;&lt;default_guid&gt;&nbsp;if&nbsp;a&nbsp;line&nbsp;was&nbsp;added.<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Otherwise,&nbsp;the&nbsp;existing&nbsp;guid&nbsp;is&nbsp;returned.</tt></dd></dl>

<dl><dt><a name="Pbxproj-add_dependency"><strong>add_dependency</strong></a>(self, dep)</dt></dl>

<dl><dt><a name="Pbxproj-add_file_to_frameworks"><strong>add_file_to_frameworks</strong></a>(self, name, guid)</dt><dd><tt>#&nbsp;Add&nbsp;a&nbsp;file&nbsp;to&nbsp;the&nbsp;Frameworks&nbsp;PBXGroup.<br>
#<br>
#&nbsp;&lt;guid&gt;&nbsp;/*&nbsp;&lt;name&gt;&nbsp;*/,</tt></dd></dl>

<dl><dt><a name="Pbxproj-add_file_to_frameworks_phase"><strong>add_file_to_frameworks_phase</strong></a>(self, name, guid)</dt></dl>

<dl><dt><a name="Pbxproj-add_filereference"><strong>add_filereference</strong></a>(self, name, file_type, default_guid, rel_path, source_tree)</dt><dd><tt>#&nbsp;Add&nbsp;a&nbsp;line&nbsp;to&nbsp;the&nbsp;PBXFileReference&nbsp;section.<br>
#<br>
#&nbsp;&lt;default_guid&gt;&nbsp;/*&nbsp;&lt;name&gt;&nbsp;*/&nbsp;=&nbsp;{isa&nbsp;=&nbsp;PBXFileReference;&nbsp;lastKnownFileType&nbsp;=&nbsp;"wrapper.&lt;file_type&gt;";&nbsp;name&nbsp;=&nbsp;&lt;name&gt;;&nbsp;path&nbsp;=&nbsp;&lt;rel_path&gt;;&nbsp;sourceTree&nbsp;=&nbsp;&lt;source_tree&gt;;&nbsp;};<br>
#<br>
#&nbsp;Returns:&nbsp;&lt;default_guid&gt;&nbsp;if&nbsp;a&nbsp;line&nbsp;was&nbsp;added.<br>
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Otherwise,&nbsp;the&nbsp;existing&nbsp;guid&nbsp;is&nbsp;returned.</tt></dd></dl>

<dl><dt><a name="Pbxproj-add_framework"><strong>add_framework</strong></a>(self, framework)</dt></dl>

<dl><dt><a name="Pbxproj-add_header_search_path"><strong>add_header_search_path</strong></a>(self, configuration)</dt></dl>

<dl><dt><a name="Pbxproj-dependencies"><strong>dependencies</strong></a>(self)</dt><dd><tt>#&nbsp;Get&nbsp;and&nbsp;cache&nbsp;the&nbsp;dependencies&nbsp;for&nbsp;this&nbsp;project.</tt></dd></dl>

<dl><dt><a name="Pbxproj-get_hash_base"><strong>get_hash_base</strong></a>(self, uniquename)</dt></dl>

<dl><dt><a name="Pbxproj-get_project_data"><strong>get_project_data</strong></a>(self)</dt><dd><tt>#&nbsp;Load&nbsp;the&nbsp;project&nbsp;data&nbsp;from&nbsp;disk.</tt></dd></dl>

<dl><dt><a name="Pbxproj-guid"><strong>guid</strong></a>(self)</dt></dl>

<dl><dt><a name="Pbxproj-path"><strong>path</strong></a>(self)</dt></dl>

<dl><dt><a name="Pbxproj-set_project_data"><strong>set_project_data</strong></a>(self, project_data)</dt><dd><tt>#&nbsp;Write&nbsp;the&nbsp;project&nbsp;data&nbsp;to&nbsp;disk.</tt></dd></dl>

<dl><dt><a name="Pbxproj-uniqueid"><strong>uniqueid</strong></a>(self)</dt></dl>

<dl><dt><a name="Pbxproj-xcodeprojpath"><strong>xcodeprojpath</strong></a>(self)</dt><dd><tt>#&nbsp;A&nbsp;pbxproj&nbsp;file&nbsp;is&nbsp;contained&nbsp;within&nbsp;an&nbsp;xcodeproj&nbsp;file.<br>
#&nbsp;This&nbsp;method&nbsp;simply&nbsp;strips&nbsp;off&nbsp;the&nbsp;project.pbxproj&nbsp;part&nbsp;of&nbsp;the&nbsp;path.</tt></dd></dl>

<hr>
Static methods defined here:<br>
<dl><dt><a name="Pbxproj-get_pbxproj_by_name"><strong>get_pbxproj_by_name</strong></a>(name)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>

<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-commonpath"><strong>commonpath</strong></a>(l1, l2, common<font color="#909090">=[]</font>)</dt></dl>
<dl><dt><a name="-pathsplit"><strong>pathsplit</strong></a>(p, rest<font color="#909090">=[]</font>)</dt><dd><tt>#&nbsp;The&nbsp;following&nbsp;relative&nbsp;path&nbsp;methods&nbsp;recyled&nbsp;from:<br>
#&nbsp;<a href="http://code.activestate.com/recipes/208993-compute-relative-path-from-one-directory-to-anothe/">http://code.activestate.com/recipes/208993-compute-relative-path-from-one-directory-to-anothe/</a><br>
#&nbsp;Author:&nbsp;Cimarron&nbsp;Taylor<br>
#&nbsp;Date:&nbsp;July&nbsp;6,&nbsp;2003</tt></dd></dl>
<dl><dt><a name="-relpath"><strong>relpath</strong></a>(p1, p2)</dt></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>

<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>pbxproj_cache</strong> = {}</td></tr></table>
</body></html>

0 comments on commit 0814b1c

Please sign in to comment.