Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- '3.3'
- '3.4'
- '4.0'
- 'jruby-10.0'

steps:
- name: Checkout
Expand All @@ -35,17 +36,25 @@ jobs:
go-version-file: go/go.mod
cache-dependency-path: go/go.sum

- name: Build Go Library
- name: Build Go Library (C archive)
if: ${{ !startsWith(matrix.ruby, 'jruby') }}
run: bundle exec rake go:build

- name: Build Go Library (shared)
if: ${{ startsWith(matrix.ruby, 'jruby') }}
run: bundle exec rake go:build_shared

- name: Compile Native Extension
if: ${{ !startsWith(matrix.ruby, 'jruby') }}
run: bundle exec rake compile

- name: Run tests
run: bundle exec rake test

- name: Run steep check
if: ${{ !startsWith(matrix.ruby, 'jruby') }}
run: bundle exec steep check

- name: Run rubocop
if: ${{ !startsWith(matrix.ruby, 'jruby') }}
run: bundle exec rubocop
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gemspec

gem "ffi", platform: :jruby
gem "irb"
gem "maxitest", "~> 7.0"
gem "rake", "~> 13.0"
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
ffi
irb
lipgloss!
maxitest (~> 7.0)
Expand Down
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ begin
end
end

desc "Build Go shared library for current platform"
task :build_shared do
platform = detect_go_platform
output_dir = "go/build/#{platform}"
FileUtils.mkdir_p(output_dir)

ext = RbConfig::CONFIG["host_os"] =~ /darwin/ ? "dylib" : "so"
sh "cd go && CGO_ENABLED=1 go build -buildmode=c-shared -o build/#{platform}/liblipgloss.#{ext} ."
end

desc "Clean Go build artifacts"
task :clean do
FileUtils.rm_rf("go/build")
Expand Down
14 changes: 9 additions & 5 deletions lib/lipgloss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

require_relative "lipgloss/version"

begin
major, minor, _patch = RUBY_VERSION.split(".") #: [String, String, String]
require_relative "lipgloss/#{major}.#{minor}/lipgloss"
rescue LoadError
require_relative "lipgloss/lipgloss"
if RUBY_ENGINE == "jruby"
require_relative "lipgloss/ffi_bindings"
else
begin
major, minor, _patch = RUBY_VERSION.split(".") #: [String, String, String]
require_relative "lipgloss/#{major}.#{minor}/lipgloss"
rescue LoadError
require_relative "lipgloss/lipgloss"
end
end

require_relative "lipgloss/position"
Expand Down
Loading
Loading