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
000ca1fe
Commit
000ca1fe
authored
Sep 01, 2017
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude test resource and framework paths from aggregate targets
parent
38391fc7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
10 deletions
+99
-10
CHANGELOG.md
CHANGELOG.md
+4
-0
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+2
-2
pod_target.rb
lib/cocoapods/target/pod_target.rb
+30
-8
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+63
-0
No files found.
CHANGELOG.md
View file @
000ca1fe
...
@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -43,6 +43,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
Justin Martin
](
https://github.com/justinseanmartin
)
[
Justin Martin
](
https://github.com/justinseanmartin
)
[
#7013
](
https://github.com/CocoaPods/CocoaPods/pull/7013
)
[
#7013
](
https://github.com/CocoaPods/CocoaPods/pull/7013
)
*
Exclude test resource and framework paths from aggregate targets
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7000
](
https://github.com/CocoaPods/CocoaPods/pull/7000
)
*
Wrap platform warning message with quotes
*
Wrap platform warning message with quotes
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6968
](
https://github.com/CocoaPods/CocoaPods/pull/6968
)
[
#6968
](
https://github.com/CocoaPods/CocoaPods/pull/6968
)
...
...
lib/cocoapods/target/aggregate_target.rb
View file @
000ca1fe
...
@@ -194,7 +194,7 @@ module Pod
...
@@ -194,7 +194,7 @@ module Pod
relevant_pod_targets
=
pod_targets
.
select
do
|
pod_target
|
relevant_pod_targets
=
pod_targets
.
select
do
|
pod_target
|
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
end
end
framework_paths_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
(
&
:framework_paths
)
framework_paths_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
{
|
pt
|
pt
.
framework_paths
(
false
)
}
end
end
framework_paths_by_config
framework_paths_by_config
end
end
...
@@ -210,7 +210,7 @@ module Pod
...
@@ -210,7 +210,7 @@ module Pod
user_build_configurations
.
keys
.
each_with_object
({})
do
|
config
,
resources_by_config
|
user_build_configurations
.
keys
.
each_with_object
({})
do
|
config
,
resources_by_config
|
resources_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
do
|
pod_target
|
resources_by_config
[
config
]
=
relevant_pod_targets
.
flat_map
do
|
pod_target
|
next
[]
unless
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
next
[]
unless
pod_target
.
include_in_build_config?
(
target_definition
,
config
)
(
pod_target
.
resource_paths
+
[
bridge_support_file
].
compact
).
uniq
(
pod_target
.
resource_paths
(
false
)
+
[
bridge_support_file
].
compact
).
uniq
end
end
end
end
end
end
...
...
lib/cocoapods/target/pod_target.rb
View file @
000ca1fe
...
@@ -197,13 +197,22 @@ module Pod
...
@@ -197,13 +197,22 @@ module Pod
specs
.
select
(
&
:test_specification?
).
map
(
&
:test_type
).
uniq
specs
.
select
(
&
:test_specification?
).
map
(
&
:test_type
).
uniq
end
end
# Returns the framework paths associated with this target. By default all paths include the framework paths
# that are part of test specifications.
#
# @param [Boolean] include_test_spec_paths
# Whether to include framework paths from test specifications or not.
#
# @return [Array<Hash{Symbol => [String]}>] The vendored and non vendored framework paths
# @return [Array<Hash{Symbol => [String]}>] The vendored and non vendored framework paths
# this target depends upon.
# this target depends upon.
#
#
def
framework_paths
def
framework_paths
(
include_test_spec_paths
=
true
)
@framework_paths
||=
begin
@framework_paths
||=
Hash
.
new
do
|
h
,
key
|
h
[
key
]
=
begin
accessors
=
file_accessors
accessors
=
accessors
.
reject
{
|
a
|
a
.
spec
.
test_specification?
}
unless
include_test_spec_paths
frameworks
=
[]
frameworks
=
[]
file_
accessors
.
flat_map
(
&
:vendored_dynamic_artifacts
).
map
do
|
framework_path
|
accessors
.
flat_map
(
&
:vendored_dynamic_artifacts
).
map
do
|
framework_path
|
relative_path_to_sandbox
=
framework_path
.
relative_path_from
(
sandbox
.
root
)
relative_path_to_sandbox
=
framework_path
.
relative_path_from
(
sandbox
.
root
)
framework
=
{
:name
=>
framework_path
.
basename
.
to_s
,
framework
=
{
:name
=>
framework_path
.
basename
.
to_s
,
:input_path
=>
"${PODS_ROOT}/
#{
relative_path_to_sandbox
}
"
,
:input_path
=>
"${PODS_ROOT}/
#{
relative_path_to_sandbox
}
"
,
...
@@ -227,15 +236,26 @@ module Pod
...
@@ -227,15 +236,26 @@ module Pod
frameworks
frameworks
end
end
end
end
@framework_paths
[
include_test_spec_paths
]
end
# Returns the resource paths associated with this target. By default all paths include the resource paths
# that are part of test specifications.
#
# @param [Boolean] include_test_spec_paths
# Whether to include resource paths from test specifications or not.
#
# @return [Array<String>] The resource and resource bundle paths this target depends upon.
# @return [Array<String>] The resource and resource bundle paths this target depends upon.
#
#
def
resource_paths
def
resource_paths
(
include_test_spec_paths
=
true
)
@resource_paths
||=
begin
@resource_paths
||=
Hash
.
new
do
|
h
,
key
|
resource_paths
=
file_accessors
.
flat_map
do
|
accessor
|
h
[
key
]
=
begin
accessors
=
file_accessors
accessors
=
accessors
.
reject
{
|
a
|
a
.
spec
.
test_specification?
}
unless
include_test_spec_paths
resource_paths
=
accessors
.
flat_map
do
|
accessor
|
accessor
.
resources
.
flat_map
{
|
res
|
"${PODS_ROOT}/
#{
res
.
relative_path_from
(
sandbox
.
project
.
path
.
dirname
)
}
"
}
accessor
.
resources
.
flat_map
{
|
res
|
"${PODS_ROOT}/
#{
res
.
relative_path_from
(
sandbox
.
project
.
path
.
dirname
)
}
"
}
end
end
resource_bundles
=
file_
accessors
.
flat_map
do
|
accessor
|
resource_bundles
=
accessors
.
flat_map
do
|
accessor
|
prefix
=
Generator
::
XCConfig
::
XCConfigHelper
::
CONFIGURATION_BUILD_DIR_VARIABLE
prefix
=
Generator
::
XCConfig
::
XCConfigHelper
::
CONFIGURATION_BUILD_DIR_VARIABLE
prefix
=
configuration_build_dir
unless
accessor
.
spec
.
test_specification?
prefix
=
configuration_build_dir
unless
accessor
.
spec
.
test_specification?
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"
#{
prefix
}
/
#{
name
.
shellescape
}
.bundle"
}
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"
#{
prefix
}
/
#{
name
.
shellescape
}
.bundle"
}
...
@@ -243,13 +263,15 @@ module Pod
...
@@ -243,13 +263,15 @@ module Pod
resource_paths
+
resource_bundles
resource_paths
+
resource_bundles
end
end
end
end
@resource_paths
[
include_test_spec_paths
]
end
# Returns the corresponding native target to use based on the provided specification.
# Returns the corresponding native target to use based on the provided specification.
# This is used to figure out whether to add a source file into the library native target or any of the
# This is used to figure out whether to add a source file into the library native target or any of the
# test native targets.
# test native targets.
#
#
# @param [Specification] spec
# @param [Specification] spec
# The specifcation to base from in order to find the native target.
# The specif
i
cation to base from in order to find the native target.
#
#
# @return [PBXNativeTarget] the native target to use or `nil` if none is found.
# @return [PBXNativeTarget] the native target to use or `nil` if none is found.
#
#
...
...
spec/unit/target/pod_target_spec.rb
View file @
000ca1fe
...
@@ -375,6 +375,69 @@ module Pod
...
@@ -375,6 +375,69 @@ module Pod
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
])
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
])
@test_pod_target
.
resource_paths
.
should
==
[
'$PODS_CONFIGURATION_BUILD_DIR/TestResourceBundle.bundle'
]
@test_pod_target
.
resource_paths
.
should
==
[
'$PODS_CONFIGURATION_BUILD_DIR/TestResourceBundle.bundle'
]
end
end
it
'includes framework paths from test specifications'
do
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/Vendored.framework'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/TestVendored.framework'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
stubs
(
:should_build?
).
returns
(
true
)
@test_pod_target
.
framework_paths
.
should
==
[
{
:name
=>
'Vendored.framework'
,
:input_path
=>
'${PODS_ROOT}/Vendored/Vendored.framework'
,
:output_path
=>
'${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Vendored.framework'
},
{
:name
=>
'TestVendored.framework'
,
:input_path
=>
'${PODS_ROOT}/Vendored/TestVendored.framework'
,
:output_path
=>
'${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TestVendored.framework'
},
]
end
it
'excludes framework paths from test specifications when not requested'
do
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/Vendored.framework'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:vendored_dynamic_artifacts
).
returns
([
config
.
sandbox
.
root
+
Pathname
.
new
(
'Vendored/TestVendored.framework'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
stubs
(
:should_build?
).
returns
(
true
)
@test_pod_target
.
framework_paths
(
false
).
should
==
[
{
:name
=>
'Vendored.framework'
,
:input_path
=>
'${PODS_ROOT}/Vendored/Vendored.framework'
,
:output_path
=>
'${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Vendored.framework'
},
]
end
it
'includes resource paths from test specifications'
do
config
.
sandbox
.
stubs
(
:project
=>
stub
(
:path
=>
Pathname
.
new
(
'ProjectPath'
)))
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:resource_bundles
).
returns
({})
fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'Model.xcdatamodeld'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:resource_bundles
).
returns
({})
test_fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'TestModel.xcdatamodeld'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
resource_paths
.
should
==
[
'${PODS_ROOT}/Model.xcdatamodeld'
,
'${PODS_ROOT}/TestModel.xcdatamodeld'
]
end
it
'excludes resource paths from test specifications when not requested'
do
config
.
sandbox
.
stubs
(
:project
=>
stub
(
:path
=>
Pathname
.
new
(
'ProjectPath'
)))
fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
fa
.
stubs
(
:resource_bundles
).
returns
({})
fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'Model.xcdatamodeld'
)])
fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
false
))
test_fa
=
Sandbox
::
FileAccessor
.
new
(
nil
,
@test_pod_target
)
test_fa
.
stubs
(
:resource_bundles
).
returns
({})
test_fa
.
stubs
(
:resources
).
returns
([
Pathname
.
new
(
'TestModel.xcdatamodeld'
)])
test_fa
.
stubs
(
:spec
).
returns
(
stub
(
:test_specification?
=>
true
))
@test_pod_target
.
stubs
(
:file_accessors
).
returns
([
fa
,
test_fa
])
@test_pod_target
.
resource_paths
(
false
).
should
==
[
'${PODS_ROOT}/Model.xcdatamodeld'
]
end
end
end
end
end
end
end
...
...
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