Skip to content

Commit

Permalink
Merge pull request #145 from robinst/taglib-2-merge-main
Browse files Browse the repository at this point in the history
Update taglib-2 from main
  • Loading branch information
jacobvosmaer authored Apr 11, 2024
2 parents 43f06d3 + b62ae40 commit c477cf8
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 55 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
key: swig-${{ matrix.os }}-v4.1.1

- name: Install SWIG v4.1.1
if: steps.cache-swig.outputs.cache-hit != 'true'
run: |
sudo apt install yodl
git clone --depth 1 --branch v4.1.1 https://github.com/swig/swig.git
Expand All @@ -52,25 +53,30 @@ jobs:
- name: Bundle Install
run: |
gem install bundler
gem install bundler -v 2.4.22
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Cache TagLib (C++)
id: cache-taglib
uses: actions/cache@v2
with:
path: tmp/${{ env.PLATFORM }}/taglib-${{ env.TAGLIB_VERSION }}
key: taglib-${{ matrix.os }}-v${{ env.TAGLIB_VERSION }}
path: |
tmp/${{ env.PLATFORM }}/taglib-${{ env.TAGLIB_VERSION }}
tmp/taglib-${{ env.TAGLIB_VERSION }}.tar.gz
key: taglib-${{ matrix.os }}-v${{ env.TAGLIB_VERSION }}-cache.v3

- name: Install TagLib (C++)
if: steps.cache-taglib.outputs.cache-hit != 'true'
run: bundle exec rake vendor

