Class: Autoproj::Environment
- Inherits:
-
Autobuild::Environment
- Object
- Autobuild::Environment
- Autoproj::Environment
- Defined in:
- lib/autoproj/environment.rb
Instance Attribute Summary collapse
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
Instance Method Summary collapse
- #each_env_filename(*subdir) ⇒ Object
- #env_filename(shell, *subdir) ⇒ Object
- #export_env_sh(subdir = nil, options = Hash.new) ⇒ Object
- #filter_original_env(name, env) ⇒ Object
- #prepare(root_dir) ⇒ Object
Instance Attribute Details
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
9 10 11 |
# File 'lib/autoproj/environment.rb', line 9 def root_dir @root_dir end |
Instance Method Details
#each_env_filename(*subdir) ⇒ Object
31 32 33 34 35 |
# 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) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# 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) ⇒ Object
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 |
# File 'lib/autoproj/environment.rb', line 37 def export_env_sh(subdir = nil, = Hash.new) if subdir.kind_of?(Hash) = subdir subdir = nil end = , shell_helpers: true shell_dir = File.(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 [: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) ⇒ Object
17 18 19 |
# File 'lib/autoproj/environment.rb', line 17 def filter_original_env(name, env) Autoproj.filter_out_paths_in_workspace(env) end |
#prepare(root_dir) ⇒ Object
11 12 13 14 15 |
# File 'lib/autoproj/environment.rb', line 11 def prepare(root_dir) @root_dir = root_dir set "AUTOPROJ_CURRENT_ROOT", root_dir super() end |