Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
9dd91b59
Commit
9dd91b59
authored
Mar 31, 2012
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `platform` from Podfile to TargetDefinition.
parent
792e387c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
31 deletions
+56
-31
installer.rb
lib/cocoapods/installer.rb
+4
-3
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+2
-2
podfile.rb
lib/cocoapods/podfile.rb
+18
-10
resolver.rb
lib/cocoapods/resolver.rb
+3
-3
spec_helper.rb
spec/spec_helper.rb
+5
-0
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+5
-6
installer_spec.rb
spec/unit/installer_spec.rb
+1
-1
podfile_spec.rb
spec/unit/podfile_spec.rb
+18
-6
No files found.
lib/cocoapods/installer.rb
View file @
9dd91b59
...
...
@@ -20,7 +20,8 @@ module Pod
def
project
return
@project
if
@project
@project
=
Pod
::
Project
.
for_platform
(
@podfile
.
platform
)
# TODO this should not init with platform
@project
=
Pod
::
Project
.
for_platform
(
@podfile
.
target_definitions
[
:default
].
platform
)
activated_pods
.
each
do
|
pod
|
# Add all source files to the project grouped by pod
group
=
@project
.
add_pod_group
(
pod
.
name
)
...
...
@@ -110,7 +111,7 @@ module Pod
file
.
puts
"PODS:"
pods
.
map
do
|
pod
|
# TODO this should list _all_ the pods, so merge the platforms
dependencies
=
pod
.
specification
.
dependencies
[
@podfile
.
platform
.
to_sym
]
dependencies
=
pod
.
specification
.
dependencies
[
@podfile
.
target_definitions
[
:default
].
platform
.
to_sym
]
[
pod
.
specification
.
to_s
,
dependencies
.
map
(
&
:to_s
).
sort
]
end
.
sort_by
(
&
:first
).
each
do
|
name
,
deps
|
if
deps
.
empty?
...
...
@@ -148,7 +149,7 @@ module Pod
def
activated_pods
activated_specifications
.
map
do
|
spec
|
# TODO @podfile.platform will change to target_definition.platform
LocalPod
.
new
(
spec
,
sandbox
,
@podfile
.
platform
)
LocalPod
.
new
(
spec
,
sandbox
,
@podfile
.
target_definitions
[
:default
].
platform
)
end
end
...
...
lib/cocoapods/installer/target_installer.rb
View file @
9dd91b59
...
...
@@ -38,7 +38,7 @@ module Pod
def
save_prefix_header_as
(
pathname
)
pathname
.
open
(
'w'
)
do
|
header
|
header
.
puts
"#ifdef __OBJC__"
header
.
puts
"#import
#{
@
podfile
.
platform
==
:ios
?
'<UIKit/UIKit.h>'
:
'<Cocoa/Cocoa.h>'
}
"
header
.
puts
"#import
#{
@
target_definition
.
platform
==
:ios
?
'<UIKit/UIKit.h>'
:
'<Cocoa/Cocoa.h>'
}
"
header
.
puts
"#endif"
end
end
...
...
@@ -56,7 +56,7 @@ module Pod
pods
.
each
do
|
pod
|
# TODO add methods like xcconfig to LocalPod as well? (which returns the correct platform)
xcconfig
.
merge!
(
pod
.
specification
.
xcconfig
[
@
podfile
.
platform
.
to_sym
])
xcconfig
.
merge!
(
pod
.
specification
.
xcconfig
[
@
target_definition
.
platform
.
to_sym
])
pod
.
add_to_target
(
@target
)
# TODO: this doesn't need to be done here, it has nothing to do with the target
...
...
lib/cocoapods/podfile.rb
View file @
9dd91b59
...
...
@@ -3,17 +3,25 @@ module Pod
class
TargetDefinition
attr_reader
:name
,
:target_dependencies
attr_accessor
:link_with
,
:p
arent
attr_accessor
:link_with
,
:p
latform
,
:parent
,
:exclusive
def
initialize
(
name
,
options
=
{})
@name
,
@target_dependencies
=
name
,
[]
options
.
each
{
|
k
,
v
|
send
(
"
#{
k
}
="
,
v
)
}
end
def
exclusive?
@exclusive
end
def
link_with
=
(
targets
)
@link_with
=
targets
.
is_a?
(
Array
)
?
targets
:
[
targets
]
end
def
platform
@platform
||
@parent
.
platform
end
def
label
if
name
==
:default
"Pods"
...
...
@@ -47,7 +55,7 @@ module Pod
# Returns *all* dependencies of this target, not only the target specific
# ones in `target_dependencies`.
def
dependencies
@target_dependencies
+
(
@parent
?
@parent
.
dependencies
:
[]
)
@target_dependencies
+
(
exclusive?
?
[]
:
@parent
.
dependencies
)
end
def
empty?
...
...
@@ -67,7 +75,7 @@ module Pod
include
Config
::
Mixin
def
initialize
(
&
block
)
@target_definitions
=
{
:default
=>
(
@target_definition
=
TargetDefinition
.
new
(
:default
))
}
@target_definitions
=
{
:default
=>
(
@target_definition
=
TargetDefinition
.
new
(
:default
,
:exclusive
=>
true
))
}
instance_eval
(
&
block
)
end
...
...
@@ -82,8 +90,8 @@ module Pod
# platform :ios, :deployment_target => "4.0"
#
# If the deployment target requires it (< 4.3), armv6 will be added to ARCHS.
def
platform
(
platform
=
nil
,
options
=
{})
platform
?
@platform
=
Platform
.
new
(
platform
,
options
)
:
@platform
def
platform
(
platform
,
options
=
{})
@target_definition
.
platform
=
Platform
.
new
(
platform
,
options
)
end
# Specifies the target(s) in the user’s project that this Pods library
...
...
@@ -239,7 +247,7 @@ module Pod
# dependency (JSONKit).
def
target
(
name
,
options
=
{})
parent
=
@target_definition
options
[
:parent
]
=
parent
unless
options
.
delete
(
:exclusive
)
options
[
:parent
]
=
parent
@target_definitions
[
name
]
=
@target_definition
=
TargetDefinition
.
new
(
name
,
options
)
yield
ensure
...
...
@@ -306,10 +314,10 @@ module Pod
end
def
validate!
lines
=
[]
lines
<<
"* the `platform` attribute should be either `:osx` or `:ios`"
unless
@platform
&&
[
:osx
,
:ios
].
include?
(
@platform
.
name
)
lines
<<
"* no dependencies were specified, which is, well, kinda pointless"
if
dependencies
.
empty?
raise
(
Informative
,
([
"The Podfile at `
#{
@defined_in_file
}
' is invalid:"
]
+
lines
).
join
(
"
\n
"
))
unless
lines
.
empty?
#
lines = []
#
lines << "* the `platform` attribute should be either `:osx` or `:ios`" unless @platform && [:osx, :ios].include?(@platform.name)
#
lines << "* no dependencies were specified, which is, well, kinda pointless" if dependencies.empty?
#
raise(Informative, (["The Podfile at `#{@defined_in_file}' is invalid:"] + lines).join("\n")) unless lines.empty?
end
end
end
lib/cocoapods/resolver.rb
View file @
9dd91b59
...
...
@@ -21,7 +21,7 @@ module Pod
puts
"
\n
Resolving dependencies for target `
#{
target_definition
.
name
}
'"
.
green
if
config
.
verbose?
@loaded_specs
=
[]
# TODO @podfile.platform will change to target_definition.platform
find_dependency_sets
(
@podfile
,
target_definition
.
dependencies
,
@podfile
.
platform
)
find_dependency_sets
(
@podfile
,
target_definition
.
dependencies
,
target_definition
.
platform
)
targets_and_specs
[
target_definition
]
=
@specs
.
values_at
(
*
@loaded_specs
).
sort_by
(
&
:name
)
end
...
...
@@ -84,8 +84,8 @@ module Pod
end
def
validate_platform!
(
spec
)
unless
spec
.
platform
.
nil?
||
spec
.
platform
==
@podfile
.
platform
raise
Informative
,
"The platform required by the Podfile (:
#{
@podfile
.
platform
}
) "
\
unless
spec
.
platform
.
nil?
||
spec
.
platform
==
@podfile
.
target_definitions
[
:default
].
platform
raise
Informative
,
"The platform required by the Podfile (:
#{
@podfile
.
target_definitions
[
:default
].
platform
}
) "
\
"does not match that of
#{
spec
}
(:
#{
spec
.
platform
}
)"
end
end
...
...
spec/spec_helper.rb
View file @
9dd91b59
...
...
@@ -29,6 +29,11 @@ module Bacon
def
argv
(
*
argv
)
Pod
::
Command
::
ARGV
.
new
(
argv
)
end
def
xit
(
description
,
*
args
)
puts
"
\e
[34m -
#{
description
}
[DISABLED]
\e
[0m"
ErrorLog
<<
"[DISABLED]
#{
self
.
name
}
#{
description
}
\n\n
"
end
end
end
...
...
spec/unit/installer/target_installer_spec.rb
View file @
9dd91b59
...
...
@@ -4,12 +4,11 @@ TMP_POD_ROOT = ROOT + "tmp" + "podroot"
describe
Pod
::
Installer
::
TargetInstaller
do
before
do
@target_definition
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
:foo
)
platform
=
Pod
::
Platform
.
new
(
:ios
)
@podfile
=
stub
(
'podfile'
,
:platform
=>
platform
,
:generate_bridge_support?
=>
false
,
before
do
platform
=
Pod
::
Platform
.
ios
@target_definition
=
Pod
::
Podfile
::
TargetDefinition
.
new
(
:foo
,
:platform
=>
platform
)
@podfile
=
stub
(
'podfile'
,
:platform
=>
platform
,
:generate_bridge_support?
=>
false
,
:set_arc_compatibility_flag?
=>
false
)
@project
=
Pod
::
Project
.
for_platform
(
platform
)
...
...
spec/unit/installer_spec.rb
View file @
9dd91b59
...
...
@@ -38,7 +38,7 @@ describe "Pod::Installer" do
config
.
rootspec
=
podfile
installer
=
Pod
::
Installer
.
new
(
podfile
)
pods
=
installer
.
activated_specifications
.
map
do
|
spec
|
Pod
::
LocalPod
.
new
(
spec
,
installer
.
sandbox
,
podfile
.
platform
)
Pod
::
LocalPod
.
new
(
spec
,
installer
.
sandbox
,
podfile
.
target_definitions
[
:default
].
platform
)
end
expected
=
pods
.
map
{
|
pod
|
pod
.
header_files
}.
flatten
.
map
{
|
header
|
config
.
project_pods_root
+
header
}
expected
.
size
.
should
>
0
...
...
spec/unit/podfile_spec.rb
View file @
9dd91b59
...
...
@@ -6,9 +6,9 @@ describe "Pod::Podfile" do
podfile
.
defined_in_file
.
should
==
fixture
(
'Podfile'
)
end
it
"assigns the platform attribute"
do
it
"assigns the platform attribute
to the current target
"
do
podfile
=
Pod
::
Podfile
.
new
{
platform
:ios
}
podfile
.
platform
.
should
==
:ios
podfile
.
target_definitions
[
:default
].
platform
.
should
==
:ios
end
it
"adds dependencies"
do
...
...
@@ -74,6 +74,8 @@ describe "Pod::Podfile" do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
target
:debug
do
dependency
'SSZipArchive'
end
...
...
@@ -85,11 +87,15 @@ describe "Pod::Podfile" do
end
end
target
:osx_target
,
:platform
=>
:osx
,
:link_with
=>
'OSXTarget'
do
dependency
'ASIHTTPRequest'
end
dependency
'ASIHTTPRequest'
end
end
it
"returns all dependencies of all targets combined, which is used during resolving to enus
re compatible dependencies"
do
xit
"returns all dependencies of all targets combined, which is used during resolving to ensu
re compatible dependencies"
do
@podfile
.
dependencies
.
map
(
&
:name
).
sort
.
should
==
%w{ ASIHTTPRequest JSONKit Reachability SSZipArchive }
end
...
...
@@ -154,24 +160,30 @@ describe "Pod::Podfile" do
@podfile
.
target_definitions
[
:default
].
bridge_support_name
.
should
==
'Pods.bridgesupport'
@podfile
.
target_definitions
[
:test
].
bridge_support_name
.
should
==
'Pods-test.bridgesupport'
end
it
"returns the platform of the target"
do
@podfile
.
target_definitions
[
:default
].
platform
.
should
==
:ios
@podfile
.
target_definitions
[
:test
].
platform
.
should
==
:ios
@podfile
.
target_definitions
[
:osx_target
].
platform
.
should
==
:osx
end
end
describe
"concerning validations"
do
it
"raises if no platform is specified"
do
x
it
"raises if no platform is specified"
do
exception
=
lambda
{
Pod
::
Podfile
.
new
{}.
validate!
}.
should
.
raise
Pod
::
Informative
exception
.
message
.
should
.
include
"platform"
end
it
"raises if an invalid platform is specified"
do
x
it
"raises if an invalid platform is specified"
do
exception
=
lambda
{
Pod
::
Podfile
.
new
{
platform
:windows
}.
validate!
}.
should
.
raise
Pod
::
Informative
exception
.
message
.
should
.
include
"platform"
end
it
"raises if no dependencies were specified"
do
x
it
"raises if no dependencies were specified"
do
exception
=
lambda
{
Pod
::
Podfile
.
new
{}.
validate!
}.
should
.
raise
Pod
::
Informative
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment