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

nu: fix build on Linux #104928

Closed
wants to merge 1 commit into from
Closed
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
54 changes: 46 additions & 8 deletions Formula/nu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,45 @@ class Nu < Formula

depends_on "pcre"

uses_from_macos "llvm" => [:build, :test]
uses_from_macos "swift" => :build # For libdispatch on Linux.
uses_from_macos "libffi"

on_linux do
depends_on "gnustep-make" => :build
depends_on "gnustep-base"
depends_on "libobjc2"
end

# Clang must be used on Linux because GCC Objective-C support is insufficient.
fails_with :gcc

def install
ENV.delete("SDKROOT") if MacOS.version < :sierra
ENV["PREFIX"] = prefix
# Don't hard code path to clang.
inreplace "tools/nuke", "/usr/bin/clang", ENV.cc

unless OS.mac?
ENV.append_path "PATH", Formula["gnustep-make"].libexec

# Help linker find libdispatch from swift on Linux.
# This is only used for the mininush temporary compiler and is not needed for nush.
ldflags = %W[
"-L#{Formula["swift"].libexec}/lib/swift/linux"
"-Wl,-rpath,#{Formula["swift"].libexec}/lib/swift/linux"
]
ENV["LIBDIRS"] = ldflags.join(" ")

# Remove unused prefix from ffi.h
inreplace ["objc/NuBridge.h", "objc/NuBridge.m", "objc/Nu.m"], "x86_64-linux-gnu/", ""

# Remove CFLAGS that force using GNU runtime on Linux.
# Remove this workaround when upstream drops these flags or provides a way to disable them.
# Reported upstream here: https://github.com/programming-nu/nu/issues/99.
inreplace "Nukefile", "-DGNU_RUNTIME=1", ""
inreplace "Nukefile", "-fgnu-runtime", ""
end

inreplace "Nukefile" do |s|
s.gsub!('(SH "sudo ', '(SH "') # don't use sudo to install
Expand All @@ -36,14 +72,16 @@ def install
end

def caveats
<<~EOS
Nu.framework was installed to:
#{frameworks}/Nu.framework

You may want to symlink this Framework to a standard macOS location,
such as:
ln -s "#{frameworks}/Nu.framework" /Library/Frameworks
EOS
on_macos do
<<~EOS
Nu.framework was installed to:
#{frameworks}/Nu.framework

You may want to symlink this Framework to a standard macOS location,
such as:
ln -s "#{frameworks}/Nu.framework" /Library/Frameworks
EOS
end
end

test do
Expand Down