Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkage: enable cache by default. #4390

Merged
merged 1 commit into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,6 @@ then
HOMEBREW_BASH_COMMAND="$HOMEBREW_LIBRARY/Homebrew/dev-cmd/$HOMEBREW_COMMAND.sh"
fi

if [[ -n "$HOMEBREW_DEVELOPER" || -n "$HOMEBREW_DEV_CMD_RUN" ]]
then
export HOMEBREW_LINKAGE_CACHE="1"
fi

check-run-command-as-root() {
[[ "$(id -u)" = 0 ]] || return

Expand Down
9 changes: 2 additions & 7 deletions Library/Homebrew/dev-cmd/linkage.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#: * `linkage` [`--test`] [`--reverse`] [`--cached`] <formula>:
#: * `linkage` [`--test`] [`--reverse`] <formula>:
#: Checks the library links of an installed formula.
#:
#: Only works on installed formulae. An error is raised if it is run on
Expand All @@ -9,9 +9,6 @@
#:
#: If `--reverse` is passed, print the dylib followed by the binaries
#: which link to it for each library the keg references.
#:
#: If `--cached` is passed, print the cached linkage values stored in
#: HOMEBREW_CACHE, set from a previous `brew linkage` run

require "cache_store"
require "linkage_checker"
Expand All @@ -24,7 +21,6 @@ def linkage
Homebrew::CLI::Parser.parse do
switch "--test"
switch "--reverse"
switch "--cached"
switch :verbose
switch :debug
end
Expand All @@ -33,8 +29,7 @@ def linkage
ARGV.kegs.each do |keg|
ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1

use_cache = args.cached? || ENV["HOMEBREW_LINKAGE_CACHE"]
result = LinkageChecker.new(keg, use_cache: use_cache, cache_db: db)
result = LinkageChecker.new(keg, cache_db: db)

if args.test?
result.display_test_output
Expand Down
6 changes: 2 additions & 4 deletions Library/Homebrew/linkage_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
class LinkageChecker
attr_reader :undeclared_deps

def initialize(keg, formula = nil, cache_db:,
use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil?,
rebuild_cache: false)
def initialize(keg, formula = nil, cache_db:, rebuild_cache: false)
@keg = keg
@formula = formula || resolve_formula(keg)
@store = LinkageCacheStore.new(keg.to_s, cache_db) if use_cache
@store = LinkageCacheStore.new(keg.to_s, cache_db)

@system_dylibs = Set.new
@broken_dylibs = Set.new
Expand Down
34 changes: 9 additions & 25 deletions Library/Homebrew/test/dev-cmd/linkage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,16 @@
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
end

context "no cache" do
it "works when no arguments are provided" do
expect { brew "linkage" }
.to be_a_success
.and not_to_output.to_stdout
.and not_to_output.to_stderr
end

it "works when one argument is provided" do
expect { brew "linkage", "testball" }
.to be_a_success
.and not_to_output.to_stderr
end
it "works when no arguments are provided" do
expect { brew "linkage" }
.to be_a_success
.and not_to_output.to_stdout
.and not_to_output.to_stderr
end

context "cache" do
it "works when no arguments are provided" do
expect { brew "linkage", "--cached" }
.to be_a_success
.and not_to_output.to_stderr
end

it "works when one argument is provided" do
expect { brew "linkage", "--cached", "testball" }
.to be_a_success
.and not_to_output.to_stderr
end
it "works when one argument is provided" do
expect { brew "linkage", "testball" }
.to be_a_success
.and not_to_output.to_stderr
end
end
5 changes: 1 addition & 4 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
If `--pry` is passed or HOMEBREW_PRY is set, pry will be
used instead of irb.

* `linkage` [`--test`] [`--reverse`] [`--cached`] `formula`:
* `linkage` [`--test`] [`--reverse`] `formula`:
Checks the library links of an installed formula.

Only works on installed formulae. An error is raised if it is run on
Expand All @@ -791,9 +791,6 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
If `--reverse` is passed, print the dylib followed by the binaries
which link to it for each library the keg references.

If `--cached` is passed, print the cached linkage values stored in
HOMEBREW_CACHE, set from a previous `brew linkage` run

* `man` [`--fail-if-changed`]:
Generate Homebrew's manpages.

Expand Down
5 changes: 1 addition & 4 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ Enter the interactive Homebrew Ruby shell\.
If \fB\-\-examples\fR is passed, several examples will be shown\. If \fB\-\-pry\fR is passed or HOMEBREW_PRY is set, pry will be used instead of irb\.
.
.TP
\fBlinkage\fR [\fB\-\-test\fR] [\fB\-\-reverse\fR] [\fB\-\-cached\fR] \fIformula\fR
\fBlinkage\fR [\fB\-\-test\fR] [\fB\-\-reverse\fR] \fIformula\fR
Checks the library links of an installed formula\.
.
.IP
Expand All @@ -807,9 +807,6 @@ If \fB\-\-test\fR is passed, only display missing libraries and exit with a non\
.IP
If \fB\-\-reverse\fR is passed, print the dylib followed by the binaries which link to it for each library the keg references\.
.
.IP
If \fB\-\-cached\fR is passed, print the cached linkage values stored in HOMEBREW_CACHE, set from a previous \fBbrew linkage\fR run
.
.TP
\fBman\fR [\fB\-\-fail\-if\-changed\fR]
Generate Homebrew\'s manpages\.
Expand Down