Skip to content

Commit 057a803

Browse files
committed
Run the CI against various version of Taglib
Add Rake tasks to build various versions of Taglib. Get Travis to build Taglib in the before_script step. Update some unit tests to reflect some changes in taglib.
1 parent ceaeee4 commit 057a803

File tree

7 files changed

+101
-36
lines changed

7 files changed

+101
-36
lines changed

.travis.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
language: ruby
2-
rvm:
3-
- 2.2.7
4-
- 2.3.4
5-
- 2.4.1
6-
addons:
7-
apt:
8-
packages:
9-
- libtag1-dev
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: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,19 @@ Build and install gem into system gems:
9595

9696
rake install
9797

98-
The `swig` and `compile` rake tasks can use the `TAGLIB_DIR` environment
99-
variable to build against non-standard taglib installations. It is assumed
100-
that taglib headers are located at `$TAGLIB_DIR/include` and taglib libraries
101-
at `$TAGLIB_DIR/lib`. To run taglib-ruby with non-standard taglib
102-
installations, use the `LD_LIBRARY_PATH` env. variable.
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
103111

104112
### Workflow
105113

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

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

test/vorbis_file_test.rb

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

2424
should "contain basic information" do
2525
assert_equal 0, @properties.length # file is short
26-
assert_equal 64, @properties.bitrate
26+
27+
# taglib/taglib#563 changed the way bitrate is calculated.
28+
if TagLib::TAGLIB_MAJOR_VERSION > 1 || (TagLib::TAGLIB_MAJOR_VERSION == 1 && TagLib::TAGLIB_MINOR_VERSION >= 10)
29+
assert_equal 222, @properties.bitrate
30+
else
31+
assert_equal 64, @properties.bitrate
32+
end
33+
2734
assert_equal 44100, @properties.sample_rate
2835
assert_equal 2, @properties.channels
2936
end

0 commit comments

Comments
 (0)