class Autoproj::Environment
Attributes
root_dir[R]
Public Instance Methods
each_env_filename(*subdir) { |shell, env_filename(shell, *subdir)| ... }
click to toggle source
# File lib/autoproj/environment.rb, line 31 def each_env_filename(*subdir) (["sh"] + Autoproj.workspace.config.user_shells).to_set.each do |shell| yield shell, env_filename(shell, *subdir) end end
env_filename(shell, *subdir)
click to toggle source
# File lib/autoproj/environment.rb, line 21 def env_filename(shell, *subdir) env_filename = if shell == "sh" ENV_FILENAME else (Pathname(ENV_FILENAME).sub_ext "").to_s.concat(".#{shell}") end File.join(root_dir, *subdir, env_filename) end
export_env_sh(subdir = nil, options = Hash.new)
click to toggle source
Calls superclass method
# File lib/autoproj/environment.rb, line 37 def export_env_sh(subdir = nil, options = Hash.new) if subdir.kind_of?(Hash) options = subdir subdir = nil end options = validate_options options, shell_helpers: true shell_dir = File.expand_path(File.join("..", "..", "shell"), File.dirname(__FILE__)) completion_dir = File.join(shell_dir, "completion") env_updated = false each_env_filename(*[subdir].compact) do |shell, filename| helper = File.join(shell_dir, "autoproj_#{shell}") if options[:shell_helpers] source_after(helper, shell: shell) if File.file?(helper) %w[alocate alog amake aup autoproj].each do |tool| completion_file = File.join(completion_dir, "#{tool}_#{shell}") if File.file?(completion_file) source_after(completion_file, shell: shell) end end end existing_content = begin File.read(filename) rescue SystemCallError end StringIO.open(new_content = String.new, "w") do |io| if inherit? io.write <<-EOF if test -n "$AUTOPROJ_CURRENT_ROOT" && test "$AUTOPROJ_CURRENT_ROOT" != "#{root_dir}"; then echo "the env.sh from $AUTOPROJ_CURRENT_ROOT is already loaded. Start a new shell before sourcing this one" return fi EOF end super(io, shell: shell) end if new_content != existing_content Ops.atomic_write(filename) { |io| io.write new_content } env_updated = true end end env_updated end
filter_original_env(name, env)
click to toggle source
# File lib/autoproj/environment.rb, line 17 def filter_original_env(name, env) Autoproj.filter_out_paths_in_workspace(env) end
prepare(root_dir)
click to toggle source
Calls superclass method
# File lib/autoproj/environment.rb, line 11 def prepare(root_dir) @root_dir = root_dir set "AUTOPROJ_CURRENT_ROOT", root_dir super() end