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

Commit 972ff3d

Browse files
committed
Merge pull request #26 from ParsePlatform/nlutsenko.rakefile
Add custom packaging into a precompiled binary via Rakefile.
2 parents 803ab04 + 71bfad4 commit 972ff3d

File tree

4 files changed

+108
-4
lines changed

4 files changed

+108
-4
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
matrix:
1313
- TEST_TYPE=iOS
1414
- TEST_TYPE=CocoaPods
15+
- TEST_TYPE=Package
1516
script:
1617
- |
1718
if [ "$TEST_TYPE" = iOS ]; then
@@ -20,6 +21,8 @@ script:
2021
elif [ "$TEST_TYPE" = CocoaPods ]; then
2122
pod lib lint ParseFacebookUtilsV4.podspec
2223
pod lib lint --use-libraries ParseFacebookUtilsV4.podspec
24+
elif [ "$TEST_TYPE" = Package ]; then
25+
bundle exec rake package:frameworks
2326
fi
2427
after_success:
2528
- |

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
source 'https://rubygems.org'
22

3+
gem 'naturally'
4+
gem 'rake'
35
gem 'xcpretty'
4-
gem 'cocoapods', '~> 0.39.0.rc.1'
6+
gem 'cocoapods', '~> 0.39'

Gemfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (4.2.4)
4+
activesupport (4.2.5)
55
i18n (~> 0.7)
66
json (~> 1.7, >= 1.7.7)
77
minitest (~> 5.1)
@@ -41,10 +41,12 @@ GEM
4141
fuzzy_match (2.0.4)
4242
i18n (0.7.0)
4343
json (1.8.3)
44-
minitest (5.8.2)
44+
minitest (5.8.3)
4545
molinillo (0.4.0)
4646
nap (1.0.0)
47+
naturally (2.1.0)
4748
netrc (0.7.8)
49+
rake (10.4.2)
4850
rouge (1.10.1)
4951
thread_safe (0.3.5)
5052
tzinfo (1.2.2)
@@ -60,7 +62,9 @@ PLATFORMS
6062
ruby
6163

6264
DEPENDENCIES
63-
cocoapods (~> 0.39.0.rc.1)
65+
cocoapods (~> 0.39)
66+
naturally
67+
rake
6468
xcpretty
6569

6670
BUNDLED WITH

Rakefile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#
2+
# Copyright (c) 2015-present, Parse, LLC.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree. An additional grant
7+
# of patent rights can be found in the PATENTS file in the same directory.
8+
#
9+
10+
require_relative 'Vendor/xctoolchain/Scripts/xctask/build_task'
11+
require_relative 'Vendor/xctoolchain/Scripts/xctask/build_framework_task'
12+
13+
script_folder = File.expand_path(File.dirname(__FILE__))
14+
build_folder = File.join(script_folder, 'build')
15+
release_folder = File.join(build_folder, 'release')
16+
17+
xcworkspace_name = 'ParseFacebookUtils.xcworkspace'
18+
framework_name = 'ParseFacebookUtilsV4.framework'
19+
20+
namespace :build do
21+
desc 'Build iOS framework.'
22+
task :ios do
23+
task = XCTask::BuildFrameworkTask.new do |t|
24+
t.directory = script_folder
25+
t.build_directory = File.join(build_folder, 'iOS')
26+
t.framework_type = XCTask::FrameworkType::IOS
27+
t.framework_name = framework_name
28+
29+
t.workspace = xcworkspace_name
30+
t.scheme = 'ParseFacebookUtilsV4-iOS'
31+
t.configuration = 'Release'
32+
end
33+
result = task.execute
34+
unless result
35+
puts 'Failed to build iOS Framework.'
36+
exit(1)
37+
end
38+
end
39+
40+
desc 'Build tvOS framework.'
41+
task :tvos do
42+
task = XCTask::BuildFrameworkTask.new do |t|
43+
t.directory = script_folder
44+
t.build_directory = File.join(build_folder, 'tvOS')
45+
t.framework_type = XCTask::FrameworkType::TVOS
46+
t.framework_name = framework_name
47+
48+
t.workspace = xcworkspace_name
49+
t.scheme = 'ParseFacebookUtilsV4-tvOS'
50+
t.configuration = 'Release'
51+
end
52+
result = task.execute
53+
unless result
54+
puts 'Failed to build tvOS Framework.'
55+
exit(1)
56+
end
57+
end
58+
end
59+
60+
namespace :package do
61+
ios_package_name = 'ParseFacebookUtils-iOS.zip'
62+
tvos_package_name = 'ParseFacebookUtils-tvOS.zip'
63+
64+
desc 'Build and package all frameworks'
65+
task :frameworks do
66+
rm_rf build_folder, :verbose => false
67+
mkdir_p build_folder, :verbose => false
68+
69+
Rake::Task['build:ios'].invoke
70+
ios_framework_path = File.join(build_folder, 'iOS', framework_name)
71+
make_package(release_folder, [ios_framework_path], ios_package_name)
72+
73+
Rake::Task['build:tvos'].invoke
74+
tvos_framework_path = File.join(build_folder, 'tvOS', framework_name)
75+
make_package(release_folder, [tvos_framework_path], tvos_package_name)
76+
end
77+
78+
def make_package(target_path, items, archive_name)
79+
temp_folder = File.join(target_path, 'tmp')
80+
`mkdir -p #{temp_folder}`
81+
82+
item_list = ''
83+
items.each do |item|
84+
`cp -R #{item} #{temp_folder}`
85+
86+
file_name = File.basename(item)
87+
item_list << " #{file_name}"
88+
end
89+
90+
archive_path = File.join(target_path, archive_name)
91+
`cd #{temp_folder}; zip -r --symlinks #{archive_path} #{item_list}`
92+
rm_rf temp_folder
93+
puts "Release archive created: #{File.join(target_path, archive_name)}"
94+
end
95+
end

0 commit comments

Comments
 (0)