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

Commit 85955db

Browse files
committed
Add custom deployment script via Rakefile.
1 parent 19c7b15 commit 85955db

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

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)