Rakefile 5.4 KB

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