Created
January 17, 2009 12:48
-
-
Save luislavena/48332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Rakefile b/Rakefile | |
index 2bf81cc..cb2fc41 100644 | |
--- a/Rakefile | |
+++ b/Rakefile | |
@@ -84,11 +84,18 @@ if defined? Gem | |
if defined? Rake::ExtensionTask | |
- host = 'i586-mingw32msvc' | |
+ # verify the building platform | |
+ if RUBY_PLATFORM !~ /mingw/ then | |
+ # only set host for cross compilation | |
+ # please note that mingw changes name between Linux and OSX. | |
+ host = 'i586-mingw32msvc' | |
+ end | |
+ | |
plat = 'x86-mswin32-60' | |
- tmp = "#{Dir.pwd}/tmp/#{plat}" | |
+ tmp = "tmp/#{plat}" | |
+ target = "#{tmp}/build" | |
cflags = "'-Os -DID3LIB_LINKOPTION=1'" | |
- config_options = ["--with-opt-dir=#{tmp}", "--with-cflags=#{cflags}"] | |
+ config_options = ["--with-opt-dir=#{target}", "--with-cflags=#{cflags}"] | |
id3lib = 'id3lib-3.8.3' | |
id3lib_url = "http://downloads.sourceforge.net/id3lib/#{id3lib}.tar.gz" | |
patches = FileList["#{Dir.pwd}/ext/mswin32/patches/*patch"] | |
@@ -108,6 +115,69 @@ if defined? Gem | |
ENV["CXX"] = "#{host}-g++" | |
end | |
+ # tmp/x86-mswin32-60 | |
+ directory tmp | |
+ | |
+ # download source code | |
+ file "#{tmp}/#{id3lib}.tar.gz" => [tmp] do |t| | |
+ when_writing("Downloading #{t.name}") do | |
+ puts "Downloading #{t.name}" | |
+ data = open(id3lib_url).read() | |
+ break if data == nil | |
+ chdir tmp do | |
+ open(File.basename(t.name), 'wb') do |f| | |
+ f.write(data) | |
+ end | |
+ end | |
+ end | |
+ end | |
+ | |
+ # get the first file from the compressed package | |
+ file "#{tmp}/#{id3lib}/Makefile.in" => ["#{tmp}/#{id3lib}.tar.gz"] do |t| | |
+ when_writing("Unpacking #{id3lib}.tar.gz") do | |
+ chdir tmp do | |
+ sh "tar xzf #{id3lib}.tar.gz" | |
+ end | |
+ end | |
+ end | |
+ | |
+ # apply patches, using a dummy checkpoint file as base | |
+ file "#{tmp}/#{id3lib}/.patched" => ["#{tmp}/#{id3lib}/Makefile.in"] do |t| | |
+ chdir tmp do | |
+ patches.each do |patch| | |
+ sh "patch -p0 < #{patch}" | |
+ end | |
+ end | |
+ touch t.name | |
+ end | |
+ | |
+ # now, let's generate the final Makefile | |
+ # we should have all patched at this point | |
+ file "#{tmp}/#{id3lib}/Makefile" => ["#{tmp}/#{id3lib}/.patched"] do |t| | |
+ env = "CFLAGS=#{cflags} CXXFLAGS=#{cflags}" | |
+ | |
+ opts = ["--prefix=#{File.expand_path(target)}"] # installation target | |
+ opts << "--host=#{host}" if host # only when cross compiling | |
+ opts << env # share the environment flags | |
+ | |
+ chdir "#{tmp}/#{id3lib}" do | |
+ system "sh configure #{opts.join(' ')}" | |
+ end | |
+ end | |
+ | |
+ # build the library with the makefile | |
+ file "#{target}/lib/libid3.a" => ["#{tmp}/#{id3lib}/Makefile"] do |t| | |
+ chdir "#{tmp}/#{id3lib}" do | |
+ system "make" | |
+ system "make install" | |
+ end | |
+ end | |
+ | |
+ end # defined? Rake::ExtensionTask | |
+ | |
+end # defined? Gem | |
+ | |
+=begin | |
# Linking to the DLLs provided by id3lib.sf.net doesn't seem to work on | |
# Windows, so we download and compile it automatically (the same as when | |
# cross compiling). | |
@@ -134,24 +204,7 @@ if defined? Gem | |
end | |
end | |
end | |
- | |
- file "#{tmp}/#{id3lib}.tar.gz" => [tmp] do |t| | |
- puts "Downloading #{id3lib_url}" | |
- data = open(id3lib_url).read() | |
- break if data == nil | |
- chdir tmp do | |
- open(File.basename(t.name), 'wb') do |f| | |
- f.write(data) | |
- end | |
- end | |
- end | |
- | |
- directory tmp | |
- | |
- end # defined? Rake::ExtensionTask | |
- | |
-end # defined? Gem | |
- | |
+=end | |
task :web => [:web_doc] do | |
puts "# Now execute the following:" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment