homebrew-core/Formula/ice.rb
2018-09-17 23:00:30 +10:00

81 lines
2.8 KiB
Ruby

class Ice < Formula
desc "Comprehensive RPC framework"
homepage "https://zeroc.com"
url "https://github.com/zeroc-ice/ice/archive/v3.7.1.tar.gz"
sha256 "b1526ab9ba80a3d5f314dacf22674dff005efb9866774903d0efca5a0fab326d"
bottle do
cellar :any
sha256 "a6a580aed075a7edcb9f59886bc59b0e6da888623dbf6d81c98f26c4fc472613" => :high_sierra
sha256 "73cb8a7d1af848b1832d1e837f2a3ec6c35846a8b7431748fd8e175442261df8" => :sierra
sha256 "319fa13dfe77aa352dd84fb5495fd548fc7d870305fd7c3ee2137c2f298cbf5e" => :el_capitan
end
#
# NOTE: we don't build slice2py, slice2js, slice2rb by default to prevent clashes with
# the translators installed by the PyPI/GEM/npm packages.
#
option "with-additional-compilers", "Build additional Slice compilers (slice2py, slice2js, slice2rb)"
option "with-java", "Build Ice for Java and the IceGrid GUI app"
option "without-xcode-sdk", "Build without the Xcode SDK for iOS development (includes static libs)"
depends_on "lmdb"
depends_on :macos => :mavericks
depends_on "mcpp"
depends_on :java => ["1.8+", :optional]
def install
ENV.O2 # Os causes performance issues
# Ensure Gradle uses a writable directory even in sandbox mode
ENV["GRADLE_USER_HOME"] = "#{buildpath}/.gradle"
args = [
"prefix=#{prefix}",
"V=1",
"MCPP_HOME=#{Formula["mcpp"].opt_prefix}",
"LMDB_HOME=#{Formula["lmdb"].opt_prefix}",
"CONFIGS=shared cpp11-shared #{build.with?("xcode-sdk") ? "xcodesdk cpp11-xcodesdk" : ""}",
"PLATFORMS=all",
"SKIP=slice2confluence #{build.without?("additional-compilers") ? "slice2py slice2rb slice2js" : ""}",
"LANGUAGES=cpp objective-c #{build.with?("java") ? "java java-compat" : ""}",
]
system "make", "install", *args
end
test do
(testpath / "Hello.ice").write <<~EOS
module Test
{
interface Hello
{
void sayHello();
}
}
EOS
(testpath / "Test.cpp").write <<~EOS
#include <Ice/Ice.h>
#include <Hello.h>
class HelloI : public Test::Hello
{
public:
virtual void sayHello(const Ice::Current&) override {}
};
int main(int argc, char* argv[])
{
Ice::CommunicatorHolder ich(argc, argv);
auto adapter = ich->createObjectAdapterWithEndpoints("Hello", "default -h localhost -p 10000");
adapter->add(std::make_shared<HelloI>(), Ice::stringToIdentity("hello"));
adapter->activate();
return 0;
}
EOS
system "#{bin}/slice2cpp", "Hello.ice"
system ENV.cxx, "-DICE_CPP11_MAPPING", "-std=c++11", "-c", "-I#{include}", "-I.", "Hello.cpp"
system ENV.cxx, "-DICE_CPP11_MAPPING", "-std=c++11", "-c", "-I#{include}", "-I.", "Test.cpp"
system ENV.cxx, "-L#{lib}", "-o", "test", "Test.o", "Hello.o", "-lIce++11"
system "./test"
end
end