我正在做的一些事情是依赖于编译器的。例如,是否可以检查是否使用gcc-4.9或clang编译器安装了boost
公式?
我正在寻找的可能是这样的:
$ echo HOMEBREW_CC
$ brew install boost
$ <comand>
built with clang
$ brew uninstall --force boost
$ export HOMEBREW_CC = gcc-4.9 ; export HOMEBREW_CXX = g++-4.9
$ brew install boost
$ <command>
built with gcc-4.9
答案 0 :(得分:0)
编制器列在收据
中$ cat /usr/local/Cellar/boost/1.58.0/INSTALL_RECEIPT.json
{"used_options":["--c++11","--with-mpi","--without-single"],"unused_options":["--universal","--with-icu4c","--without-static"],"built_as_bottle":false,"poured_from_bottle":false,"time":1437512231,"HEAD":"1d7b6215cbe7d690e961f1a72f497a58c95f6de4","stdlib":"libstdcxx","compiler":"gcc-5","source":{"path":"/usr/local/Library/Formula/boost.rb","tap":"Homebrew/homebrew"}}~
..虽然我一起攻击另一个解决方案
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index bf11af0..1c1caf3 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -774,7 +774,9 @@ class Formula
"version" => keg.version.to_s,
"used_options" => tab.used_options.as_flags,
"built_as_bottle" => tab.built_bottle,
- "poured_from_bottle" => tab.poured_from_bottle
+ "poured_from_bottle" => tab.poured_from_bottle,
+ "cc_compiler" => tab.cc_compiler,
+ "cxx_compiler" => tab.cxx_compiler
}
end
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 37b0db2..de0fe11 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -182,6 +182,16 @@ class Tab < OpenStruct
end
def to_json
+ if ENV['HOMEBREW_CC'] then
+ cc_compiler = ENV['HOMEBREW_CC']
+ else
+ cc_compiler = "clang"
+ end
+ if ENV['HOMEBREW_CXX'] then
+ cxx_compiler = ENV['HOMEBREW_CXX']
+ else
+ cxx_compiler = "clang"
+ end
attributes = {
"used_options" => used_options.as_flags,
"unused_options" => unused_options.as_flags,
@@ -192,6 +202,8 @@ class Tab < OpenStruct
"stdlib" => (stdlib.to_s if stdlib),
"compiler" => (compiler.to_s if compiler),
"source" => source,
+ "cc_compiler" => cc_compiler,
+ "cxx_compiler" => cxx_compiler
}
Utils::JSON.dump(attributes)