Sha256: c98eba0032569b93dc36e774010e72e9a20172258260c979e5eed876a1289916
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
module Autobuild class << self # Configure the programs used by different packages attr_reader :programs # A cache of entries in programs to their resolved full path # # @return [{String=>[String,String,String]}] the triplet (full path, # tool name, value of ENV['PATH']). The last two values are used to # invalidate the cache when needed # # @see tool_in_path attr_reader :programs_in_path # Get a given program, using its name as default value. For # instance # tool('automake') # will return 'automake' unless the autobuild script defined # another automake program in Autobuild.programs by doing # Autobuild.programs['automake'] = 'automake1.9' def tool(name) programs[name.to_sym] || programs[name.to_s] || name.to_s end # Find a file in a given path-like variable def find_in_path(file, envvar = 'PATH') env.find_in_path(file, envvar) end # Resolves the absolute path to a given tool def tool_in_path(name, env: self.env) path, path_name, path_env = programs_in_path[name] current = tool(name) env_PATH = env.resolved_env['PATH'] if (path_env != env_PATH) || (path_name != current) # Delete the current entry given that it is invalid programs_in_path.delete(name) if current[0, 1] == "/" # This is already a full path path = current else path = env.find_executable_in_path(current) end if !path raise ArgumentError, "tool #{name}, set to #{current}, can not be found in PATH=#{env_PATH}" end programs_in_path[name] = [path, current, env_PATH] end return path end end @programs = Hash.new @programs_in_path = Hash.new end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
autobuild-1.12.3 | lib/autobuild/tools.rb |