Skip to content

Commit 0a20dab

Browse files
authored
Merge pull request #79 from Sigill/travis-update
Update Rake tasks to easily run the CI against various versions of taglib
2 parents 640fe2a + 057a803 commit 0a20dab

File tree

11 files changed

+144
-38
lines changed

11 files changed

+144
-38
lines changed

.travis.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
language: ruby
2-
rvm:
3-
- 1.8.7
4-
- 2.0.0
5-
- 2.1.1
6-
- 2.3.0
7-
addons:
8-
apt:
9-
packages:
10-
- libtag1-dev
11-
- swig
2+
env:
3+
global:
4+
- PLATFORM=x86_64-linux-gnu
5+
- MAKEFLAGS="-j2"
6+
matrix:
7+
include:
8+
- rvm: 2.2.7
9+
env: TAGLIB_VERSION=1.7.2 TAGLIB_DIR=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.7.2 LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.7.2/lib:$LD_LIBRARY_PATH
10+
- rvm: 2.2.7
11+
env: TAGLIB_VERSION=1.8 TAGLIB_DIR=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.8 LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.8/lib:$LD_LIBRARY_PATH
12+
- rvm: 2.3.4
13+
env: TAGLIB_VERSION=1.9.1 TAGLIB_DIR=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.9.1 LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.9.1/lib:$LD_LIBRARY_PATH
14+
- rvm: 2.4.1
15+
env: TAGLIB_VERSION=1.10 TAGLIB_DIR=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.10 LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.10/lib:$LD_LIBRARY_PATH
16+
- rvm: 2.4.1
17+
env: TAGLIB_VERSION=1.11.1 TAGLIB_DIR=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.11.1 LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/tmp/x86_64-linux-gnu/taglib-1.11.1/lib:$LD_LIBRARY_PATH
18+
before_script: bundle exec rake vendor

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ Build and install gem into system gems:
9595

9696
rake install
9797

98+
Build a specific version of Taglib:
99+
100+
PLATFORM=x86_64-linux TAGLIB_VERSION=1.9.1 rake vendor
101+
102+
The above command will automatically download Taglig 1.9.1, build it and install it in `tmp/x86_64-linux/taglib-1.9.1`.
103+
104+
The `swig` and `compile` tasks can then be executed against that specific version of Taglib by setting the `TAGLIB_DIR` environment variable to `$PWD/tmp/x86_64-linux/taglib-1.9.1` (it is assumed that taglib headers are located at `$TAGLIB_DIR/include` and taglib libraries at `$TAGLIB_DIR/lib`).
105+
106+
The `test` task can then be run for that version of Taglib by adding `$PWD/tmp/x86_64-linux/taglib-1.9.1/lib` to the `LD_LIBRARY_PATH` environment variable.
107+
108+
To do everything in one command:
109+
110+
PLATFORM=x86_64-linux TAGLIB_VERSION=1.7.2 TAGLIB_DIR=$PWD/tmp/x86_64-linux/taglib-1.7.2 LD_LIBRARY_PATH=$PWD/tmp/x86_64-linux/taglib-1.7.2/lib rake vendor compile test
111+
98112
### Workflow
99113

100114
* Check out the latest master to make sure the feature hasn't been

Rakefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,14 @@ end
2525

2626
$gemspec = Bundler::GemHelper.gemspec
2727

28-
FileList['tasks/**/*.rake'].each { |task| import task }
28+
import 'tasks/docs_coverage.rake'
29+
import 'tasks/ext.rake'
30+
import 'tasks/gemspec_check.rake'
31+
32+
# When importing swig.rake, the *_wrap.cxx files depend on being generated
33+
# by Swig. Since the ExtensionTasks depend on the *_wrap.cxx files,
34+
# compiling the extensions will trigger Swig, which is not desired as
35+
# those files have already been generated and there's no reason to make
36+
# Swig a variable of the CI. To prevent those dependencies, do not import
37+
# swig.rake when running in Travis.
38+
import 'tasks/swig.rake' unless ENV['TRAVIS'] == 'true'

ext/extconf_common.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ def error msg
2020
abort
2121
end
2222

23-
dir_config('tag')
23+
if ENV.has_key?('TAGLIB_DIR') and !File.directory?(ENV['TAGLIB_DIR'])
24+
error "When defined, the TAGLIB_DIR environment variable must point to a valid directory."
25+
end
26+
27+
# If specified, use the TAGLIB_DIR environment variable as the prefix
28+
# for finding taglib headers and libs. See MakeMakefile#dir_config
29+
# for more details.
30+
dir_config('tag', (ENV['TAGLIB_DIR'] if ENV.has_key?('TAGLIB_DIR')))
2431

