forked from videolan/vlckit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
148 lines (121 loc) · 4.85 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Rakefile
# Copyright (C) 2018 Mike JS Choi
# Copyright (C) 2018 VLC authors and VideoLAN
# $Id$
#
# Authors: Mike JS. Choi <mkchoi212 # icloud.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
#
# ------------------------------------------------------------- Constants ------
PROJECT_IOS = 'MobileVLCKit.xcodeproj'
PROJECT_TV = 'MobileVLCKit.xcodeproj'
PROJECT_MAC = 'VLCKit.xcodeproj'
SDK_SIM_IOS = 'iphonesimulator11.3'
SDK_SIM_TV = 'appletvsimulator11.3'
SDK_SIM_MAC = 'macosx10.13'
SDK_SIM_DEST_IOS = "'platform=iOS Simulator,name=iPhone 7,OS=11.3'"
SDK_SIM_DEST_TV = "'platform=tvOS Simulator,name=Apple TV,OS=11.3'"
SDK_SIM_DEST_MAC = "'platform=OS X,arch=x86_64'"
SCHEME_IOS = 'MobileVLCKitTests'
SCHEME_TV = 'TVVLCKitTests'
SCHEME_MAC = 'VLCKitTests'
VLC_FLAGS_IOS = '-dva x86_64'
VLC_FLAGS_TV = '-st'
VLC_FLAGS_MAC = '-dxs'
DERIVED_DATA_PATH = 'DerivedData'
COVERAGE_REPORT_PATH = 'Tests/Coverage'
XCPRETTY = "xcpretty && exit ${PIPESTATUS[0]}"
# ----------------------------------------------------------------- Tasks ------
desc 'Build MobileVLCKit'
task 'build:vlckit:ios' do
puts 'Building MobileVLCKit'
plugin_file = 'Resources/MobileVLCKit/vlc-plugins-iPhone.h'
required_dirs = ['./libvlc/vlc/install-iPhoneSimulator', './libvlc/vlc/build-iPhoneSimulator']
if File.exist?(plugin_file) && dirs_exist?(required_dirs)
puts 'Found pre-existing build directory. Skipping build'
else
sh "./compileAndBuildVLCKit.sh #{VLC_FLAGS_IOS}"
end
end
desc 'Build TVVLCKit'
task 'build:vlckit:tv' do
puts 'Building TVVLCKit'
plugin_file = 'Resources/MobileVLCKit/vlc-plugins-AppleTV.xcconfig'
required_dirs = ['./libvlc/vlc/install-AppleTVSimulator', './libvlc/vlc/build-AppleTVSimulator']
if File.exist?(plugin_file) && dirs_exist?(required_dirs)
puts 'Found pre-existing build directory. Skipping build'
else
sh "./compileAndBuildVLCKit.sh #{VLC_FLAGS_TV}"
end
end
desc 'Build VLCKit (macOS)'
task 'build:vlckit:mac' do
puts 'Building VLCKit (macOS)'
plugin_file = 'Resources/MobileVLCKit/vlc-plugins-MacOSX.xcconfig'
required_dirs = ['./libvlc/vlc/install-MacOSX', './libvlc/vlc/build-MacOSX']
if File.exist?(plugin_file) && dirs_exist?(required_dirs)
puts 'Found pre-existing build directory. Skipping build'
else
sh "./compileAndBuildVLCKit.sh #{VLC_FLAGS_MAC}"
end
end
desc 'Run MobileVLCKit tests'
task 'test:ios' do
puts 'Running tests for MobileVLCKit'
sh "xcodebuild -derivedDataPath #{DERIVED_DATA_PATH}/#{SCHEME_IOS} -project #{PROJECT_IOS} -scheme #{SCHEME_IOS} -sdk #{SDK_SIM_IOS} -destination #{SDK_SIM_DEST_IOS} test | #{XCPRETTY}"
end
desc 'Run TVVLCKit tests'
task 'test:tv' do
puts 'Running tests for TVVLCKit'
sh "xcodebuild -derivedDataPath #{DERIVED_DATA_PATH}/#{SCHEME_TV} -project #{PROJECT_TV} -scheme #{SCHEME_TV} -sdk #{SDK_SIM_TV} -destination #{SDK_SIM_DEST_TV} test | #{XCPRETTY}"
end
desc 'Run VLCKit tests'
task 'test:mac' do
puts 'Running tests for VLCKit'
sh "xcodebuild -derivedDataPath #{DERIVED_DATA_PATH}/#{SCHEME_MAC} -project #{PROJECT_MAC} -scheme #{SCHEME_MAC} -sdk #{SDK_SIM_MAC} -destination #{SDK_SIM_DEST_MAC} test | #{XCPRETTY}"
end
desc 'Generate MobileVLCKit coverage reports'
task 'codecov:ios' do
puts 'Generating MobileVLCKit code coverage reports'
generate_coverage(SCHEME_IOS)
end
desc 'Generate TVVLCKit code coverage reports'
task 'codecov:tv' do
puts 'Generating TVVLCKit code coverage reports'
generate_coverage(SCHEME_TV)
end
desc 'Generate VLCKit (macOS) code coverage reports'
task 'codecov:mac' do
puts 'Generating VLCKit code coverage reports'
generate_coverage(SCHEME_MAC)
end
# ------------------------------------------------------------- Functions ------
def generate_coverage(scheme)
report_name = "#{COVERAGE_REPORT_PATH}/#{scheme}_coverage.txt"
scheme_derived_data = "#{DERIVED_DATA_PATH}/#{scheme}"
if Dir.exist?(scheme_derived_data)
sh "mkdir -p #{COVERAGE_REPORT_PATH}"
sh "xcrun xccov view #{scheme_derived_data}/Logs/Test/*.xccovreport > #{report_name}"
sh "cat #{report_name}"
else
puts "#{scheme} has not been tested yet. Please run its tests first"
end
end
def dirs_exist?(directories)
directories.each do |dir|
return false unless Dir.exist?(dir)
end
end