diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1d901df..01fecdee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,11 +8,18 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', '3.2', '3.3'] # 3.4+ is not yet supported by google-protobuf + ruby: + - '2.7' + - '3.0' + - '3.1' + - '3.2' + - '3.3' + # Note: 3.4+ is not yet supported by google-protobuf + - '3.4.0-rc1' os: ['ubuntu-latest', 'windows-latest'] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -21,4 +28,4 @@ jobs: run: bundle exec rake test - name: RuboCop run: bundle exec rake lint - if: matrix.ruby != '3.1' && matrix.ruby != '3.2' && matrix.ruby != '3.3' + if: matrix.ruby != '3.1' && matrix.ruby != '3.2' && matrix.ruby != '3.3' && matrix.ruby != '3.4.0-rc1' diff --git a/ext/pg_query/extconf.rb b/ext/pg_query/extconf.rb index cf7feb51..9739f27c 100644 --- a/ext/pg_query/extconf.rb +++ b/ext/pg_query/extconf.rb @@ -21,12 +21,36 @@ $INCFLAGS = "-I#{File.join(__dir__, 'include', 'postgres', 'port', 'win32_msvc')} " + $INCFLAGS end -SYMFILE = - if RUBY_PLATFORM =~ /freebsd/ - File.join(__dir__, 'pg_query_ruby_freebsd.sym') +def have_ruby_abi_version() + # ruby_abi_version is only available in development versions: https://github.com/ruby/ruby/pull/6231 + return false if RUBY_PATCHLEVEL >= 0 + + m = /(\d+)\.(\d+)/.match(RUBY_VERSION) + if m.nil? + puts "Failed to parse ruby version: #{RUBY_VERSION}. Assuming ruby_abi_version symbol is NOT present." + return false + end + major = m[1].to_i + minor = m[2].to_i + if major >= 3 and minor >= 2 + puts "Ruby version #{RUBY_VERSION} >= 3.2. Assuming ruby_abi_version symbol is present." + return true + end + puts "Ruby version #{RUBY_VERSION} < 3.2. Assuming ruby_abi_version symbol is NOT present." + false +end + +def ext_export_filename() + name = if RUBY_PLATFORM =~ /freebsd/ + 'pg_query_ruby_freebsd' elsif RUBY_PLATFORM !~ /cygwin|mswin|mingw|bccwin|wince|emx/ - File.join(__dir__, 'pg_query_ruby.sym') + 'pg_query_ruby' end + name += '-with-ruby-abi-version' if have_ruby_abi_version() + "#{name}.sym" +end + +SYMFILE = File.join(__dir__, ext_export_filename()) if RUBY_PLATFORM =~ /darwin/ $DLDFLAGS << " -Wl,-exported_symbols_list #{SYMFILE}" unless defined?(::Rubinius) diff --git a/ext/pg_query/pg_query_ruby-with-ruby-abi-version.sym b/ext/pg_query/pg_query_ruby-with-ruby-abi-version.sym new file mode 100644 index 00000000..05fcbdf4 --- /dev/null +++ b/ext/pg_query/pg_query_ruby-with-ruby-abi-version.sym @@ -0,0 +1,2 @@ +_Init_pg_query +_ruby_abi_version diff --git a/ext/pg_query/pg_query_ruby_freebsd-with-ruby-abi-version.sym b/ext/pg_query/pg_query_ruby_freebsd-with-ruby-abi-version.sym new file mode 100644 index 00000000..ba6b96f8 --- /dev/null +++ b/ext/pg_query/pg_query_ruby_freebsd-with-ruby-abi-version.sym @@ -0,0 +1,2 @@ +Init_pg_query +_ruby_abi_version