Commit 279ff119 authored by Marius Rackwitz's avatar Marius Rackwitz

[EmbedFrameworksScript] Be agnostic about target-specific build products

parent ef5f9a4f
module Pod module Pod
module Generator module Generator
class EmbedFrameworksScript class EmbedFrameworksScript
# @return [TargetDefinition] The target definition, whose label will be
# used to locate the target-specific build products.
#
attr_reader :target_definition
# @return [Hash{String, Array{String}] Multiple lists of frameworks per # @return [Hash{String, Array{String}] Multiple lists of frameworks per
# configuration. # configuration.
# #
attr_reader :frameworks_by_config attr_reader :frameworks_by_config
# @param [TargetDefinition] target_definition
# @see #target_definition
#
# @param [Hash{String, Array{String}] frameworks_by_config # @param [Hash{String, Array{String}] frameworks_by_config
# @see #frameworks_by_config # @see #frameworks_by_config
# #
def initialize(target_definition, frameworks_by_config) def initialize(frameworks_by_config)
@target_definition = target_definition
@frameworks_by_config = frameworks_by_config @frameworks_by_config = frameworks_by_config
end end
...@@ -54,7 +45,7 @@ module Pod ...@@ -54,7 +45,7 @@ module Pod
install_framework() install_framework()
{ {
local source="${BUILT_PRODUCTS_DIR}/#{target_definition.label}/$1" local source="${BUILT_PRODUCTS_DIR}/$1"
local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
if [ -L "${source}" ]; then if [ -L "${source}" ]; then
...@@ -72,9 +63,9 @@ module Pod ...@@ -72,9 +63,9 @@ module Pod
# Embed linked Swift runtime libraries # Embed linked Swift runtime libraries
local basename local basename
basename=$(echo $1 | sed -E s/\\\\..+// && exit ${PIPESTATUS[0]}) basename=$(basename $1 | sed -E s/\\\\..+// && exit ${PIPESTATUS[0]})
local swift_runtime_libs local swift_runtime_libs
swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/$1/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\\\/\\(.+dylib\\).*/\\\\1/g | uniq -u && exit ${PIPESTATUS[0]}) swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/${basename}.framework/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\\\/\\(.+dylib\\).*/\\\\1/g | uniq -u && exit ${PIPESTATUS[0]})
for lib in $swift_runtime_libs; do for lib in $swift_runtime_libs; do
echo "rsync -auv \\"${SWIFT_STDLIB_PATH}/${lib}\\" \\"${destination}\\"" echo "rsync -auv \\"${SWIFT_STDLIB_PATH}/${lib}\\" \\"${destination}\\""
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
......
...@@ -140,9 +140,11 @@ module Pod ...@@ -140,9 +140,11 @@ module Pod
target.user_build_configurations.keys.each do |config| target.user_build_configurations.keys.each do |config|
frameworks_by_config[config] = target.pod_targets.select do |pod_target| frameworks_by_config[config] = target.pod_targets.select do |pod_target|
pod_target.include_in_build_config?(config) && pod_target.should_build? pod_target.include_in_build_config?(config) && pod_target.should_build?
end.map(&:product_name) end.map do |pod_target|
"#{target_definition.label}/#{pod_target.product_name}"
end end
generator = Generator::EmbedFrameworksScript.new(target_definition, frameworks_by_config) end
generator = Generator::EmbedFrameworksScript.new(frameworks_by_config)
generator.save_as(path) generator.save_as(path)
add_file_to_support_group(path) add_file_to_support_group(path)
end end
......
...@@ -3,15 +3,14 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,15 +3,14 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Generator::EmbedFrameworksScript do describe Generator::EmbedFrameworksScript do
it 'returns the embed frameworks script' do it 'returns the embed frameworks script' do
target_definition = Podfile::TargetDefinition.new(:default, nil)
frameworks = { frameworks = {
'Debug' => %w(Loopback.framework Reveal.framework), 'Debug' => %w(Pods/Loopback.framework Reveal.framework),
'Release' => %w(CrashlyticsFramework.framework), 'Release' => %w(CrashlyticsFramework.framework),
} }
generator = Pod::Generator::EmbedFrameworksScript.new(target_definition, frameworks) generator = Pod::Generator::EmbedFrameworksScript.new(frameworks)
generator.send(:script).should.include <<-eos.strip_heredoc generator.send(:script).should.include <<-eos.strip_heredoc
if [[ "$CONFIGURATION" == "Debug" ]]; then if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework 'Loopback.framework' install_framework 'Pods/Loopback.framework'
install_framework 'Reveal.framework' install_framework 'Reveal.framework'
fi fi
eos eos
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment