diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d79707..330962c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -52,7 +53,7 @@ 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 @@ -60,10 +61,13 @@ jobs: 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 @@ -71,6 +75,8 @@ jobs: 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 diff --git a/ext/taglib_aiff/taglib_aiff_wrap.cxx b/ext/taglib_aiff/taglib_aiff_wrap.cxx index 255fa0b..360014a 100644 --- a/ext/taglib_aiff/taglib_aiff_wrap.cxx +++ b/ext/taglib_aiff/taglib_aiff_wrap.cxx @@ -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; diff --git a/ext/taglib_base/taglib_base_wrap.cxx b/ext/taglib_base/taglib_base_wrap.cxx index 921ddc9..8255935 100644 --- a/ext/taglib_base/taglib_base_wrap.cxx +++ b/ext/taglib_base/taglib_base_wrap.cxx @@ -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; @@ -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; diff --git a/ext/taglib_flac/taglib_flac_wrap.cxx b/ext/taglib_flac/taglib_flac_wrap.cxx index 9ba658d..f1564d8 100644 --- a/ext/taglib_flac/taglib_flac_wrap.cxx +++ b/ext/taglib_flac/taglib_flac_wrap.cxx @@ -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; diff --git a/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx b/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx index 13fd608..f0046c4 100644 --- a/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +++ b/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx @@ -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; diff --git a/ext/taglib_id3v1/taglib_id3v1_wrap.cxx b/ext/taglib_id3v1/taglib_id3v1_wrap.cxx index 93543a1..56f78de 100644 --- a/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +++ b/ext/taglib_id3v1/taglib_id3v1_wrap.cxx @@ -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; @@ -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; diff --git a/ext/taglib_id3v2/taglib_id3v2_wrap.cxx b/ext/taglib_id3v2/taglib_id3v2_wrap.cxx index a08de3e..708f651 100644 --- a/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +++ b/ext/taglib_id3v2/taglib_id3v2_wrap.cxx @@ -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; @@ -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; @@ -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; diff --git a/ext/taglib_mp4/taglib_mp4_wrap.cxx b/ext/taglib_mp4/taglib_mp4_wrap.cxx index 9fdbd6e..b2e945a 100644 --- a/ext/taglib_mp4/taglib_mp4_wrap.cxx +++ b/ext/taglib_mp4/taglib_mp4_wrap.cxx @@ -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; @@ -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; @@ -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; diff --git a/ext/taglib_mpeg/taglib_mpeg_wrap.cxx b/ext/taglib_mpeg/taglib_mpeg_wrap.cxx index f1fa517..68ae96a 100644 --- a/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +++ b/ext/taglib_mpeg/taglib_mpeg_wrap.cxx @@ -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; diff --git a/ext/taglib_ogg/taglib_ogg_wrap.cxx b/ext/taglib_ogg/taglib_ogg_wrap.cxx index 9ad12e0..94079e8 100644 --- a/ext/taglib_ogg/taglib_ogg_wrap.cxx +++ b/ext/taglib_ogg/taglib_ogg_wrap.cxx @@ -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; @@ -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; diff --git a/ext/taglib_vorbis/taglib_vorbis_wrap.cxx b/ext/taglib_vorbis/taglib_vorbis_wrap.cxx index dcda389..40c5ad2 100644 --- a/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +++ b/ext/taglib_vorbis/taglib_vorbis_wrap.cxx @@ -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; diff --git a/ext/taglib_wav/taglib_wav_wrap.cxx b/ext/taglib_wav/taglib_wav_wrap.cxx index 0c452fc..a75a793 100644 --- a/ext/taglib_wav/taglib_wav_wrap.cxx +++ b/ext/taglib_wav/taglib_wav_wrap.cxx @@ -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; diff --git a/tasks/build.rb b/tasks/build.rb new file mode 100644 index 0000000..e57c056 --- /dev/null +++ b/tasks/build.rb @@ -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 diff --git a/tasks/ext.rake b/tasks/ext.rake index b86eaef..1eae3d6 100644 --- a/tasks/ext.rake +++ b/tasks/ext.rake @@ -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', @@ -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' @@ -75,37 +68,38 @@ 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}" @@ -113,5 +107,3 @@ file "#{tmp}/#{taglib}.tar.gz" => [tmp] do |t| IO.copy_stream(URI.open(taglib_url), f) end end - -directory tmp diff --git a/tasks/swig.rake b/tasks/swig.rake index 50d5cf4..5954831 100644 --- a/tasks/swig.rake +++ b/tasks/swig.rake @@ -1,5 +1,7 @@ # frozen-string-literal: true +require_relative 'build' + # Tasks for generating SWIG wrappers in ext # Execute SWIG for the specified extension. @@ -11,9 +13,11 @@ 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']) @@ -21,14 +25,20 @@ def run_swig(mod) 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',