Permalink
Browse files

working on CDH install script

  • Loading branch information...
drewcrawford committed Mar 26, 2012
1 parent 8fc4c53 commit 39a894f982244733053ebf7e1b8ed8d9bdcf2af3
Showing with 92 additions and 1 deletion.
  1. +92 −1 lib/xcodeproj/project.rb
View
@@ -230,6 +230,13 @@ def self.const_missing(name)
end
end
+ class PBXReferenceProxy < PBXObject
+ attributes :path
+ #has_one :group, :inverse_of =>:extChildren
+
+
+ end
+
class PBXFileReference < PBXObject
attributes :path, :sourceTree, :explicitFileType, :lastKnownFileType, :includeInIndex
has_many :buildFiles, :inverse_of => :file
@@ -280,7 +287,6 @@ def set_default_file_type!
class PBXGroup < PBXObject
attributes :sourceTree
-
has_many :children, :class => PBXFileReference do |object|
if object.is_a?(Xcodeproj::Project::PBXFileReference)
# Associating the file to this group through the inverse
@@ -305,6 +311,10 @@ def files
end
end
+ def reference_proxies
+ list_by_class(childReferences,Xcodeproj::Project::PBXReferenceProxy)
+ end
+
def source_files
files = self.files.reject { |file| file.buildFiles.empty? }
list_by_class(childReferences, Xcodeproj::Project::PBXFileReference, files) do |file|
@@ -330,6 +340,8 @@ class PBXBuildPhase < PBXObject
# TODO rename this to buildFiles and add a files :through => :buildFiles shortcut
has_many :files, :class => PBXBuildFile
+ #has_many :extFiles, :class => PBXReferenceProxy, :uuid => :files
+
attributes :buildActionMask, :runOnlyForDeploymentPostprocessing
def initialize(*)
@@ -375,6 +387,80 @@ class PBXNativeTarget < PBXObject
has_one :product, :uuid => :productReference
has_many :dependencies, :class => PBXTargetDependency
+ def link_with_framework(project)
+ frameworkPhase = self.buildPhases.select_by_class(PBXFrameworksBuildPhase)[0]
+ frameworksGroup = project.groups.find{|g| g.name=='Frameworks'}
+ framework = projects.add_system_framework("CoreData.framework")
+ frameworkPhase.files<< framework
+ end
+
+ def flatten(parent)
+ puts "parsing #{parent.inspect}"
+ flats = []
+ if parent.respond_to?(:children)
+ parent.children.each do |child|
+ flats << self.flatten(child)
+ end
+ elsif parent.respond_to?(:each)
+ parent.each do |child|
+ flats << self.flatten(child)
+ end
+ elsif parent.respond_to?(:products)
+ parent.products.children.each do |child|
+
+ flats << self.flatten(child)
+ end
+ else
+ if parent.kind_of?(PBXBuildFile)
+ flats << parent.file.inspect
+ puts "resolved #{parent.file.inspect}"
+ else
+ flats << parent.inspect
+ end
+
+ end
+ return flats
+ end
+
+ def link_with_staticlib(staticLibName,project)
+ frameworkPhase = self.buildPhases.select_by_class(PBXFrameworksBuildPhase)[0]
+ #some group is going to have the appropriate file
+ #file = project.objects.select_by_class(PBXReferenceProxy).find_all{|prox| prox.path==staticLibName}[0]
+ products_groups = project.groups.find_all{|g| g.name=='Products'}
+ products_groups.each {|products| products.reference_proxies.each {|child| puts child.inspect} }
+ file = nil
+ products_groups.each do |products|
+ products.reference_proxies.each do |proxy|
+ if proxy.path==staticLibName
+ file = proxy
+ break
+ end
+ end
+
+ end
+
+ puts "done"
+ if not file
+ puts "WTF is this?"
+ raise "can't find file with that name"
+ end
+ puts "before"
+ self.frameworks_build_phases.first.files.each {|pbxfile| puts pbxfile.file.inspect}
+
+ pbxfile = PBXFileReference.new(project,nil,{"name" => staticLibName,"file" => file})
+ buildFile = pbxfile.buildFiles.new
+
+ puts "something #{buildFile}"
+ #create the link
+ self.frameworks_build_phases.first.files << buildFile
+ #puts "appending #{file.inspect}"
+
+ puts "after"
+ self.frameworks_build_phases.first.files.each {|pbxfile| puts pbxfile.file.inspect}
+
+
+ end
+
def self.new_static_library(project, productName)
# TODO should probably switch the uuid and attributes argument
target = new(project, nil, 'productType' => STATIC_LIBRARY, 'productName' => productName)
@@ -518,7 +604,11 @@ def new(hash = {})
end
def <<(object)
+ puts "appending #{object.inspect}"
+ puts self.inspect
@callback.call(object) if @callback
+ puts "done appending"
+ puts self.inspect
end
def each
@@ -673,6 +763,7 @@ def add_dependency(name,foreignPBXProjName)
return dep
end
+
IGNORE_GROUPS = ['Frameworks', 'Products', 'Supporting Files']
def source_files
source_files = {}

0 comments on commit 39a894f

Please sign in to comment.