aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/dmd.rb
blob: bd10fbf60fdca9fa8cb97d891cd318c34a62e082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'formula'

class Dmd < Formula
  homepage 'http://dlang.org'
  url 'https://github.com/D-Programming-Language/dmd/archive/v2.064.2.tar.gz'
  sha1 '8f88af77aab4c206841d93d7f4cfd399cbe3fdd6'

  resource 'druntime' do
    url 'https://github.com/D-Programming-Language/druntime/archive/v2.064.2.tar.gz'
    sha1 '42bc0f252bbb0c71de6789bdf2697b5daf41dd43'
  end

  resource 'phobos' do
    url 'https://github.com/D-Programming-Language/phobos/archive/v2.064.2.tar.gz'
    sha1 'e39489a6c7c60c947559a084cc7619e373d3c464'
  end

  resource 'tools' do
    url 'https://github.com/D-Programming-Language/tools/archive/v2.064.2.tar.gz'
    sha1 '590dfb8cd4b6fea74d03ddf230ec2734e7c71c99'
  end

  def install
    make_args = ["INSTALL_DIR=#{prefix}", "MODEL=#{Hardware::bits}", "-f", "posix.mak"]

    system "make", "install", "TARGET_CPU=X86", "RELEASE=1", *make_args

    share.install prefix/'man'

    rm bin/'dmd.conf'

    make_args.unshift "DMD=#{bin}/dmd"

    resource('druntime').stage do
      system "make", "install", *make_args
    end

    resource('phobos').stage do
      system "make", "install", "DRUNTIME_PATH=#{prefix}", "VERSION=#{buildpath}/VERSION", *make_args
    end

    (bin/'dmd.conf').open('w+') do |f|
      f.puts "[Environment]"
      f.puts "DFLAGS=-I#{prefix}/import -L-L#{lib}"
    end

    resource('tools').stage do
      inreplace 'posix.mak' do |s|
        s.gsub! 'install: $(TOOLS) $(CURL_TOOLS)', 'install: $(TOOLS)'
        #Remove on next release
        s.gsub! 'install -t $(DESTDIR)$(PREFIX) $(^)', 'cp $^ $(INSTALL_DIR)/bin'
      end
      system "make", "install", *make_args
    end
  end

  def test
    system "dmd", "#{prefix}/samples/hello.d"
    system "./hello"
  end
end