- name: Generate SWIG Wrappers
run: |
touch ext/*/*.i
export PATH=$HOME/$SWIG_DIR/bin:$PATH
TAGLIB_DIR=$PWD/tmp/$PLATFORM/taglib-$TAGLIB_VERSION bundle exec rake swig
echo 'Checking for changes (there should be none)'
git diff --exit-code
- name: Compile (taglib-ruby)
run: TAGLIB_DIR=$PWD/tmp/$PLATFORM/taglib-$TAGLIB_VERSION bundle exec rake compile
Expand Down
2 changes: 1 addition & 1 deletion ext/taglib_aiff/taglib_aiff_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
4 changes: 2 additions & 2 deletions ext/taglib_base/taglib_base_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2223,7 +2223,7 @@ SWIG_From_bool (bool value)
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
2 changes: 1 addition & 1 deletion ext/taglib_flac/taglib_flac_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
2 changes: 1 addition & 1 deletion ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
4 changes: 2 additions & 2 deletions ext/taglib_id3v1/taglib_id3v1_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2185,7 +2185,7 @@ SWIG_From_unsigned_SS_int (unsigned int value)
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
6 changes: 3 additions & 3 deletions ext/taglib_id3v2/taglib_id3v2_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2299,7 +2299,7 @@ SWIG_From_bool (bool value)
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2451,7 +2451,7 @@ inline int SWIG_isfinite_func(T x) {
#endif


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
6 changes: 3 additions & 3 deletions ext/taglib_mp4/taglib_mp4_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2271,7 +2271,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)



/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2355,7 +2355,7 @@ SWIG_AsVal_unsigned_SS_char (VALUE obj, unsigned char *val)


#ifdef SWIG_LONG_LONG_AVAILABLE
/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LL(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
2 changes: 1 addition & 1 deletion ext/taglib_mpeg/taglib_mpeg_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
4 changes: 2 additions & 2 deletions ext/taglib_ogg/taglib_ogg_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down Expand Up @@ -2226,7 +2226,7 @@ SWIG_From_unsigned_SS_int (unsigned int value)
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
2 changes: 1 addition & 1 deletion ext/taglib_vorbis/taglib_vorbis_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
2 changes: 1 addition & 1 deletion ext/taglib_wav/taglib_wav_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
}


/*@SWIG:/usr/local/Cellar/swig/4.1.1/share/swig/4.1.1/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
/*@SWIG:/swig/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE arg)
{
VALUE *args = (VALUE *)arg;
Expand Down
45 changes: 45 additions & 0 deletions tasks/build.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen-string-literal: true

class Build
class << self
def plat
ENV['PLATFORM'] || 'i386-mingw32'
end

def version
ENV['TAGLIB_VERSION'] || '1.11.1'
end

def dir
"taglib-#{version}"
end

def tmp
"#{__dir__}/../tmp"
end

def source
"#{tmp}/#{dir}"
end

def tarball
"#{source}.tar.gz"
end

def tmp_arch
"#{tmp}/#{plat}"
end

def install_dir
"#{tmp_arch}/#{dir}"
end

def build_dir
"#{install_dir}-build"
end

def library
"#{install_dir}/lib/libtag.#{RbConfig::CONFIG['SOEXT']}"
end
end
end
52 changes: 22 additions & 30 deletions tasks/ext.rake
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
# frozen-string-literal: true

require_relative 'build'

# Extension tasks and cross-compiling

host = 'i686-w64-mingw32'
$plat = ENV['PLATFORM'] || 'i386-mingw32'

taglib_version = ENV['TAGLIB_VERSION'] || '1.9.1'
taglib = "taglib-#{taglib_version}"

tmp = "#{Dir.pwd}/tmp"
tmp_arch = "#{tmp}/#{$plat}"
toolchain_file = "#{Dir.pwd}/ext/win.cmake"
install_dir = "#{tmp_arch}/#{taglib}"
install_dll = "#{install_dir}/bin/libtag.dll"
install_so = "#{install_dir}/lib/libtag.so"
$cross_config_options = ["--with-opt-dir=#{install_dir}"]
install_dll = "#{Build.install_dir}/bin/libtag.dll"
$cross_config_options = ["--with-opt-dir=#{Build.install_dir}"]

taglib_url = "https://github.com/taglib/taglib/archive/v#{taglib_version}.tar.gz"
taglib_url = "https://github.com/taglib/taglib/archive/v#{Build.version}.tar.gz"
taglib_options = ['-DCMAKE_BUILD_TYPE=Release',
'-DBUILD_EXAMPLES=OFF',
'-DBUILD_TESTS=OFF',
Expand All @@ -27,7 +20,7 @@ taglib_options = ['-DCMAKE_BUILD_TYPE=Release',

def configure_cross_compile(ext)
ext.cross_compile = true
ext.cross_platform = $plat
ext.cross_platform = Build.plat
ext.cross_config_options.concat($cross_config_options)
ext.cross_compiling do |gem|
gem.files << 'lib/libtag.dll'
Expand Down Expand Up @@ -75,43 +68,42 @@ task :cross do
ENV['CXX'] = "#{host}-g++"
end

file "#{tmp_arch}/stage/lib/libtag.dll" => [install_dll] do |f|
file "#{Build.tmp_arch}/stage/lib/libtag.dll" => [install_dll] do |f|
install install_dll, f
end

file install_dll => ["#{tmp}/#{taglib}"] do
chdir "#{tmp}/#{taglib}" do
sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file} #{taglib_options})
file install_dll => [Build.source] do
chdir Build.source do
sh %(cmake -DCMAKE_INSTALL_PREFIX=#{Build.install_dir} -DCMAKE_TOOLCHAIN_FILE=#{toolchain_file} #{taglib_options})
sh 'make VERBOSE=1'
sh 'make install'
end
end

task vendor: [install_so]
task vendor: [Build.library]

file install_so => ["#{tmp_arch}/#{taglib}", "#{tmp_arch}/#{taglib}-build", "#{tmp}/#{taglib}"] do
chdir "#{tmp_arch}/#{taglib}-build" do
sh %(cmake -DCMAKE_INSTALL_PREFIX=#{install_dir} #{taglib_options} #{tmp}/#{taglib})
sh 'make install VERBOSE=1'
file Build.library => [Build.install_dir, Build.build_dir, Build.source] do
chdir Build.build_dir do
sh %(cmake -DCMAKE_INSTALL_PREFIX=#{Build.install_dir} #{taglib_options} #{Build.source})
sh 'make install -j 4 VERBOSE=1'
end
end

directory "#{tmp_arch}/#{taglib}"
directory "#{tmp_arch}/#{taglib}-build"
directory Build.install_dir
directory Build.build_dir
directory Build.tmp

file "#{tmp}/#{taglib}" => ["#{tmp}/#{taglib}.tar.gz"] do
chdir tmp do
sh "tar xzf #{taglib}.tar.gz"
file Build.source => [Build.tarball] do
chdir Build.tmp do
sh "tar xzf #{Build.tarball}"
end
end

file "#{tmp}/#{taglib}.tar.gz" => [tmp] do |t|
file Build.tarball => [Build.tmp] do |t|
require 'open-uri'
puts "Downloading #{taglib_url}"

File.open(t.name, 'wb') do |f|
IO.copy_stream(URI.open(taglib_url), f)
end
end

directory tmp
18 changes: 14 additions & 4 deletions tasks/swig.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen-string-literal: true

require_relative 'build'

# Tasks for generating SWIG wrappers in ext

# Execute SWIG for the specified extension.
Expand All @@ -11,24 +13,32 @@
def run_swig(mod)
swig = `which swig`.chomp
swig = `which swig2.0`.chomp if swig.empty?
swiglib = `swig -swiglib`.chomp
abort 'swig failed' unless $?.success?

# Standard search location for headers
include_args = %w[-I/usr/local/include -I/usr/include]
include_args = "-I#{Build.install_dir}/include"

if ENV.key?('TAGLIB_DIR')
unless File.directory?(ENV['TAGLIB_DIR'])
abort 'When defined, the TAGLIB_DIR environment variable must point to a valid directory.'
end

# Push it in front to get it searched first.
include_args.unshift("-I#{ENV['TAGLIB_DIR']}/include")
include_args = "-I#{ENV['TAGLIB_DIR']}/include"
end

sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} #{include_args.join(' ')} #{mod}.i"
Dir.chdir("ext/#{mod}") do
sh "#{swig} -c++ -ruby -autorename -initname #{mod} #{include_args} #{mod}.i"
wrap = "#{mod}_wrap.cxx"
wrapdata = File.read(wrap)
File.write(wrap, wrapdata.gsub(swiglib, '/swig'))
end
end

task swig:
['ext/taglib_base/taglib_base_wrap.cxx',
[Build.library,
'ext/taglib_base/taglib_base_wrap.cxx',
'ext/taglib_mpeg/taglib_mpeg_wrap.cxx',
'ext/taglib_id3v1/taglib_id3v1_wrap.cxx',
'ext/taglib_id3v2/taglib_id3v2_wrap.cxx',
Expand Down

0 comments on commit c477cf8

Please sign in to comment.