Skip to content

Commit 2b7d830

Browse files
Avoid clobbering LDFLAGS and CPPFLAGS if in a nix prepared environment (#526)
* Avoid nuking LDFLAGS if using nix * Actual code change * Use ENV.key? to check for nix env var * Consistent use of ENV.key? --------- Co-authored-by: Maciej Mensfeld <[email protected]>
1 parent 337f72f commit 2b7d830

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ext/Rakefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ task :default => :clean do
1616
require "mini_portile2"
1717
recipe = MiniPortile.new("librdkafka", Rdkafka::LIBRDKAFKA_VERSION)
1818

19-
# Use default homebrew openssl if we're on mac and the directory exists
20-
# and each of flags is not empty
21-
if recipe.host&.include?("darwin") && system("which brew &> /dev/null") && Dir.exist?("#{homebrew_prefix = %x(brew --prefix openssl).strip}")
22-
ENV["CPPFLAGS"] = "-I#{homebrew_prefix}/include" unless ENV["CPPFLAGS"]
23-
ENV["LDFLAGS"] = "-L#{homebrew_prefix}/lib" unless ENV["LDFLAGS"]
19+
# Use default homebrew openssl if we're on mac and the directory exists, is not using nix-prepared libraries
20+
# and each of flags is not already set
21+
if recipe.host&.include?("darwin") && system("which brew &> /dev/null") && Dir.exist?("#{homebrew_prefix = %x(brew --prefix openssl).strip}") && ENV.key?("NIX_LDFLAGS")
22+
ENV["CPPFLAGS"] = "-I#{homebrew_prefix}/include" unless ENV.key?("CPPFLAGS")
23+
ENV["LDFLAGS"] = "-L#{homebrew_prefix}/lib" unless ENV.key?("LDFLAGS")
2424
end
2525

2626
releases = File.expand_path(File.join(File.dirname(__FILE__), '../dist'))

0 commit comments

Comments
 (0)