Module: Origen::Generator::Comparator
Instance Method Summary collapse
-
#check_for_changes(new, old, options = {}) ⇒ Object
Will check if the supplied file has changed from the last time it was generated Returns true if it is a new file, or if a change has been detected.
- #relative_path_to(file) ⇒ Object
- #stats ⇒ Object
Instance Method Details
#check_for_changes(new, old, options = {}) ⇒ Object
Will check if the supplied file has changed from the last time it was generated Returns true if it is a new file, or if a change has been detected
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/origen/generator/comparator.rb', line 6 def check_for_changes(new, old, = {}) = { comment_char: Origen.app.tester ? Origen.app.tester.comment_char : nil, quiet: false, compile_job: false, suspend_string: 'STOPDIFF', resume_string: 'STARTDIFF' }.merge() if File.exist?(old) if Utility::Diff.new(file_a: new, file_b: old, ignore_blank_lines: [:ignore_blank_lines], comment_char: [:comment_char], suspend_string: [:suspend_string], resume_string: [:resume_string]).diffs? unless [:quiet] cmd = "*** CHANGE DETECTED *** To update the reference: #{Origen.config.copy_command} #{relative_path_to(new)} #{relative_path_to(old)}" cmd += ' /Y' if Origen.running_on_windows? Origen.log.info cmd Origen.log.info "#{Origen.config.diff_command} #{relative_path_to(old)} #{relative_path_to(new)} &" Origen.log.info '**********************************************************************' end if [:compile_job] stats.changed_files += 1 else stats.changed_patterns += 1 end true end else unless [:quiet] Origen.log.info "*** NEW FILE *** To save it: #{Origen.config.copy_command} #{relative_path_to(new)} #{relative_path_to(old)}" Origen.log.info '**********************************************************************' end if [:compile_job] stats.new_files += 1 else stats.new_patterns += 1 end true end end |
#relative_path_to(file) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/origen/generator/comparator.rb', line 53 def relative_path_to(file) file = Pathname.new(file) unless file.is_a?(Pathname) p = file..relative_path_from(Pathname.pwd).to_s p.gsub!('/', '\\') if Origen.running_on_windows? p end |