Class: ICURecipe

Inherits:
MiniPortile
  • Object
show all
Defined in:
ext/icu/extconf.rb

Overview

Checkout the source code of ICU. site.icu-project.org/download/ userguide.icu-project.org/howtouseicu Also check the readme of ICU release file.

Instance Method Summary collapse

Constructor Details

#initialize(name, version, static_p) {|_self| ... } ⇒ ICURecipe

Returns a new instance of ICURecipe.

Yields:

  • (_self)

Yield Parameters:

  • _self (ICURecipe)

    the object that the method was called on



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
# File 'ext/icu/extconf.rb', line 69

def initialize(name, version, static_p)
  super(name, version)
  self.target = File.join(ROOT, "ports")
  # Prefer host_alias over host in order to use i586-mingw32msvc as
  # correct compiler prefix for cross build, but use host if not set.
  self.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
  self.patch_files = Dir[File.join(ROOT, "patches", name, "*.patch")].sort
  self.configure_options << "--libdir=#{File.join(self.path, "lib")}"

  yield self

  env = Hash.new do |hash, key|
    hash[key] = ENV[key].dup.to_s rescue ''
  end

  self.configure_options.flatten!

  self.configure_options.delete_if do |option|
    case option
      when /\A(\w+)=(.*)\z/
        env[$1] = $2
        true
      else
        false
    end
  end

  if static_p
    self.configure_options += [
        "--enable-static",
        "--enable-shared",
        "--disable-renaming"
    ]
    env['CFLAGS'] = "-fPIC #{env['CFLAGS']}"
    env['CPPFLAGS'] = "-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=0 -DU_STATIC_IMPLEMENTATION #{env['CPPFLAGS']}"
    env['CXXFLAGS'] = "-fPIC -fno-exceptions #{env['CXXFLAGS']}"
    env['LDFLAGS'] = "-static-libstdc++ #{env['CFLAGS']}"
  else
    self.configure_options += [
        "--enable-shared",
        "--disable-static",
    ]
  end

  if RbConfig::CONFIG['target_cpu'] == 'universal'
    %w[CFLAGS LDFLAGS].each do |key|
      unless env[key].include?('-arch')
        env[key] += ' ' + RbConfig::CONFIG['ARCH_FLAG']
      end
    end
  end

  @env = env
end

Instance Method Details

#configureObject



157
158
159
160
161
162
163
164
165
166
167
168
# File 'ext/icu/extconf.rb', line 157

def configure
  # run as recommend, basically set up compiler and flags
  platform = if RUBY_PLATFORM =~ /mingw|mswin/
               'MSYS/MSVC'
             elsif RUBY_PLATFORM =~ /darwin/
               'MacOSX'
             else
               'Linux'
             end  # double quotes are significant.
  execute('ICU Configure', [@env] + ['./runConfigureICU', platform] + computed_options)
  super
end

#cookObject



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
# File 'ext/icu/extconf.rb', line 124

def cook

  message <<-"EOS"
************************************************************************
IMPORTANT NOTICE:

Building ICU with a packaged version of #{name}-#{version}#{'.' if self.patch_files.empty?}
  EOS

  unless self.patch_files.empty?
    message "with the following patches applied:\n"

    self.patch_files.each do |patch|
      message "\t- %s\n" % File.basename(patch)
    end
  end

  message <<-"EOS"

gem install icu -- --use-system-libraries

If you are using Bundler, tell it to use the option:

bundle config build.icu --use-system-libraries
bundle install
  EOS

  message <<-"EOS"
************************************************************************
  EOS
  super
end

#work_pathObject



170
171
172
# File 'ext/icu/extconf.rb', line 170

def work_path
  File.join(Dir.glob("#{tmp_path}/*").find { |d| File.directory?(d) }, 'source')
end