Fix brew style

This commit is contained in:
Mike McQuaid 2020-09-15 13:39:06 +01:00
parent 828eb0b690
commit 3923d331de
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
7 changed files with 36 additions and 30 deletions

View File

@ -194,6 +194,11 @@ Lint/AmbiguousRegexpLiteral:
Exclude:
- 'Taps/*/*/{Formula/,}*.rb'
# useful for metaprogramming in RSpec
Lint/ConstantDefinitionInBlock:
Exclude:
- '**/*_spec.rb'
# so many of these in formulae and can't be autocorrected
Lint/ParenthesesAsGroupedExpression:
Exclude:

View File

@ -276,7 +276,7 @@ module Cask
def x11_dependencies
return unless @cask.depends_on.x11
raise CaskX11DependencyError, @cask.token unless MacOS::X11.installed?
raise CaskX11DependencyError, @cask.token unless MacOS::XQuartz.installed?
end
def graph_dependencies(cask_or_formula, acc = TopologicalHash.new)

View File

@ -915,11 +915,11 @@ module Homebrew
none_string
else
cask_count = begin
tap.cask_files.count
rescue
error_tap_paths << tap.path
0
end
tap.cask_files.count
rescue
error_tap_paths << tap.path
0
end
"#{tap.path} (#{cask_count} #{"cask".pluralize(cask_count)})"
end

View File

@ -11,25 +11,25 @@ module Stdenv
def x11
# There are some config scripts here that should go in the PATH
append_path "PATH", MacOS::X11.bin.to_s
append_path "PATH", MacOS::XQuartz.bin.to_s
# Append these to PKG_CONFIG_LIBDIR so they are searched
# *after* our own pkgconfig directories, as we dupe some of the
# libs in XQuartz.
append_path "PKG_CONFIG_LIBDIR", "#{MacOS::X11.lib}/pkgconfig"
append_path "PKG_CONFIG_LIBDIR", "#{MacOS::X11.share}/pkgconfig"
append_path "PKG_CONFIG_LIBDIR", "#{MacOS::XQuartz.lib}/pkgconfig"
append_path "PKG_CONFIG_LIBDIR", "#{MacOS::XQuartz.share}/pkgconfig"
append "LDFLAGS", "-L#{MacOS::X11.lib}"
append_path "CMAKE_PREFIX_PATH", MacOS::X11.prefix.to_s
append_path "CMAKE_INCLUDE_PATH", MacOS::X11.include.to_s
append_path "CMAKE_INCLUDE_PATH", "#{MacOS::X11.include}/freetype2"
append "LDFLAGS", "-L#{MacOS::XQuartz.lib}"
append_path "CMAKE_PREFIX_PATH", MacOS::XQuartz.prefix.to_s
append_path "CMAKE_INCLUDE_PATH", MacOS::XQuartz.include.to_s
append_path "CMAKE_INCLUDE_PATH", "#{MacOS::XQuartz.include}/freetype2"
append "CPPFLAGS", "-I#{MacOS::X11.include}"
append "CPPFLAGS", "-I#{MacOS::X11.include}/freetype2"
append "CPPFLAGS", "-I#{MacOS::XQuartz.include}"
append "CPPFLAGS", "-I#{MacOS::XQuartz.include}/freetype2"
append_path "ACLOCAL_PATH", "#{MacOS::X11.share}/aclocal"
append_path "ACLOCAL_PATH", "#{MacOS::XQuartz.share}/aclocal"
append "CFLAGS", "-I#{MacOS::X11.include}" unless MacOS::CLT.installed?
append "CFLAGS", "-I#{MacOS::XQuartz.include}" unless MacOS::CLT.installed?
end
def setup_build_environment(**options)

View File

@ -24,7 +24,7 @@ module Superenv
def homebrew_extra_paths
paths = []
paths << MacOS::X11.bin.to_s if x11?
paths << MacOS::XQuartz.bin.to_s if x11?
paths
end
@ -32,13 +32,13 @@ module Superenv
def homebrew_extra_pkg_config_paths
paths = \
["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
paths << "#{MacOS::X11.lib}/pkgconfig" << "#{MacOS::X11.share}/pkgconfig" if x11?
paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11?
paths
end
def homebrew_extra_aclocal_paths
paths = []
paths << "#{MacOS::X11.share}/aclocal" if x11?
paths << "#{MacOS::XQuartz.share}/aclocal" if x11?
paths
end
@ -54,7 +54,7 @@ module Superenv
paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
paths
end
@ -65,7 +65,7 @@ module Superenv
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib"
paths << Formula["llvm"].opt_lib.to_s
end
paths << MacOS::X11.lib.to_s if x11?
paths << MacOS::XQuartz.lib.to_s if x11?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
paths
end
@ -74,14 +74,14 @@ module Superenv
paths = []
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed?
paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt?
paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11?
paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
paths
end
def homebrew_extra_cmake_library_paths
paths = []
paths << MacOS::X11.lib.to_s if x11?
paths << MacOS::XQuartz.lib.to_s if x11?
paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries"
paths
end
@ -102,7 +102,7 @@ module Superenv
end
def set_x11_env_if_installed
ENV.x11 = MacOS::X11.installed?
ENV.x11 = MacOS::XQuartz.installed?
end
# @private

View File

@ -2,7 +2,10 @@
module OS
module Mac
X11 = XQuartz = Module.new do # rubocop:disable Style/MutableConstant
# Helper module for querying XQuartz information.
#
# @api private
module XQuartz
module_function
DEFAULT_BUNDLE_PATH = Pathname.new("Applications/Utilities/XQuartz.app").freeze
@ -83,12 +86,10 @@ module OS
PKGINFO_VERSION_MAP.fetch(str, str)
end
# This should really be private, but for compatibility reasons it must
# remain public. New code should use `MacOS::X11.bin`, `MacOS::X11.lib` and
# `MacOS::X11.include` instead, as that accounts for Xcode-only systems.
def prefix
@prefix ||= Pathname.new("/opt/X11") if Pathname.new("/opt/X11/lib/libpng.dylib").exist?
end
private_class_method :prefix
def installed?
!version.null? && !prefix.nil?

View File

@ -76,7 +76,7 @@ describe "Satisfy Dependencies and Requirements", :cask do
describe "depends_on x11" do
before do
allow(MacOS::X11).to receive(:installed?).and_return(x11_installed)
allow(MacOS::XQuartz).to receive(:installed?).and_return(x11_installed)
end
context "when satisfied" do