dependencies.rake 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. DEPENDENCIES_LIBRARIES.each do |deplib|
  2. # Look up the name of this dependency library
  3. deplib_name = @ceedling[DEPENDENCIES_SYM].get_name(deplib)
  4. # Make sure the required working directories exists
  5. # (don't worry about the subdirectories. That's the job of the dep's build tool)
  6. paths = @ceedling[DEPENDENCIES_SYM].get_working_paths(deplib)
  7. paths.each {|path| directory(path) }
  8. task :directories => paths
  9. all_deps = @ceedling[DEPENDENCIES_SYM].get_static_libraries_for_dependency(deplib) +
  10. @ceedling[DEPENDENCIES_SYM].get_dynamic_libraries_for_dependency(deplib) +
  11. @ceedling[DEPENDENCIES_SYM].get_include_directories_for_dependency(deplib) +
  12. @ceedling[DEPENDENCIES_SYM].get_source_files_for_dependency(deplib)
  13. # Add a rule for building the actual libraries from dependency list
  14. (@ceedling[DEPENDENCIES_SYM].get_static_libraries_for_dependency(deplib) +
  15. @ceedling[DEPENDENCIES_SYM].get_dynamic_libraries_for_dependency(deplib)
  16. ).each do |libpath|
  17. file libpath do |filetask|
  18. path = filetask.name
  19. # We double-check that it doesn't already exist, because this process sometimes
  20. # produces multiple files, but they may have already been flagged as invoked
  21. unless (File.exists?(path))
  22. # Set Environment Variables, Fetch, and Build
  23. @ceedling[DEPENDENCIES_SYM].set_env_if_required(path)
  24. @ceedling[DEPENDENCIES_SYM].fetch_if_required(path)
  25. @ceedling[DEPENDENCIES_SYM].build_if_required(path)
  26. end
  27. end
  28. end
  29. # Add a rule for building the source and includes from dependency list
  30. (@ceedling[DEPENDENCIES_SYM].get_include_directories_for_dependency(deplib) +
  31. @ceedling[DEPENDENCIES_SYM].get_source_files_for_dependency(deplib)
  32. ).each do |libpath|
  33. task libpath do |filetask|
  34. path = filetask.name
  35. unless (File.file?(path) || File.directory?(path))
  36. # Set Environment Variables, Fetch, and Build
  37. @ceedling[DEPENDENCIES_SYM].set_env_if_required(path)
  38. @ceedling[DEPENDENCIES_SYM].fetch_if_required(path)
  39. @ceedling[DEPENDENCIES_SYM].build_if_required(path)
  40. end
  41. end
  42. end
  43. # Give ourselves a way to trigger individual dependencies
  44. namespace DEPENDENCIES_SYM do
  45. namespace :deploy do
  46. # Add task to directly just build this dependency
  47. task(deplib_name => @ceedling[DEPENDENCIES_SYM].get_dynamic_libraries_for_dependency(deplib)) do |t,args|
  48. @ceedling[DEPENDENCIES_SYM].deploy_if_required(deplib_name)
  49. end
  50. end
  51. namespace :make do
  52. # Add task to directly just build this dependency
  53. task(deplib_name => all_deps)
  54. end
  55. namespace :clean do
  56. # Add task to directly clobber this dependency
  57. task(deplib_name) do
  58. @ceedling[DEPENDENCIES_SYM].clean_if_required(deplib_name)
  59. end
  60. end
  61. namespace :fetch do
  62. # Add task to directly clobber this dependency
  63. task(deplib_name) do
  64. @ceedling[DEPENDENCIES_SYM].fetch_if_required(deplib_name)
  65. end
  66. end
  67. end
  68. # Add source files to our list of things to build during release
  69. source_files = @ceedling[DEPENDENCIES_SYM].get_source_files_for_dependency(deplib)
  70. task PROJECT_RELEASE_BUILD_TARGET => source_files
  71. # Finally, add the static libraries to our RELEASE build dependency list
  72. static_libs = @ceedling[DEPENDENCIES_SYM].get_static_libraries_for_dependency(deplib)
  73. task RELEASE_SYM => static_libs
  74. # Add the dynamic libraries to our RELEASE task dependency list so that they will be copied automatically
  75. dynamic_libs = @ceedling[DEPENDENCIES_SYM].get_dynamic_libraries_for_dependency(deplib)
  76. task RELEASE_SYM => dynamic_libs
  77. # Add the include dirs / files to our list of dependencies for release
  78. headers = @ceedling[DEPENDENCIES_SYM].get_include_directories_for_dependency(deplib)
  79. task RELEASE_SYM => headers
  80. # Paths to Libraries need to be Added to the Lib Path List
  81. all_libs = static_libs + dynamic_libs
  82. PATHS_LIBRARIES ||= []
  83. all_libs.each {|lib| PATHS_LIBRARIES << File.dirname(lib) }
  84. PATHS_LIBRARIES.uniq!
  85. PATHS_LIBRARIES.reject!{|s| s.empty?}
  86. # Libraries Need to be Added to the Library List
  87. LIBRARIES_SYSTEM ||= []
  88. all_libs.each {|lib| LIBRARIES_SYSTEM << File.basename(lib,'.*').sub(/^lib/,'') }
  89. LIBRARIES_SYSTEM.uniq!
  90. LIBRARIES_SYSTEM.reject!{|s| s.empty?}
  91. end
  92. # Add any artifact:include or :source folders to our release & test includes paths so linking and mocking work.
  93. @ceedling[DEPENDENCIES_SYM].add_headers_and_sources()
  94. # Add tasks for building or cleaning ALL depencies
  95. namespace DEPENDENCIES_SYM do
  96. desc "Deploy missing dependencies."
  97. task :deploy => DEPENDENCIES_LIBRARIES.map{|deplib| "#{DEPENDENCIES_SYM}:deploy:#{@ceedling[DEPENDENCIES_SYM].get_name(deplib)}"}
  98. desc "Build any missing dependencies."
  99. task :make => DEPENDENCIES_LIBRARIES.map{|deplib| "#{DEPENDENCIES_SYM}:make:#{@ceedling[DEPENDENCIES_SYM].get_name(deplib)}"}
  100. desc "Clean all dependencies."
  101. task :clean => DEPENDENCIES_LIBRARIES.map{|deplib| "#{DEPENDENCIES_SYM}:clean:#{@ceedling[DEPENDENCIES_SYM].get_name(deplib)}"}
  102. desc "Fetch all dependencies."
  103. task :fetch => DEPENDENCIES_LIBRARIES.map{|deplib| "#{DEPENDENCIES_SYM}:fetch:#{@ceedling[DEPENDENCIES_SYM].get_name(deplib)}"}
  104. end
  105. namespace :files do
  106. desc "List all collected dependency libraries."
  107. task :dependencies do
  108. puts "dependency files:"
  109. deps = []
  110. DEPENDENCIES_LIBRARIES.each do |deplib|
  111. deps << @ceedling[DEPENDENCIES_SYM].get_static_libraries_for_dependency(deplib)
  112. deps << @ceedling[DEPENDENCIES_SYM].get_dynamic_libraries_for_dependency(deplib)
  113. end
  114. deps.flatten!
  115. deps.sort.each {|dep| puts " - #{dep}"}
  116. puts "file count: #{deps.size}"
  117. end
  118. end
  119. # Make sure that we build dependencies before attempting to tackle any of the unit tests
  120. Rake::Task[:test_deps].enhance ['dependencies:make']