Commit 0d889c8c authored by Ben Asher's avatar Ben Asher

check env var in shell script

parent 5070013c
...@@ -34,11 +34,6 @@ module Pod ...@@ -34,11 +34,6 @@ module Pod
# @return [String] The contents of the embed frameworks script. # @return [String] The contents of the embed frameworks script.
# #
def script def script
codesign_bg = ''
parallel_codesign = ENV['COCOAPODS_PARALLEL_CODE_SIGN'] == 'true'
if parallel_codesign
codesign_bg = ' &'
end
script = <<-SH.strip_heredoc script = <<-SH.strip_heredoc
#!/bin/sh #!/bin/sh
set -e set -e
...@@ -101,8 +96,13 @@ module Pod ...@@ -101,8 +96,13 @@ module Pod
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy # Use the current code_sign_identitiy
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \\"$1\\"#{codesign_bg}" local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\""
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"#{codesign_bg}
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
fi
echo "$code_sign_cmd"
eval "$code_sign_cmd"
fi fi
} }
...@@ -135,7 +135,11 @@ module Pod ...@@ -135,7 +135,11 @@ module Pod
script << "fi\n" script << "fi\n"
end end
end end
script << "wait\n" unless frameworks_by_config.values.all?(&:empty?) || !parallel_codesign script << <<-SH.strip_heredoc
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
wait
fi
SH
script script
end end
end end
......
...@@ -2,45 +2,23 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,45 +2,23 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Generator::EmbedFrameworksScript do describe Generator::EmbedFrameworksScript do
before do it 'returns the embed frameworks script' do
ENV.delete('COCOAPODS_PARALLEL_CODE_SIGN')
frameworks = { frameworks = {
'Debug' => %w(Pods/Loopback.framework Reveal.framework), 'Debug' => %w(Pods/Loopback.framework Reveal.framework),
'Release' => %w(CrashlyticsFramework.framework), 'Release' => %w(CrashlyticsFramework.framework),
} }
@generator = Pod::Generator::EmbedFrameworksScript.new(frameworks) generator = Pod::Generator::EmbedFrameworksScript.new(frameworks)
end generator.send(:script).should.include <<-SH.strip_heredoc
it 'returns the embed frameworks script' do
@generator.send(:script).should.include <<-SH.strip_heredoc
if [[ "$CONFIGURATION" == "Debug" ]]; then if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "Pods/Loopback.framework" install_framework "Pods/Loopback.framework"
install_framework "Reveal.framework" install_framework "Reveal.framework"
fi fi
SH SH
@generator.send(:script).should.include <<-SH.strip_heredoc generator.send(:script).should.include <<-SH.strip_heredoc
if [[ "$CONFIGURATION" == "Release" ]]; then if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "CrashlyticsFramework.framework" install_framework "CrashlyticsFramework.framework"
fi fi
SH SH
end end
it 'runs codesigning in the background when COCOAPODS_PARALLEL_CODE_SIGN is set to true' do
ENV['COCOAPODS_PARALLEL_CODE_SIGN'] = 'true'
@generator.send(:script).should.include <<-SH.strip_heredoc
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" &
SH
@generator.send(:script).should.include <<-SH.strip_heredoc
wait
SH
end
it 'does not run codesigning in the background when COCOAPODS_PARALLEL_CODE_SIGN is set to true' do
@generator.send(:script).should.include <<-SH.strip_heredoc
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"
SH
@generator.send(:script).should.not.include <<-SH.strip_heredoc
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" &
SH
end
end end
end end
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