ENV.with_build_environment
This commit is contained in:
parent
3d92f1c683
commit
d06824c357
@ -438,6 +438,14 @@ class << ENV
|
|||||||
self['PATH'] = paths.unshift(*self['PATH'].split(":")).uniq.join(":")
|
self['PATH'] = paths.unshift(*self['PATH'].split(":")).uniq.join(":")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def with_build_environment
|
||||||
|
old_env = to_hash
|
||||||
|
setup_build_environment
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
replace(old_env)
|
||||||
|
end
|
||||||
|
|
||||||
def fortran
|
def fortran
|
||||||
fc_flag_vars = %w{FCFLAGS FFLAGS}
|
fc_flag_vars = %w{FCFLAGS FFLAGS}
|
||||||
|
|
||||||
|
@ -125,10 +125,10 @@ class MPIDependency < Requirement
|
|||||||
|
|
||||||
def satisfied?
|
def satisfied?
|
||||||
# we have to assure the ENV is (almost) as during the build
|
# we have to assure the ENV is (almost) as during the build
|
||||||
orig_PATH = ENV['PATH']
|
|
||||||
require 'superenv'
|
require 'superenv'
|
||||||
ENV.setup_build_environment
|
ENV.with_build_environment do
|
||||||
ENV.userpaths!
|
ENV.userpaths!
|
||||||
|
|
||||||
@lang_list.each do |lang|
|
@lang_list.each do |lang|
|
||||||
case lang
|
case lang
|
||||||
when :cc, :cxx, :f90, :f77
|
when :cc, :cxx, :f90, :f77
|
||||||
@ -138,10 +138,7 @@ class MPIDependency < Requirement
|
|||||||
@unknown_langs << lang.to_s
|
@unknown_langs << lang.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
# Restore the original paths
|
|
||||||
ENV['PATH'] = orig_PATH
|
|
||||||
|
|
||||||
@unknown_langs.empty? and @non_functional.empty?
|
@unknown_langs.empty? and @non_functional.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,4 +26,13 @@ class EnvironmentTests < Test::Unit::TestCase
|
|||||||
assert_nil ENV['LD']
|
assert_nil ENV['LD']
|
||||||
assert_equal ENV['OBJC'], ENV['CC']
|
assert_equal ENV['OBJC'], ENV['CC']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_with_build_environment
|
||||||
|
before = ENV.to_hash
|
||||||
|
ENV.with_build_environment do
|
||||||
|
ENV['foo'] = 'bar'
|
||||||
|
end
|
||||||
|
assert_nil ENV['foo']
|
||||||
|
assert_equal before, ENV.to_hash
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user