File: package.rb

package info (click to toggle)
ruby-gnome 4.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,320 kB
  • sloc: ruby: 55,206; ansic: 29,012; xml: 333; sh: 229; cpp: 45; makefile: 42
file content (161 lines) | stat: -rw-r--r-- 4,444 bytes parent folder | download | duplicates (3)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# -*- ruby -*-
#
# Copyright (C) 2013-2022  Ruby-GNOME Project Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

require "pathname"

module GNOME
  module Rake
    class Package
      attr_reader :name
      attr_reader :root_dir
      attr_reader :windows
      attr_reader :native
      attr_writer :external_packages
      def initialize(name, root_dir)
        @name = name
        @root_dir = Pathname.new(root_dir).expand_path
        @windows = WindowsConfiguration.new
        @native = NativeConfiguration.new
        @external_packages = []
      end

      def project_root_dir
        @root_dir.parent
      end

      def glib2_root_dir
        project_root_dir + "glib2"
      end

      def tmp_dir
        @root_dir + "tmp"
      end

      def download_dir
        tmp_dir + "download"
      end

      def patches_dir
        @root_dir + "patches"
      end

      def external_packages
        @external_packages.collect do |package|
          ExternalPackage.new(package)
        end
      end

      class WindowsConfiguration < Struct.new(:packages,
                                              :dependencies,
                                              :build_dependencies,
                                              :gobject_introspection_dependencies,
                                              :build_packages,
                                              :build_host)

        attr_reader :relative_binary_dir, :absolute_binary_dir
        def initialize
          super
          @relative_binary_dir = Pathname.new("vendor/local")
          @absolute_binary_dir = @relative_binary_dir.expand_path
        end

        def packages
          super || []
        end

        def dependencies
          super || []
        end

        def build_dependencies
          super || []
        end

        def gobject_introspection_dependencies
          super || []
        end

        def build_packages
          (super || []).collect do |package|
            package = package.dup
            package[:windows] = {
              :include_paths   => package.delete(:include_paths),
              :library_paths   => package.delete(:library_paths),
              :configure_args  => package.delete(:configure_args),
              :patches         => package.delete(:patches),
              :need_autogen    => package.delete(:need_autogen),
              :need_autoreconf => package.delete(:need_autoreconf),
            }
            ExternalPackage.new(package)
          end
        end

        def build_host
          super || guess_build_host
        end

        def guess_build_host
          ENV["RUBY_GNOME2_BUILD_HOST"] ||
            guess_build_host_from_architecture ||
            "i686-w64-mingw32"
        end

        def guess_build_host_from_architecture
          case build_architecture
          when "x86"
            "i686-w64-mingw32"
          when "x64"
            "x86_64-w64-mingw32"
          else
            nil
          end
        end

        def build_arch
          case build_architecture
          when "x86"
            "i686"
          when "x64"
            "x86_64"
          end
        end

        def build_architecture
          ENV["RUBY_GNOME2_BUILD_ARCHITECTURE"] || "x86"
        end

        def build_architecture_suffix
          case build_architecture
          when "x86"
            "win32"
          when "x64"
            "win64"
          end
        end
      end

      class NativeConfiguration
        attr_reader :relative_binary_dir, :absolute_binary_dir
        def initialize
          @relative_binary_dir = Pathname.new("tmp/native/local")
          @absolute_binary_dir = @relative_binary_dir.expand_path
        end
      end
    end
  end
end