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

check env var in shell script

parent 5070013c
......@@ -34,11 +34,6 @@ module Pod
# @return [String] The contents of the embed frameworks script.
#
def script
codesign_bg = ''
parallel_codesign = ENV['COCOAPODS_PARALLEL_CODE_SIGN'] == 'true'
if parallel_codesign
codesign_bg = ' &'
end
script = <<-SH.strip_heredoc
#!/bin/sh
set -e
......@@ -101,8 +96,13 @@ module Pod
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy
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}"
/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\""
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
fi
echo "$code_sign_cmd"
eval "$code_sign_cmd"
fi
}
......@@ -135,7 +135,11 @@ module Pod
script << "fi\n"
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
end
end
......
......@@ -2,45 +2,23 @@ require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Generator::EmbedFrameworksScript do
before do
ENV.delete('COCOAPODS_PARALLEL_CODE_SIGN')
it 'returns the embed frameworks script' do
frameworks = {
'Debug' => %w(Pods/Loopback.framework Reveal.framework),
'Release' => %w(CrashlyticsFramework.framework),
}
@generator = Pod::Generator::EmbedFrameworksScript.new(frameworks)
end
it 'returns the embed frameworks script' do
@generator.send(:script).should.include <<-SH.strip_heredoc
generator = Pod::Generator::EmbedFrameworksScript.new(frameworks)
generator.send(:script).should.include <<-SH.strip_heredoc
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework "Pods/Loopback.framework"
install_framework "Reveal.framework"
fi
SH
@generator.send(:script).should.include <<-SH.strip_heredoc
generator.send(:script).should.include <<-SH.strip_heredoc
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework "CrashlyticsFramework.framework"
fi
SH
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
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