Rakefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_MOBILE = 'MobileVLCKit.xcodeproj'
  24. SDK_SIM_IOS = 'iphonesimulator11.3'
  25. SDK_SIM_DEST_IOS = "'platform=iOS Simulator,name=iPhone 7,OS=11.3'"
  26. SCHEME_IOS = 'MobileVLCKitTests'
  27. VLC_FLAGS_IOS = '-dva x86_64'
  28. DERIVED_DATA_PATH = 'DerivedData'
  29. COVERAGE_REPORT_PATH = 'Tests/Coverage'
  30. XCPRETTY = "xcpretty && exit ${PIPESTATUS[0]}"
  31. # ----------------------------------------------------------------- Tasks ------
  32. desc 'Build MobileVLCKit'
  33. task 'build:vlckit:ios' do
  34. puts 'Building MobileVLCKit'
  35. plugin_file = 'Resources/MobileVLCKit/vlc-plugins-iPhone.h'
  36. required_dirs = ['./libvlc/vlc/install-iPhoneSimulator', './libvlc/vlc/build-iPhoneSimulator']
  37. if File.exist?(plugin_file) && dirs_exist?(required_dirs)
  38. puts 'Found pre-existing build directory. Skipping build'
  39. else
  40. sh "./compileAndBuildVLCKit.sh #{VLC_FLAGS_IOS}"
  41. end
  42. end
  43. desc 'Run MobileVLCKit tests'
  44. task 'test:ios' do
  45. puts 'Running tests for MobileVLCKit'
  46. sh "xcodebuild -derivedDataPath #{DERIVED_DATA_PATH}/#{SCHEME_IOS} -project #{PROJECT_MOBILE} -scheme #{SCHEME_IOS} -sdk #{SDK_SIM_IOS} -destination #{SDK_SIM_DEST_IOS} test | #{XCPRETTY}"
  47. end
  48. desc 'Generate code coverage reports (MobileVLCKit)'
  49. task 'codecov:ios' do
  50. puts 'Generating code coverage reports (MobileVLCKit)'
  51. generate_coverage(SCHEME_IOS)
  52. end
  53. # ------------------------------------------------------------- Functions ------
  54. def generate_coverage(scheme)
  55. report_name = "#{COVERAGE_REPORT_PATH}/#{scheme}_coverage.txt"
  56. scheme_derived_data = "#{DERIVED_DATA_PATH}/#{scheme}"
  57. if Dir.exist?(scheme_derived_data)
  58. sh "mkdir -p #{COVERAGE_REPORT_PATH}"
  59. sh "xcrun xccov view #{scheme_derived_data}/Logs/Test/*.xccovreport > #{report_name}"
  60. sh "cat #{report_name}"
  61. else
  62. puts "#{scheme} has not been tested yet. Please run its tests first"
  63. end
  64. end
  65. def dirs_exist?(directories)
  66. directories.each do |dir|
  67. return false unless Dir.exist?(dir)
  68. end
  69. end