mini_portile 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ === 0.2.0 / 2011-04-05
2
+
3
+ * Enhancements:
4
+ * Improve tar detection
5
+ * Improve and refactor configure_options
6
+ * Detect configure_options changes. Closes GH-1
7
+ * Add recipe examples
8
+
9
+ * Bugfixes:
10
+ * MiniPortile#target can be changed now. Closes GH-2
11
+ * Always redirect tar output properly
12
+
1
13
  === 0.1.0 / 2011-03-08
2
14
 
3
15
  * Initial release. Welcome to this world!
@@ -3,8 +3,8 @@
3
3
  * {Source Code}[https://github.com/luislavena/mini_portile]
4
4
  * {Bug Reports}[https://github.com/luislavena/mini_portile/issues]
5
5
 
6
- This project is a minimalistic, simplistic and stupid implementation of a port
7
- /recipe system <b>for developers</b>.
6
+ This project is a minimalistic, simplistic and stupid implementation of a port/recipe
7
+ system <b>for developers</b>.
8
8
 
9
9
  == Another port system, srsly?
10
10
 
@@ -103,15 +103,16 @@ task depends on MiniPortile compilation and most important, activation.
103
103
  Take the following as a simplification of how you can use MiniPortile with
104
104
  Rake:
105
105
 
106
- file ".libiconv.1.13.1.installed" do |f|
106
+ task :libiconv do
107
107
  recipe = MiniPortile.new("libiconv", "1.13.1")
108
108
  recipe.files = ["http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz"]
109
- recipe.cook
110
- touch f.name
111
- end
109
+ checkpoint = ".#{recipe.name}-#{recipe.version}.installed"
110
+
111
+ unless File.exist?(checkpoint)
112
+ recipe.cook
113
+ touch checkpoint
114
+ end
112
115
 
113
- task :libiconv => [".libiconv.1.13.1.installed"] do
114
- recipe = MiniPortile.new("libiconv", "1.13.1")
115
116
  recipe.activate
116
117
  end
117
118
 
@@ -128,6 +129,21 @@ This example will:
128
129
  For your homework, you can make libiconv version be taken from <tt>ENV</tt>
129
130
  variables.
130
131
 
132
+ === Native or cross-compilation
133
+
134
+ Above examples cover the normal use case: compile support libraries natively.
135
+
136
+ MiniPortile also covers another use case, which is the cross-compilation of the
137
+ support libraries to be used as part of a binary gem compilation.
138
+
139
+ It is the perfect complementary tool for rake-compiler and it's <tt>cross</tt>
140
+ Rake task.
141
+
142
+ Depending on your usage of rake-compiler, you will need to use <tt>host</tt> to
143
+ match the installed cross-compiler toolchain.
144
+
145
+ Please refer to the examples directory for simplified and practical usage.
146
+
131
147
  === Supported scenarios
132
148
 
133
149
  As mentioned before, MiniPortile requires a GCC compiler toolchain. This has
data/Rakefile CHANGED
@@ -4,12 +4,12 @@ require "rubygems/package_task"
4
4
  GEM_SPEC = Gem::Specification.new do |s|
5
5
  # basic information
6
6
  s.name = "mini_portile"
7
- s.version = "0.1.0"
7
+ s.version = "0.2.0"
8
8
  s.platform = Gem::Platform::RUBY
9
9
 
10
10
  # description and details
11
11
  s.summary = "Simplistic port-like solution for developers"
12
- s.description = "Provide a standard and simplified way to build and package\nRuby extensions (C, Java) using Rake as glue."
12
+ s.description = "Simplistic port-like solution for developers. It provides a standard and simplified way to compile against dependency libraries without messing up your system."
13
13
 
14
14
  # requirements
15
15
  s.required_ruby_version = ">= 1.8.6"
@@ -19,7 +19,7 @@ GEM_SPEC = Gem::Specification.new do |s|
19
19
  # development dependencies (add_development_dependency)
20
20
 
21
21
  # components, files and paths
22
- s.files = FileList["lib/**/*.rb", "Rakefile", "*.{rdoc,txt}"]
22
+ s.files = FileList["examples/Rakefile", "lib/**/*.rb", "Rakefile", "*.{rdoc,txt}"]
23
23
 
24
24
  s.require_path = 'lib'
25
25
 
@@ -0,0 +1,47 @@
1
+ require File.expand_path("mini_portile", File.join(File.dirname(__FILE__), "../lib"))
2
+
3
+ $recipes = {}
4
+
5
+ ICONV_VERSION = "1.13.1"
6
+ $recipes[:libiconv] = MiniPortile.new "libiconv", ICONV_VERSION
7
+ $recipes[:libiconv].files << "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"
8
+
9
+ $recipes[:sqlite3] = MiniPortile.new "sqlite3", "3.7.5"
10
+ $recipes[:sqlite3].files << "http://sqlite.org/sqlite-autoconf-3070500.tar.gz"
11
+
12
+ namespace :ports do
13
+ directory "ports"
14
+
15
+ desc "Install port libiconv #{ICONV_VERSION}"
16
+ task :libiconv => ["ports"] do |t|
17
+ recipe = $recipes[:libiconv]
18
+ checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
19
+
20
+ unless File.exist?(checkpoint)
21
+ recipe.cook
22
+ touch checkpoint
23
+ end
24
+
25
+ recipe.activate
26
+ end
27
+
28
+ desc "Install port sqlite3 #{$recipes[:sqlite3].version}"
29
+ task :sqlite3 => ["ports"] do |t|
30
+ recipe = $recipes[:sqlite3]
31
+ checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
32
+
33
+ unless File.exist?(checkpoint)
34
+ recipe.cook
35
+ touch checkpoint
36
+ end
37
+
38
+ recipe.activate
39
+ end
40
+ end
41
+
42
+ desc "Adjust all recipes host for cross-compilation"
43
+ task :cross do
44
+ $recipes.each do |_, recipe|
45
+ recipe.host = "i686-w64-mingw32"
46
+ end
47
+ end
@@ -2,10 +2,12 @@ require 'rbconfig'
2
2
  require 'net/http'
3
3
  require 'fileutils'
4
4
  require 'tempfile'
5
+ require 'digest/md5'
5
6
 
6
7
  class MiniPortile
7
- attr_reader :name, :version, :target
8
- attr_accessor :host, :files, :logger, :config_options
8
+ attr_reader :name, :version
9
+ attr_writer :configure_options
10
+ attr_accessor :host, :files, :target, :logger
9
11
 
10
12
  def initialize(name, version)
11
13
  @name = name
@@ -13,7 +15,6 @@ class MiniPortile
13
15
  @target = 'ports'
14
16
  @files = []
15
17
  @logger = STDOUT
16
- @config_options = []
17
18
 
18
19
  @host = RbConfig::CONFIG['arch']
19
20
  end
@@ -32,18 +33,18 @@ class MiniPortile
32
33
  end
33
34
  end
34
35
 
36
+ def configure_options
37
+ @configure_options ||= configure_defaults
38
+ end
39
+
35
40
  def configure
36
41
  return if configured?
37
42
 
38
- prefix = File.expand_path(port_path)
39
- options = [
40
- "--disable-shared", # disable generation of shared object
41
- "--enable-static", # build static library
42
- "--host=#{@host}", # build for specific target (host)
43
- "--prefix=#{prefix}" # installation target
44
- ].concat(@config_options).join(' ')
43
+ md5_file = File.join(tmp_path, 'configure.md5')
44
+ digest = Digest::MD5.hexdigest(computed_options)
45
+ File.open(md5_file, "w") { |f| f.write digest }
45
46
 
46
- execute('configure', %Q(sh configure #{options}))
47
+ execute('configure', %Q(sh configure #{computed_options}))
47
48
  end
48
49
 
49
50
  def compile
@@ -67,8 +68,12 @@ class MiniPortile
67
68
  def configured?
68
69
  configure = File.join(work_path, 'configure')
69
70
  makefile = File.join(work_path, 'Makefile')
71
+ md5_file = File.join(tmp_path, 'configure.md5')
70
72
 
71
- newer?(makefile, configure)
73
+ stored_md5 = File.exist?(md5_file) ? File.read(md5_file) : ""
74
+ current_md5 = Digest::MD5.hexdigest(computed_options)
75
+
76
+ (current_md5 == stored_md5) && newer?(makefile, configure)
72
77
  end
73
78
 
74
79
  def installed?
@@ -131,16 +136,44 @@ private
131
136
  end
132
137
  end
133
138
 
139
+ def configure_defaults
140
+ [
141
+ "--host=#{@host}", # build for specific target (host)
142
+ "--enable-static", # build static library
143
+ "--disable-shared" # disable generation of shared object
144
+ ]
145
+ end
146
+
147
+ def configure_prefix
148
+ "--prefix=#{File.expand_path(port_path)}"
149
+ end
150
+
151
+ def computed_options
152
+ [
153
+ configure_options, # customized or default options
154
+ configure_prefix, # installation target
155
+ ].flatten.join(' ')
156
+ end
157
+
134
158
  def log_file(action)
135
159
  File.join(tmp_path, "#{action}.log")
136
160
  end
137
161
 
162
+ def tar_exe
163
+ @@tar_exe ||= begin
164
+ dev_null = RbConfig::CONFIG['host_os'] =~ /mingw|mswin/ ? 'NUL' : '/dev/null'
165
+ %w[tar bsdtar basic-bsdtar].find { |c|
166
+ system("#{c} --version >> #{dev_null} 2>&1")
167
+ }
168
+ end
169
+ end
170
+
138
171
  def extract_file(file, target)
139
172
  filename = File.basename(file)
140
173
  FileUtils.mkdir_p target
141
174
 
142
175
  message "Extracting #{filename} into #{target}... "
143
- result = `tar xf #{file} -C #{target}`
176
+ result = `#{tar_exe} xf #{file} -C #{target} 2>&1`
144
177
  if $?.success?
145
178
  output "OK"
146
179
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_portile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Luis Lavena
@@ -15,13 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-07 00:00:00 -03:00
18
+ date: 2011-04-05 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
22
- description: |-
23
- Provide a standard and simplified way to build and package
24
- Ruby extensions (C, Java) using Rake as glue.
22
+ description: Simplistic port-like solution for developers. It provides a standard and simplified way to compile against dependency libraries without messing up your system.
25
23
  email: luislavena@gmail.com
26
24
  executables: []
27
25
 
@@ -32,6 +30,7 @@ extra_rdoc_files:
32
30
  - History.txt
33
31
  - LICENSE.txt
34
32
  files:
33
+ - examples/Rakefile
35
34
  - lib/mini_portile.rb
36
35
  - Rakefile
37
36
  - README.rdoc
@@ -74,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
73
  requirements: []
75
74
 
76
75
  rubyforge_project:
77
- rubygems_version: 1.5.2
76
+ rubygems_version: 1.6.2
78
77
  signing_key:
79
78
  specification_version: 3
80
79
  summary: Simplistic port-like solution for developers