Skip to content

Commit

Permalink
Merge pull request #10 from djberg96/file_offset_bits
Browse files Browse the repository at this point in the history
Add libs and DEF to command.
  • Loading branch information
djberg96 authored Sep 14, 2024
2 parents d526328 + 960451a commit c542c18
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
test:
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.7.0 - 13-Sep-2024
* Append typical library switches to the compiler command. There was a private
method already in the code but I wasn't using it.
* Append DEFS if present in your RbConfig options. This was mainly to ensure
that FILE_OFFSET_BITS is passed, if present, but there could be other
macros in theory.

## 0.6.0 - 26-Sep-2023
* Added the memoist gem and memoized the results of all public methods since
the odds of them changing between calls is basically zero.
Expand Down
20 changes: 12 additions & 8 deletions lib/mkmf/lite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ module Lite
extend Memoist

# The version of the mkmf-lite library
MKMF_LITE_VERSION = '0.6.0'
MKMF_LITE_VERSION = '0.7.0'

private

def cpp_defs
RbConfig::CONFIG['DEFS']
end

# rubocop:disable Layout/LineLength
def cpp_command
command = RbConfig::CONFIG['CC'] || RbConfig::CONFIG['CPP'] || File.which('cc') || File.which('gcc') || File.which('cl')
Expand All @@ -44,11 +48,11 @@ def cpp_out_file

memoize :cpp_out_file

# TODO: We should adjust this based on OS. For now we're using
# arguments I think you'll typically see set on Linux and BSD.
def cpp_libraries
if RbConfig::CONFIG['LIBS']
RbConfig::CONFIG['LIBS'] + RbConfig::CONFIG['LIBRUBYARG']
return if File::ALT_SEPARATOR && RbConfig::CONFIG['CPP'] =~ /^cl/

if cpp_command =~ /clang/i
'-Lrt -Ldl -Lcrypt -Lm'
else
'-lrt -ldl -lcrypt -lm'
end
Expand Down Expand Up @@ -205,7 +209,7 @@ def try_to_execute(code)
Dir.chdir(Dir.tmpdir) do
File.write(cpp_source_file, code)

command = "#{cpp_command} "
command = "#{cpp_command} #{cpp_libraries} #{cpp_defs} "
command += "#{cpp_out_file} "
command += cpp_source_file

Expand Down Expand Up @@ -254,9 +258,9 @@ def try_to_compile(code, command_options = nil)
File.write(cpp_source_file, code)

if command_options
command = "#{cpp_command} #{command_options} "
command = "#{cpp_command} #{command_options} #{cpp_libraries} #{cpp_defs} "
else
command = "#{cpp_command} "
command = "#{cpp_command} #{cpp_libraries} #{cpp_defs} "
end

command += "#{cpp_out_file} "
Expand Down
2 changes: 1 addition & 1 deletion mkmf-lite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'rubygems'
Gem::Specification.new do |spec|
spec.name = 'mkmf-lite'
spec.summary = 'A lighter version of mkmf designed for use as a library'
spec.version = '0.6.0'
spec.version = '0.7.0'
spec.author = 'Daniel J. Berger'
spec.license = 'Apache-2.0'
spec.email = '[email protected]'
Expand Down
2 changes: 1 addition & 1 deletion spec/mkmf_lite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

describe 'constants' do
example 'version information' do
expect(described_class::MKMF_LITE_VERSION).to eq('0.6.0')
expect(described_class::MKMF_LITE_VERSION).to eq('0.7.0')
expect(described_class::MKMF_LITE_VERSION).to be_frozen
end
end
Expand Down

0 comments on commit c542c18

Please sign in to comment.