class RBT::SymlinkHeaders
Constants
- DELETE_TARGET_HEADER_FILE_IF_IT_EXISTS
#¶ ↑
DELETE_TARGET_HEADER_FILE_IF_IT_EXISTS
¶ ↑The following constant will remove the .h file if it exists in the /usr/include/ hierarchy. Suffice to say that this may be dangerous, so you should really know what you are doing.
#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- USR_INCLUDE_HIERARCHY
#¶ ↑
USR_INCLUDE_HIERARCHY
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( program_name = ARGV, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 52 def initialize( program_name = ARGV, run_already = true ) reset set_program_name(program_name) if block_given? yielded = yield case yielded when :do_not_notify_if_there_were_no_header_files @notify_the_user_if_there_were_no_header_files = false when :notify_the_user_if_no_header_files_were_found @notify_the_user_if_there_were_no_header_files = true end end run if run_already end
Public Instance Methods
consider_notifying_the_user_that_no_header_files_were_found()
click to toggle source
#¶ ↑
consider_notifying_the_user_that_no_header_files_were_found
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 172 def consider_notifying_the_user_that_no_header_files_were_found if @notify_the_user_if_there_were_no_header_files opnn; e "No .h files were found in the target "\ "directory `#{sdir(@target_directory)}`." end end
do_symlink_this_target(i)
click to toggle source
#¶ ↑
do_symlink_this_target
¶ ↑
Use this method to symlink into the /usr/include/ hierarchy.
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 184 def do_symlink_this_target(i) # ======================================================================= # # The variable new_target points to the /usr/include/ hierarchy. # ======================================================================= # new_target = USR_INCLUDE_HIERARCHY+File.basename(i) opnn; e 'Now symlinking `'+sfile(i)+'` into `'+sfile(new_target)+'`.' if @delete_target_header_file_if_it_exists if File.exist? new_target # =================================================================== # # Next, if it is a file or symlink, we will delete it. If it is a # directory, then we will symlink into that directory. # =================================================================== # if File.directory? new_target symlink_what_into_this_directory(i, new_target) else remove(new_target) end end end symlink(i, new_target, :be_quiet) end
obtain_all_header_files()
click to toggle source
#¶ ↑
obtain_all_header_files
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 135 def obtain_all_header_files target = programs_dir?+program_name?+'/Current/' include_target = "#{target}include/" set_target_directory(include_target) target_for_header_files = include_target+'**/**.h' _found_headers = Dir[target_for_header_files] # <- This variable is currently not in use. # ======================================================================= # # The next variable is probably the best, as in, the most useful # target. We only look for one base heirarchy, not for any files # within that directory. Is not very sophisticated, but the simplest # and best variant, in my opinion. # ======================================================================= # all_targets_in_the_base_include_directory = Dir[include_target+'*'] symlink_these_targets_into_the_usr_include_hierarchy( all_targets_in_the_base_include_directory ) end
program_name?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::Base#reset
# File lib/rbt/utility_scripts/symlink_headers.rb, line 73 def reset super() @namespace = NAMESPACE @delete_target_header_file_if_it_exists = DELETE_TARGET_HEADER_FILE_IF_IT_EXISTS @target_directory = nil # ======================================================================= # # We may either notify the user that we did not find anything, if there # were no header files, or we may not. By default, the variable that # controls this behaviour is set to false, in order to lessen the # spam/verbosity of RBT. # However had, RBT::Compile will specifically set this variable to # true, since it appears to be more helpful if this is done to # the end user. # ======================================================================= # @notify_the_user_if_there_were_no_header_files = false end
run()
click to toggle source
set_program_name( i = Dir.pwd )
click to toggle source
#¶ ↑
set_program_name
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 93 def set_program_name( i = Dir.pwd ) i = i.first if i.is_a? Array i = Dir.pwd if i.nil? i = i.to_s.dup # ======================================================================= # # Next, if we have at the least one '/' character, we will try to infer # what the user wants to do. Ideally the user provides us with a # specific instruction but this will not always be the case so. In # these cases, we will have to infer something. # ======================================================================= # if i.include? '/' if i.include?(programs_dir?) and (i =~ /\d+/) # Has at the least one number. i = i.split('/').reject {|line| line.empty? } # This is assumed to be a String such as '/Programs/Glib/Current/'. i = i[1] else i = File.basename(i) end end i.capitalize! # Conform to my custom, semi-GoboLinux hierarchy. @program_name = i end
set_target_directory(i = nil)
click to toggle source
symlink_these_targets_into_the_usr_include_hierarchy(i)
click to toggle source
#¶ ↑
symlink_these_targets_into_the_usr_include_hierarchy
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 156 def symlink_these_targets_into_the_usr_include_hierarchy(i) if i.is_a? Array if i.empty? consider_notifying_the_user_that_no_header_files_were_found end i.each {|entry| symlink_these_targets_into_the_usr_include_hierarchy(entry) } else do_symlink_this_target(i) end end
symlink_what_into_this_directory(what, this_directory)
click to toggle source
#¶ ↑
symlink_what_into_this_directory
¶ ↑
This will symlink .h files into the target directory.
#¶ ↑
# File lib/rbt/utility_scripts/symlink_headers.rb, line 211 def symlink_what_into_this_directory(what, this_directory) if File.directory? this_directory this_directory << '/' unless this_directory.end_with? '/' end if File.directory? what and File.directory? this_directory all_header_files_in_the_main_directory = Dir[what+'/*.h'] # ===================================================================== # # base_dir = (File.dirname(this_directory)+'/').squeeze('/') # if File.exist?(base_dir) and # File.directory?(base_dir) and # !File.symlink?(base_dir) # this_directory = base_dir # end # ===================================================================== # all_header_files_in_the_main_directory.each {|this_header_file| # =================================================================== # # Still honour the instance variable whether to delete the target # file. # =================================================================== # target_file = rds( this_directory+'/'+File.basename(this_header_file) ) # Unfortunately, something doesn't quite work here, so I disabled # this on 30 Aug 2017 again. # if @delete_target_header_file_if_it_exists and # File.exist?(target_file) # delete_file(target_file) # end symlink(this_header_file, target_file) } end end