Class: RakeOE::BinaryBase
- Inherits:
-
Object
- Object
- RakeOE::BinaryBase
- Includes:
- Rake::DSL
- Defined in:
- lib/rakeoe/binary_base.rb
Overview
Base class for all projects that assemble binary data
Instance Attribute Summary collapse
-
#bin_dir ⇒ Object
Returns the value of attribute bin_dir.
-
#binary ⇒ Object
Returns the value of attribute binary.
-
#build_dir ⇒ Object
readonly
Returns the value of attribute build_dir.
-
#deps ⇒ Object
Returns the value of attribute deps.
-
#inc_dirs ⇒ Object
readonly
Returns the value of attribute inc_dirs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#obj_dirs ⇒ Object
readonly
Returns the value of attribute obj_dirs.
-
#objs ⇒ Object
Returns the value of attribute objs.
-
#prj_file ⇒ Object
Returns the value of attribute prj_file.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#src_dir ⇒ Object
readonly
Returns the value of attribute src_dir.
-
#src_dirs ⇒ Object
readonly
Returns the value of attribute src_dirs.
-
#tc ⇒ Object
Returns the value of attribute tc.
-
#test_binary ⇒ Object
Returns the value of attribute test_binary.
-
#test_deps ⇒ Object
Returns the value of attribute test_deps.
-
#test_dir ⇒ Object
Returns the value of attribute test_dir.
-
#test_dirs ⇒ Object
readonly
Returns the value of attribute test_dirs.
-
#test_objs ⇒ Object
Returns the value of attribute test_objs.
Instance Method Summary collapse
-
#assemble_moc_file_list(include_files) ⇒ Array
Assemble list of to be generated moc files.
-
#check_params(params) ⇒ Object
Check params given to #initialize.
-
#create_build_rules ⇒ Object
Create build rules for generating an object.
-
#dep_to_source(dep, source_dir, dep_dir) ⇒ String
Transforms a dependency file name into its corresponding source file name by replacing file name extension and object directory with dependency directory.
-
#disable_build ⇒ Object
Disable a build.
-
#each_local_lib(&block) ⇒ Object
Iterate over each local library and execute given block.
-
#fgrep(file, string) ⇒ boolean
Greps for a string in a file.
-
#find_files_relative(directory, files) ⇒ Array
Search list of files relative to given directory.
-
#handle_prj_type ⇒ Object
Settings according to project type.
-
#handle_qt ⇒ Object
Qt special handling.
-
#has_tests? ⇒ Boolean
Returns if any test sources found.
-
#initialize(params) ⇒ BinaryBase
constructor
The following parameters are expected in given hash params:.
-
#lib_incs(libs = []) ⇒ Array
Returns list of include directories for name of libraries in parameter libs.
-
#load_deps(deps) ⇒ Object
Loads dependency files if already generated.
-
#obj_to_dep(src, dep_dir, obj_dir) ⇒ String
Transforms an object file into its corresponding dependency file name by replacing file name extension and object directory with dependency directory.
-
#obj_to_source(obj, source_dir, obj_dir) ⇒ String
Transforms an object file name to its source file name by replacing build directory base with the source directory base and then iterating list of known sources to match.
-
#override_toolchain_vars ⇒ Object
Depending on the read settings we have to change various values like CXXFLAGS, LDFLAGS, etc.
-
#paths_of_libs(some_libs) ⇒ Object
Returns absolute paths to given libraries, if they are local libraries of the current project.
-
#paths_of_local_libs ⇒ Object
Returns absolute paths to dependend local libraries, i.e.
-
#platform_flags_fixup(libs) ⇒ Object
Change ADD_CFLAGS, ADD_CXXFLAGS, ADD_LDFLAGS according to settings in platform file.
-
#project_can_build? ⇒ Boolean
Checks if projects build prerequisites are met.
-
#read_prj_settings(file) ⇒ KeyValueReader
Read project file if it exists.
-
#search_files(directories, extensions) ⇒ Array
Search files recursively in directory with given extensions.
-
#search_libs(settings) ⇒ Hash
Search dependent libraries as specified in ADD_LIBS setting of prj.rake file.
-
#source_to_dep(src, source_dir, dep_dir) ⇒ String
Transforms a source file name in to its dependency file name by replacing file name extension and the source directory base with the build directory base.
-
#source_to_obj(src, source_dir, obj_dir) ⇒ String
Transforms a source file name in to its object file name by replacing file name extension and the source directory base with the build directory base.
-
#src_directories(main_dir, sub_dirs, params = {}) ⇒ Array
Returns array of source code directories assembled via given parameters.
-
#stub_to_src(stub) ⇒ String
Match the file stub (i.e. the filename with absolute path without extension) to one of all known source (including test source) files.
Constructor Details
#initialize(params) ⇒ BinaryBase
The following parameters are expected in given hash params:
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 |
# File 'lib/rakeoe/binary_base.rb', line 26 def initialize(params) check_params(params) @@all_libs ||= (PrjFileCache.project_names('LIB') + PrjFileCache.project_names('SOLIB')).uniq @@all_libs_and_deps ||= PrjFileCache.search_recursive(:names => @@all_libs, :attribute => 'ADD_LIBS') @name = params[:name] @settings = params[:settings] @src_dir = @settings['PRJ_HOME'] @bin_dir = params[:bin_dir] @tc = params[:toolchain] # derived parameters @build_dir = "#{@bin_dir}/.#{@name}" @binary = '.delete_me' @src_dirs = src_directories(src_dir, @settings['ADD_SOURCE_DIRS'].split, :subdir_only => false) @test_dirs = src_directories(src_dir, @settings['TEST_SOURCE_DIRS'].split, :subdir_only => true) @inc_dirs = src_directories(src_dir, @settings['ADD_INC_DIRS'].split << 'include/', :subdir_only => true) @inc_dirs += @src_dirs if @settings['EXPORTED_INC_DIRS'] @inc_dirs += src_directories(src_dir, @settings['EXPORTED_INC_DIRS'].split, :subdir_only => true) end @inc_dirs += lib_incs(@settings['ADD_LIBS'].split) @inc_dirs.uniq! # list of all object file directories to be created @obj_dirs = (@src_dirs+@test_dirs).map {|dir| dir.gsub(@src_dir, @build_dir)} @obj_dirs.each do |dir| directory dir end # fetch list of all sources with all supported source file extensions ignored_srcs = find_files_relative(@src_dir, @settings['IGNORED_SOURCES'].split) @srcs = (search_files(src_dirs, @tc.source_extensions) - ignored_srcs).uniq @test_srcs = search_files(test_dirs, @tc.source_extensions).uniq # special handling for Qt files if '1' == @settings['USE_QT'] mocs = assemble_moc_file_list(search_files(src_dirs, [@tc.moc_header_extension])) mocs.each do |moc| @srcs << moc CLEAN.include(moc) end @srcs.uniq! end if (@settings['TEST_FRAMEWORK'].nil? or @settings['TEST_FRAMEWORK'].empty?) @test_fw = @tc.default_test_framework else @test_fw = @tc.test_framework(@settings['TEST_FRAMEWORK']) end @objs = @srcs.map {|file| source_to_obj(file, @src_dir, @build_dir)} @deps = @objs.map {|obj| obj.ext('.d')} if has_tests? @test_objs = @test_srcs.map {|file| source_to_obj(file, @src_dir, @build_dir)} @test_deps = @test_objs.map {|obj| obj.ext('.d')} load_deps(@test_deps) @test_inc_dirs = @settings['TEST_SOURCE_DIRS'].empty? ? '' : @test_fw.include.join(' ') else @test_objs = [] @test_deps = [] @test_inc_dirs = '' end # load dependency files if already generated load_deps(@deps) # all objs are dependent on project file and platform file (@objs+@test_objs).each do |obj| file obj => [@settings['PRJ_FILE'], @tc.config.platform] end @test_binary = "#{bin_dir}/#{name}-test" handle_prj_type handle_qt if '1' == @settings['USE_QT'] # todo check all directories for existence ? end |
Instance Attribute Details
#bin_dir ⇒ Object
Returns the value of attribute bin_dir.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def bin_dir @bin_dir end |
#binary ⇒ Object
Returns the value of attribute binary.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def binary @binary end |
#build_dir ⇒ Object (readonly)
Returns the value of attribute build_dir.
12 13 14 |
# File 'lib/rakeoe/binary_base.rb', line 12 def build_dir @build_dir end |
#deps ⇒ Object
Returns the value of attribute deps.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def deps @deps end |
#inc_dirs ⇒ Object (readonly)
Returns the value of attribute inc_dirs.
12 13 14 |
# File 'lib/rakeoe/binary_base.rb', line 12 def inc_dirs @inc_dirs end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def name @name end |
#obj_dirs ⇒ Object (readonly)
Returns the value of attribute obj_dirs.
12 13 14 |
# File 'lib/rakeoe/binary_base.rb', line 12 def obj_dirs @obj_dirs end |
#objs ⇒ Object
Returns the value of attribute objs.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def objs @objs end |
#prj_file ⇒ Object
Returns the value of attribute prj_file.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def prj_file @prj_file end |
#settings ⇒ Object
Returns the value of attribute settings.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def settings @settings end |
#src_dir ⇒ Object (readonly)
Returns the value of attribute src_dir.
12 13 14 |
# File 'lib/rakeoe/binary_base.rb', line 12 def src_dir @src_dir end |
#src_dirs ⇒ Object (readonly)
Returns the value of attribute src_dirs.
12 13 14 |
# File 'lib/rakeoe/binary_base.rb', line 12 def src_dirs @src_dirs end |
#tc ⇒ Object
Returns the value of attribute tc.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def tc @tc end |
#test_binary ⇒ Object
Returns the value of attribute test_binary.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def test_binary @test_binary end |
#test_deps ⇒ Object
Returns the value of attribute test_deps.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def test_deps @test_deps end |
#test_dir ⇒ Object
Returns the value of attribute test_dir.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def test_dir @test_dir end |
#test_dirs ⇒ Object (readonly)
Returns the value of attribute test_dirs.
12 13 14 |
# File 'lib/rakeoe/binary_base.rb', line 12 def test_dirs @test_dirs end |
#test_objs ⇒ Object
Returns the value of attribute test_objs.
14 15 16 |
# File 'lib/rakeoe/binary_base.rb', line 14 def test_objs @test_objs end |
Instance Method Details
#assemble_moc_file_list(include_files) ⇒ Array
Assemble list of to be generated moc files
228 229 230 231 232 |
# File 'lib/rakeoe/binary_base.rb', line 228 def assemble_moc_file_list(include_files) include_files.map do |file| "#{File.dirname(file)}/moc_#{File.basename(file).ext(@tc.moc_source)}" if fgrep(file,'Q_OBJECT') end.compact end |
#check_params(params) ⇒ Object
Check params given to #initialize
114 115 116 117 118 119 |
# File 'lib/rakeoe/binary_base.rb', line 114 def check_params(params) raise 'No project name given' unless params[:name] raise 'No settings given' unless params[:settings] raise 'No build directory given' unless params[:bin_dir] raise 'No toolchain given' unless params[:toolchain] end |
#create_build_rules ⇒ Object
Create build rules for generating an object. Dependency to corresponding source file is made via proc object
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/rakeoe/binary_base.rb', line 378 def create_build_rules platform_flags_fixup(search_libs(@settings)) incs = inc_dirs # map object to source file and make it dependent on creation of all object directories rule /#{build_dir}\/.*\.o/ => [ proc {|tn| obj_to_source(tn, src_dir, build_dir)}] + obj_dirs do |t| if t.name =~ /\/tests\// # test framework additions incs << @test_inc_dirs unless incs.include?(@test_inc_dirs) @settings['ADD_CXXFLAGS'] += @test_fw.cflags @settings['ADD_CFLAGS'] += @test_fw.cflags end tc.obj(:source => t.source, :object => t.name, :settings => @settings, :includes => incs.uniq) end # map dependency to source file and make it dependent on creation of all object directories rule /#{build_dir}\/.*\.d/ => [ proc {|tn| dep_to_source(tn, src_dir, build_dir)}] + obj_dirs do |t| # don't generate dependencies for assembler files XXX DS: use tc.file_extensions[:as_sources] if (t.source.end_with?('.S') || t.source.end_with?('.s')) tc.touch(t.name) next end if t.name =~ /\/tests\// # test framework additions incs << @test_inc_dirs unless incs.include?(@test_inc_dirs) @settings['ADD_CXXFLAGS'] += @test_fw.cflags @settings['ADD_CFLAGS'] += @test_fw.cflags end tc.dep(:source => t.source, :dep => t.name, :settings => @settings, :includes => incs.uniq) end # make moc source file dependent on corresponding header file, XXX DS: only if project uses QT rule /#{src_dir}\/.*moc_.*#{Regexp.escape(tc.moc_source)}$/ => [ proc {|tn| tn.gsub(/moc_/, '').ext(tc.moc_header_extension) } ] do |t| tc.moc(:source => t.source, :moc => t.name, :settings => @settings) end end |
#dep_to_source(dep, source_dir, dep_dir) ⇒ String
Transforms a dependency file name into its corresponding source file name by replacing file name extension and object directory with dependency directory. Searches through list of source files to find it.
369 370 371 372 373 374 |
# File 'lib/rakeoe/binary_base.rb', line 369 def dep_to_source(dep, source_dir, dep_dir) stub = dep.gsub(dep_dir, source_dir).ext('') src = stub_to_src(stub) return src if src raise "No matching source for #{dep} found." end |
#disable_build ⇒ Object
Disable a build. Is called from derived class if e.g. set in prj.rake
271 272 273 274 275 276 |
# File 'lib/rakeoe/binary_base.rb', line 271 def disable_build desc '*** DISABLED ***' task @name => @binary file @binary do end end |
#each_local_lib(&block) ⇒ Object
Iterate over each local library and execute given block
494 495 496 497 498 499 |
# File 'lib/rakeoe/binary_base.rb', line 494 def each_local_lib(&block) libs = search_libs(@settings) libs[:local].each do |lib| yield(lib) end end |
#fgrep(file, string) ⇒ boolean
Greps for a string in a file
544 545 546 |
# File 'lib/rakeoe/binary_base.rb', line 544 def fgrep(file, string) open(file).grep(/#{string}/).any? end |
#find_files_relative(directory, files) ⇒ Array
Search list of files relative to given directory
213 214 215 216 217 218 219 |
# File 'lib/rakeoe/binary_base.rb', line 213 def find_files_relative(directory, files) return [] unless files.any? files.each_with_object([]) do |file, obj| path = "#{directory}/#{file}" obj << path if File.exist?(path) end end |
#handle_prj_type ⇒ Object
Settings according to project type
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/rakeoe/binary_base.rb', line 133 def handle_prj_type # TODO make these settable in defaults.rb case @settings['PRJ_TYPE'] when 'SOLIB' @binary = "#{bin_dir}/lib#{name}.so" @settings['ADD_CFLAGS'] += ' -fPIC -Wl,-export-dynamic' @settings['ADD_CXXFLAGS'] += ' -fPIC -Wl,-export-dynamic' when 'LIB' @binary = "#{bin_dir}/lib#{name}.a" when 'APP' @binary = "#{bin_dir}/#{name}" @app_lib = "#{build_dir}/lib#{name}-app.a" when 'DISABLED' puts "### WARNING: project #{name} is disabled !!" else raise "unsupported project type #{@settings['PRJ_TYPE']}" end end |
#handle_qt ⇒ Object
Qt special handling
122 123 124 125 126 127 128 129 130 |
# File 'lib/rakeoe/binary_base.rb', line 122 def handle_qt unless tc.qt.check_once puts '### WARN: QT prerequisites not complete!' end @settings['ADD_CFLAGS'] += tc.qt.cflags @settings['ADD_CXXFLAGS'] += tc.qt.cflags @settings['ADD_LDFLAGS'] += tc.qt.ldflags @settings['ADD_LIBS'] += tc.qt.libs end |
#has_tests? ⇒ Boolean
Returns if any test sources found
253 254 255 |
# File 'lib/rakeoe/binary_base.rb', line 253 def has_tests? return @test_srcs.any? end |
#lib_incs(libs = []) ⇒ Array
Returns list of include directories for name of libraries in parameter libs
180 181 182 183 184 185 186 187 |
# File 'lib/rakeoe/binary_base.rb', line 180 def lib_incs(libs=[]) includes = Array.new libs.each do |name, param| lib_includes = PrjFileCache.exported_lib_incs(name) includes += lib_includes if lib_includes.any? end includes end |
#load_deps(deps) ⇒ Object
Loads dependency files if already generated
260 261 262 263 264 265 266 |
# File 'lib/rakeoe/binary_base.rb', line 260 def load_deps(deps) deps.each do |file| if File.file?(file) Rake::MakefileLoader.new.load(file) end end end |
#obj_to_dep(src, dep_dir, obj_dir) ⇒ String
Transforms an object file into its corresponding dependency file name by replacing file name extension and object directory with dependency directory
356 357 358 |
# File 'lib/rakeoe/binary_base.rb', line 356 def obj_to_dep(src, dep_dir, obj_dir) src.sub(/\.o$/, '.d').gsub(dep_dir, obj_dir) end |
#obj_to_source(obj, source_dir, obj_dir) ⇒ String
Transforms an object file name to its source file name by replacing build directory base with the source directory base and then iterating list of known sources to match
315 316 317 318 319 320 |
# File 'lib/rakeoe/binary_base.rb', line 315 def obj_to_source(obj, source_dir, obj_dir) stub = obj.gsub(obj_dir, source_dir).ext('') src = stub_to_src(stub) return src if src raise "No matching source for #{obj} found." end |
#override_toolchain_vars ⇒ Object
Depending on the read settings we have to change various values like CXXFLAGS, LDFLAGS, etc.
248 249 |
# File 'lib/rakeoe/binary_base.rb', line 248 def override_toolchain_vars end |
#paths_of_libs(some_libs) ⇒ Object
Returns absolute paths to given libraries, if they are local libraries of the current project.
506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/rakeoe/binary_base.rb', line 506 def paths_of_libs(some_libs) local_libs = Array.new some_libs.each do |lib| if PrjFileCache.contain?('LIB', lib) local_libs << "#{tc.settings['LIB_OUT']}/lib#{lib}.a" elsif PrjFileCache.contain?('SOLIB', lib) local_libs << "#{tc.settings['LIB_OUT']}/lib#{lib}.so" end end local_libs end |
#paths_of_local_libs ⇒ Object
Returns absolute paths to dependend local libraries, i.e. libraries of the current project.
523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/rakeoe/binary_base.rb', line 523 def paths_of_local_libs local_libs = Array.new each_local_lib() do |lib| if PrjFileCache.contain?('LIB', lib) local_libs << "#{tc.settings['LIB_OUT']}/lib#{lib}.a" elsif PrjFileCache.contain?('SOLIB', lib) local_libs << "#{tc.settings['LIB_OUT']}/lib#{lib}.so" end end local_libs end |
#platform_flags_fixup(libs) ⇒ Object
Change ADD_CFLAGS, ADD_CXXFLAGS, ADD_LDFLAGS according to settings in platform file.
430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/rakeoe/binary_base.rb', line 430 def platform_flags_fixup(libs) libs[:all].each do |lib| ps = tc.platform_settings_for(lib) unless ps.empty? @settings['ADD_CFLAGS'] += " #{ps[:CFLAGS]}" if ps[:CFLAGS] @settings['ADD_CXXFLAGS'] += " #{ps[:CXXFLAGS]}" if ps[:CXXFLAGS] # remove all -lXX settings from ps[:LDFLAGS] and use rest for @settings['ADD_LDFLAGS'], # -lXX is set in Toolchain#linker_line_for @settings['ADD_LDFLAGS'] += ps[:LDFLAGS].gsub(/(\s|^)+-l\S+/, '') if ps[:LDFLAGS] end end end |
#project_can_build? ⇒ Boolean
Checks if projects build prerequisites are met.
If at least one of the following criteria are met, the method returns false:
* project variable PRJ_TYPE == "DISABLED"
* project variable IGNORED_PLATFORMS contains build platform
286 287 288 |
# File 'lib/rakeoe/binary_base.rb', line 286 def project_can_build? (settings['PRJ_TYPE'] != 'DISABLED') and (! tc.current_platform_any?(settings['IGNORED_PLATFORMS'].split)) end |
#read_prj_settings(file) ⇒ KeyValueReader
Read project file if it exists
239 240 241 242 243 244 |
# File 'lib/rakeoe/binary_base.rb', line 239 def read_prj_settings(file) unless File.file?(file) file = File.dirname(__FILE__)+'/prj.rake' end KeyValueReader.new(file) end |
#search_files(directories, extensions) ⇒ Array
Search files recursively in directory with given extensions
197 198 199 200 201 202 203 |
# File 'lib/rakeoe/binary_base.rb', line 197 def search_files(directories, extensions) extensions.each_with_object([]) do |ext, obj| directories.each do |dir| obj << FileList["#{dir}/*#{ext}"] end end.flatten.compact end |
#search_libs(settings) ⇒ Hash
Search dependent libraries as specified in ADD_LIBS setting of prj.rake file
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/rakeoe/binary_base.rb', line 455 def search_libs(settings) # get all libs specified in ADD_LIBS search_libs = settings['ADD_LIBS'].split our_lib_deps = [] search_libs.each do |lib| our_lib_deps << lib deps_of_lib = @@all_libs_and_deps[lib] if deps_of_lib our_lib_deps += deps_of_lib end end our_lib_deps.uniq! # match libs found by toolchain solibs_local = [] alibs_local = [] our_lib_deps.each do |lib| if PrjFileCache.contain?('LIB', lib) alibs_local << lib elsif PrjFileCache.contain?('SOLIB', lib) solibs_local << lib end end local_libs = (alibs_local + solibs_local) || [] # return value is a hash { :local => local_libs, :local_alibs => alibs_local, :local_solibs => solibs_local, :all => our_lib_deps } end |
#source_to_dep(src, source_dir, dep_dir) ⇒ String
Transforms a source file name in to its dependency file name by replacing file name extension and the source directory base with the build directory base
343 344 345 346 |
# File 'lib/rakeoe/binary_base.rb', line 343 def source_to_dep(src, source_dir, dep_dir) exts = '\\' + @tc.source_extensions.join('|\\') src.sub(/(#{exts})$/, '.d').gsub(source_dir, dep_dir) end |
#source_to_obj(src, source_dir, obj_dir) ⇒ String
Transforms a source file name in to its object file name by replacing file name extension and the source directory base with the build directory base
330 331 332 333 |
# File 'lib/rakeoe/binary_base.rb', line 330 def source_to_obj(src, source_dir, obj_dir) exts = '\\' + @tc.source_extensions.join('|\\') src.sub(/(#{exts})$/, '.o').gsub(source_dir, obj_dir) end |
#src_directories(main_dir, sub_dirs, params = {}) ⇒ Array
Returns array of source code directories assembled via given parameters
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/rakeoe/binary_base.rb', line 160 def src_directories(main_dir, sub_dirs, params={}) if params[:subdir_only] all_dirs=[] else all_dirs = [main_dir] end sub_dirs.each do |dir| all_dirs << "#{main_dir}/#{dir}" end all_dirs.compact end |
#stub_to_src(stub) ⇒ String
Match the file stub (i.e. the filename with absolute path without extension) to one of all known source (including test source) files
TODO optimization possible for faster lookup by using hash of source files instead of array
297 298 299 300 301 302 303 304 |
# File 'lib/rakeoe/binary_base.rb', line 297 def stub_to_src(stub) (@srcs+@test_srcs).each do |src| if src.ext('') == stub return src end end nil end |