Class: RakeOE::App
- Inherits:
-
BinaryBase
- Object
- BinaryBase
- RakeOE::App
- Defined in:
- lib/rakeoe/app.rb
Overview
Finds all source codes in specified directory and encapsulates App projects
Instance Attribute Summary collapse
-
#binary ⇒ Object
readonly
Returns the value of attribute binary.
Attributes inherited from BinaryBase
#bin_dir, #build_dir, #deps, #inc_dirs, #name, #obj_dirs, #objs, #prj_file, #settings, #src_dir, #src_dirs, #tc, #test_binary, #test_deps, #test_dir, #test_dirs, #test_objs
Instance Method Summary collapse
-
#create ⇒ Object
create all rules, tasks and dependencies for the app.
- #create_app_lib_rules(binary_targets, libs) ⇒ Object
- #create_test_rules(binary_targets, linked_libs) ⇒ Object
-
#initialize(name, settings, tool) ⇒ App
constructor
The following parameters are expected in given hash params:.
Methods inherited from BinaryBase
#assemble_moc_file_list, #check_params, #create_build_rules, #dep_to_source, #disable_build, #each_local_lib, #fgrep, #find_files_relative, #handle_prj_type, #handle_qt, #has_tests?, #lib_incs, #load_deps, #obj_to_dep, #obj_to_source, #override_toolchain_vars, #paths_of_libs, #paths_of_local_libs, #platform_flags_fixup, #project_can_build?, #read_prj_settings, #search_files, #search_libs, #source_to_dep, #source_to_obj, #src_directories, #stub_to_src
Constructor Details
#initialize(name, settings, tool) ⇒ App
The following parameters are expected in given hash params:
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rakeoe/app.rb', line 20 def initialize(name, settings, tool) super(:name => name, :settings => settings, :bin_dir => tool.settings['APP_OUT'], :toolchain => tool) # We need to divide our app into an app lib and the app main object file # for testing. # # This is the convention: 'name.o' is supposed to contain the main() function. # All other object files are linked into a static library 'libname-app.a'. # Finally both are linked together with all dependent external libraries # to the application binary. # # In case of tests, the test objects are linked against 'libname-app.a' # and all dependent external libraries. # @app_main_obj = objs.select{|obj| File.basename(obj) == "#{name}.o"} @app_main_dep = @app_main_obj.map {|obj| obj.ext('.d')} @app_lib_objs = objs - @app_main_obj @app_lib_deps = @app_lib_objs.map {|obj| obj.ext('.d')} @prj_libs = search_libs(settings) end |
Instance Attribute Details
#binary ⇒ Object (readonly)
Returns the value of attribute binary.
11 12 13 |
# File 'lib/rakeoe/app.rb', line 11 def binary @binary end |
Instance Method Details
#create ⇒ Object
create all rules, tasks and dependencies for the app
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 |
# File 'lib/rakeoe/app.rb', line 47 def create unless project_can_build? disable_build return end # create build directory directory build_dir binary_targets = paths_of_local_libs() + @app_main_dep + @app_main_obj prj_libs = search_libs(settings) linked_libs = prj_libs[:all] # This is only necessary if we have more than a single app main file if @app_lib_objs.any? create_app_lib_rules(binary_targets, linked_libs) end file binary => binary_targets do tc.app(:libs => linked_libs, :app => binary, :objects => @app_main_obj, :settings => @settings, :includes => src_dirs) end if test_objs.any? create_test_rules(binary_targets, linked_libs) end # link dependent library to lib target (e.g. libXXX.a => lib:XXX) # this makes a connection from the dependency in variable libs above to the appropriate rule as defined # inside the lib class. If one would know the absolute path to the library, one could alternatively draw # a dependency to the lib binary instead of the name, then these two rules wouldn't be necessary rule '.a' => [ proc {|tn| 'lib:' + File.basename(tn.name).gsub('lib', '').gsub('.a','') } ] rule '.so' => [ proc {|tn| 'lib:' + File.basename(tn.name).gsub('lib', '').gsub('.so','') } ] # create standard rules create_build_rules desc "Create #{name}" task name => binary_targets + [binary] #desc "Clean #{name}" task name+'_clean' do tc.rm (objs + deps + [binary]).join(' ') end # add this application as dependency for the app:all task task :all => name # create runner task "#{name}_run" => name do tc.run binary end # add files for the clean rule CLEAN.include('*.o', build_dir) CLEAN.include(@app_lib, build_dir) CLEAN.include(binary, build_dir) CLOBBER.include('*.d', build_dir) end |
#create_app_lib_rules(binary_targets, libs) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/rakeoe/app.rb', line 111 def create_app_lib_rules(binary_targets, libs) app_lib_targets = @app_lib_deps + @app_lib_objs + [@settings['PRJ_FILE']] file @app_lib => app_lib_targets do tc.lib(:objects => @app_lib_objs, :lib => @app_lib, :libs => libs, :settings => @settings) end # add this to the dependent targets of app binary binary_targets << @app_lib # we treat the app lib as an object file. This makes linking easier. @app_main_obj << @app_lib end |
#create_test_rules(binary_targets, linked_libs) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/rakeoe/app.rb', line 128 def create_test_rules(binary_targets, linked_libs) namespace 'test' do desc "Test #{name}" task "#{name}" => test_binary do tc.run(test_binary) end # Build the library and execute tests task "#{name}_junit" => test_binary do tc.run_junit_test(test_binary) end # 'hidden' task just for building the test task "#{name}_build" => test_binary test_binary_dependencies = [@test_fw.binary_path] + binary_targets + test_deps + test_objs file test_binary => test_binary_dependencies do tc.test(:objects => test_objs + [@app_lib], :test => test_binary, :libs => linked_libs, :framework => @test_fw.name, :settings => @settings, :includes => test_dirs) end CLEAN.include(test_binary, build_dir) task :all => "#{name}" task :junit => "#{name}_junit" task :build => "#{name}_build" end end |