2532
# When compiling statically, -lstdc++ would make the resulting .so to
2633
# have a dependency on an external libstdc++ instead of the static one.

ext/taglib_base/taglib_base.i

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ namespace TagLib {
3232

3333
// Rename setters to Ruby convention (combining SWIG rename functions
3434
// does not seem to be possible, thus resort to some magic)
35-
%rename("%(command: ruby -e 'print(ARGV[0][3..-1].split(/(?=[A-Z])/).join(\"_\").downcase + \"=\")' )s",
35+
// setFoo -> foo=
36+
%rename("%(command: perl -e \"print lc(join('_', split(/(?=[A-Z])/, substr(@ARGV[0], 3)))), '='\" )s",
3637
regexmatch$name="^set[A-Z]") "";
3738

3839
// isFoo -> foo?
39-
%rename("%(command: ruby -e 'print(ARGV[0][2..-1].split(/(?=[A-Z])/).join(\"_\").downcase + \"?\")' )s",
40+
%rename("%(command: perl -e \"print lc(join('_', split(/(?=[A-Z])/, substr(@ARGV[0], 2)))), '?'\" )s",
4041
regexmatch$name="^is[A-Z]") "";
4142

4243
// ByteVector

tasks/ext.rake

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
# Extension tasks and cross-compiling
22

33
host = 'i686-w64-mingw32'
4-
$plat = 'i386-mingw32'
4+
$plat = ENV['PLATFORM'] || 'i386-mingw32'
55

6-
tmp = "#{Dir.pwd}/tmp/#{$plat}"
6+
7+
taglib_version = ENV['TAGLIB_VERSION'] || '1.9.1'
8+
taglib = "taglib-#{taglib_version}"
9+
10+
tmp = "#{Dir.pwd}/tmp"
11+
tmp_arch = "#{tmp}/#{$plat}"
712
toolchain_file = "#{Dir.pwd}/ext/win.cmake"
8-
install_dir = "#{tmp}/install"
13+
install_dir = "#{tmp_arch}/#{taglib}"
914
install_dll = "#{install_dir}/bin/libtag.dll"
15+
install_so = "#{install_dir}/lib/libtag.so"
1016
$cross_config_options = ["--with-opt-dir=#{install_dir}"]
1117

12-
taglib_version = '1.9.1'
13-
taglib = "taglib-#{taglib_version}"
14-
taglib_url = "https://github.com/taglib/taglib/releases/download/v#{taglib_version}/#{taglib}.tar.gz"
15-
# WITH_MP4, WITH_ASF only needed with taglib 1.7, will be default in 1.8
16-
taglib_options = "-DCMAKE_BUILD_TYPE=Release -DWITH_MP4=ON -DWITH_ASF=ON"
18+
taglib_url = "https://github.com/taglib/taglib/archive/v#{taglib_version}.tar.gz"
19+
taglib_options = [ "-DCMAKE_BUILD_TYPE=Release",
20+
"-DBUILD_EXAMPLES=OFF",
21+
"-DBUILD_TESTS=OFF",
22+
"-DBUILD_BINDINGS=OFF", # 1.11 builds bindings by default
23+
"-DBUILD_SHARED_LIBS=ON", # 1.11 builds static by default
24+
"-DWITH_MP4=ON",# WITH_MP4, WITH_ASF only needed with taglib 1.7, will be default in 1.8
25+
"-DWITH_ASF=ON"].join(' ')
1726

1827
def configure_cross_compile(ext)
1928
ext.cross_compile = true
@@ -62,7 +71,7 @@ task :cross do
6271
ENV["CXX"] = "#{host}-g++"
6372
end
6473

65-
file "tmp/#{$plat}/stage/lib/libtag.dll" => [install_dll] do |f|
74+
file "#{tmp_arch}/stage/lib/libtag.dll" => [install_dll] do |f|
6675
install install_dll, f
6776
end
6877

@@ -74,6 +83,18 @@ file install_dll => ["#{tmp}/#{taglib}"] do
7483
end
7584
end
7685

86+
task :vendor => [install_so]
87+
88+
file install_so => ["#{tmp_arch}/#{taglib}", "#{tmp_arch}/#{taglib}-build", "#{tmp}/#{taglib}"] do
89+
chdir "#{tmp_arch}/#{taglib}-build" do
90+
sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} #{taglib_options} #{tmp}/#{taglib})
91+
sh "make install VERBOSE=1"
92+
end
93+
end
94+
95+
directory "#{tmp_arch}/#{taglib}"
96+
directory "#{tmp_arch}/#{taglib}-build"
97+
7798
file "#{tmp}/#{taglib}" => ["#{tmp}/#{taglib}.tar.gz"] do
7899
chdir tmp do
79100
sh "tar xzf #{taglib}.tar.gz"
@@ -83,12 +104,9 @@ end
83104
file "#{tmp}/#{taglib}.tar.gz" => [tmp] do |t|
84105
require 'open-uri'
85106
puts "Downloading #{taglib_url}"
86-
data = open(taglib_url).read()
87-
break if data == nil
88-
chdir tmp do
89-
open(File.basename(t.name), 'wb') do |f|
90-
f.write(data)
91-
end
107+
108+
File.open(t.name, 'wb') do |f|
109+
IO.copy_stream(open(taglib_url), f)
92110
end
93111
end
94112

tasks/swig.rake

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
# Tasks for generating SWIG wrappers in ext
22

3+
# Execute SWIG for the specified extension.
4+
# Arguments:
5+
# mod:: The name of the SWIG wrapper to process.
6+
#
7+
# If the TAGLIB_DIR environment variable points to a directory,
8+
# $TAGLIB_DIR/include will be searched first for taglib headers.
39
def run_swig(mod)
410
swig = `which swig`.chomp
511
if swig.empty?
612
swig = `which swig2.0`.chomp
713
end
8-
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/local/include -I/usr/include #{mod}.i"
14+
15+
# Standard search location for headers
16+
include_args = %w{-I/usr/local/include -I/usr/include}
17+
18+
if ENV.has_key?('TAGLIB_DIR')
19+
unless File.directory?(ENV['TAGLIB_DIR'])
20+
abort "When defined, the TAGLIB_DIR environment variable must point to a valid directory."
21+
end
22+
23+
# Push it in front to get it searched first.
24+
include_args.unshift('-I' + ENV['TAGLIB_DIR'] + '/include')
25+
end
26+
27+
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} #{include_args.join(' ')} #{mod}.i"
928
end
1029

1130
task :swig =>

test/flac_file_test.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ class FlacFileTest < Test::Unit::TestCase
3737

3838
should "contain basic information" do
3939
assert_equal 1, @properties.length
40-
assert_equal 212, @properties.bitrate
40+
41+
# taglib/taglib#557 changed the way bitrate is calculated.
42+
if TagLib::TAGLIB_MAJOR_VERSION > 1 || (TagLib::TAGLIB_MAJOR_VERSION == 1 && TagLib::TAGLIB_MINOR_VERSION >= 10)
43+
assert_equal 209, @properties.bitrate
44+
else
45+
assert_equal 212, @properties.bitrate
46+
end
47+
4148
assert_equal 44100, @properties.sample_rate
4249
assert_equal 1, @properties.channels
4350
end

test/id3v2_tag_test.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,20 @@ class TestID3v2Tag < Test::Unit::TestCase
4444
end
4545

4646
should "have nil for string attributes" do
47-
assert_nil @tag.title
48-
assert_nil @tag.artist
49-
assert_nil @tag.album
50-
assert_nil @tag.comment
51-
assert_nil @tag.genre
47+
# taglib/taglib/8c6fe45: return an empty string instead of NULL
48+
if TagLib::TAGLIB_MAJOR_VERSION > 1 || (TagLib::TAGLIB_MAJOR_VERSION == 1 && TagLib::TAGLIB_MINOR_VERSION >= 11)
49+
assert_equal "", @tag.title
50+
assert_equal "", @tag.artist
51+
assert_equal "", @tag.album
52+
assert_equal "", @tag.comment
53+
assert_equal "", @tag.genre
54+
else
55+
assert_nil @tag.title
56+
assert_nil @tag.artist
57+
assert_nil @tag.album
58+
assert_nil @tag.comment
59+
assert_nil @tag.genre
60+
end
5261
end
5362

5463
should "have 0 for numeric attributes" do

test/mp4_file_test.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ class MP4FileTest < Test::Unit::TestCase
2929

3030
should "contain basic information" do
3131
assert_equal 1, @properties.length
32-
assert_equal 54, @properties.bitrate
32+
33+
# taglib/taglib#558 changed the way bitrate is calculated.
34+
if TagLib::TAGLIB_MAJOR_VERSION > 1 || (TagLib::TAGLIB_MAJOR_VERSION == 1 && TagLib::TAGLIB_MINOR_VERSION >= 10)
35+
assert_equal 55, @properties.bitrate
36+
else
37+
assert_equal 54, @properties.bitrate
38+
end
39+
3340
assert_equal 44100, @properties.sample_rate
3441
# The test file is mono, this appears to be a TagLib bug
3542
assert_equal 2, @properties.channels

0 commit comments

Comments
 (0)