Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
d4602b17
Commit
d4602b17
authored
10 years ago
by
Jack Nagel
Browse files
Options
Downloads
Patches
Plain Diff
Eliminate some indirection in evaluating requirement env blocks
parent
dff74d9c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/requirement.rb
+30
-17
30 additions, 17 deletions
Library/Homebrew/requirement.rb
Library/Homebrew/test/test_requirement.rb
+4
-0
4 additions, 0 deletions
Library/Homebrew/test/test_requirement.rb
with
34 additions
and
17 deletions
Library/Homebrew/requirement.rb
+
30
−
17
View file @
d4602b17
...
...
@@ -24,11 +24,8 @@ class Requirement
# Overriding #satisfied? is deprecated.
# Pass a block or boolean to the satisfy DSL method instead.
def
satisfied?
result
=
self
.
class
.
satisfy
.
yielder
do
|
proc
|
instance_eval
(
&
proc
)
end
infer_env_modification
(
result
)
result
=
self
.
class
.
satisfy
.
yielder
{
|
p
|
instance_eval
(
&
p
)
}
@satisfied_result
=
result
!!
result
end
...
...
@@ -51,13 +48,31 @@ class Requirement
# Note: #satisfied? should be called before invoking this method
# as the env modifications may depend on its side effects.
def
modify_build_environment
env
.
modify_build_environment
(
self
)
instance_eval
(
&
env_proc
)
if
env_proc
# XXX If the satisfy block returns a Pathname, then make sure that it
# remains available on the PATH. This makes requirements like
# satisfy { which("executable") }
# work, even under superenv where "executable" wouldn't normally be on the
# PATH.
# This is undocumented magic and it should be removed, but we need to add
# a way to declare path-based requirements that work with superenv first.
if
Pathname
===
@satisfied_result
parent
=
@satisfied_result
.
parent
unless
ENV
[
"PATH"
].
split
(
File
::
PATH_SEPARATOR
).
include?
(
parent
.
to_s
)
ENV
.
append_path
(
"PATH"
,
parent
)
end
end
end
def
env
self
.
class
.
env
end
def
env_proc
self
.
class
.
env_proc
end
def
eql?
(
other
)
instance_of?
(
other
.
class
)
&&
name
==
other
.
name
&&
tags
==
other
.
tags
end
...
...
@@ -85,17 +100,6 @@ class Requirement
klass
.
downcase
end
def
infer_env_modification
(
o
)
case
o
when
Pathname
self
.
class
.
env
do
unless
ENV
[
"PATH"
].
split
(
File
::
PATH_SEPARATOR
).
include?
(
o
.
parent
.
to_s
)
ENV
.
append_path
(
"PATH"
,
o
.
parent
)
end
end
end
end
def
which
(
cmd
)
super
(
cmd
,
ORIGINAL_PATHS
.
join
(
File
::
PATH_SEPARATOR
))
end
...
...
@@ -103,6 +107,7 @@ class Requirement
class
<<
self
include
BuildEnvironmentDSL
attr_reader
:env_proc
attr_rw
:fatal
,
:default_formula
# build is deprecated, use `depends_on <requirement> => :build` instead
attr_rw
:build
...
...
@@ -110,6 +115,14 @@ class Requirement
def
satisfy
(
options
=
{},
&
block
)
@satisfied
||=
Requirement
::
Satisfier
.
new
(
options
,
&
block
)
end
def
env
(
*
settings
,
&
block
)
if
block_given?
@env_proc
=
block
else
super
end
end
end
class
Satisfier
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/test_requirement.rb
+
4
−
0
View file @
d4602b17
...
...
@@ -123,6 +123,10 @@ class RequirementTests < Homebrew::TestCase
end
end
def
test_modify_build_environment_without_env_proc
assert_nil
Class
.
new
(
Requirement
).
new
.
modify_build_environment
end
def
test_eql
a
,
b
=
Requirement
.
new
,
Requirement
.
new
assert_eql
a
,
b
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment