Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Add custom packaging into a precompiled binary via Rakefile. #16

Merged
merged 3 commits into from
Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
matrix:
- TEST_TYPE=iOS
- TEST_TYPE=CocoaPods
- TEST_TYPE=Package
script:
- |
if [ "$TEST_TYPE" = iOS ]; then
Expand All @@ -19,6 +20,8 @@ script:
elif [ "$TEST_TYPE" = CocoaPods ]; then
pod lib lint ParseTwitterUtils.podspec
pod lib lint --use-libraries ParseTwitterUtils.podspec
elif [ "$TEST_TYPE" = Package ]; then
bundle exec rake package:frameworks
fi
after_success:
- |
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source 'https://rubygems.org'

gem 'naturally'
gem 'rake'
gem 'xcpretty'
gem 'cocoapods', '~> 0.39.0.rc.1'
gem 'cocoapods', '~> 0.39'
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.4)
activesupport (4.2.5)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
Expand Down Expand Up @@ -41,10 +41,12 @@ GEM
fuzzy_match (2.0.4)
i18n (0.7.0)
json (1.8.3)
minitest (5.8.2)
minitest (5.8.3)
molinillo (0.4.0)
nap (1.0.0)
naturally (2.1.0)
netrc (0.7.8)
rake (10.4.2)
rouge (1.10.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
Expand All @@ -60,7 +62,9 @@ PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 0.39.0.rc.1)
cocoapods (~> 0.39)
naturally
rake
xcpretty

BUNDLED WITH
Expand Down
71 changes: 71 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#
# Copyright (c) 2015-present, Parse, LLC.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
#

require_relative 'Vendor/xctoolchain/Scripts/xctask/build_task'
require_relative 'Vendor/xctoolchain/Scripts/xctask/build_framework_task'

script_folder = File.expand_path(File.dirname(__FILE__))
build_folder = File.join(script_folder, 'build')
release_folder = File.join(build_folder, 'release')

xcworkspace_name = 'ParseTwitterUtils.xcworkspace'
framework_name = 'ParseTwitterUtils.framework'

namespace :build do
desc 'Build iOS framework.'
task :ios do
task = XCTask::BuildFrameworkTask.new do |t|
t.directory = script_folder
t.build_directory = build_folder
t.framework_type = XCTask::FrameworkType::IOS
t.framework_name = framework_name

t.workspace = xcworkspace_name
t.scheme = 'ParseTwitterUtils-iOS'
t.configuration = 'Release'
end
result = task.execute
unless result
puts 'Failed to build iOS Framework.'
exit(1)
end
end
end

namespace :package do
ios_package_name = 'ParseTwitterUtils-iOS.zip'

desc 'Build and package all frameworks'
task :frameworks do
rm_rf build_folder, :verbose => false
mkdir_p build_folder, :verbose => false

Rake::Task['build:ios'].invoke
ios_framework_path = File.join(build_folder, framework_name)
make_package(release_folder, [ios_framework_path], ios_package_name)
end

def make_package(target_path, items, archive_name)
temp_folder = File.join(target_path, 'tmp')
`mkdir -p #{temp_folder}`

item_list = ''
items.each do |item|
`cp -R #{item} #{temp_folder}`

file_name = File.basename(item)
item_list << " #{file_name}"
end

archive_path = File.join(target_path, archive_name)
`cd #{temp_folder}; zip -r --symlinks #{archive_path} #{item_list}`
rm_rf temp_folder
puts "Release archive created: #{File.join(target_path, archive_name)}"
end
end