Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JRuby supoort by copy all binary exectuables on pure Ruby platform #38

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/pkg
/exe/
!/exe/thrust
.DS_Store
10 changes: 7 additions & 3 deletions exe/thrust
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#! /usr/bin/env ruby

PLATFORM = [ :cpu, :os ].map { |m| Gem::Platform.local.send(m) }.join("-")
EXECUTABLE = File.expand_path(File.join(__dir__, PLATFORM, "thrust"))
EXECUTE_PLATFORM = if RUBY_PLATFORM == 'java'
%w[target_cpu target_os].map { |m| RbConfig::CONFIG[m] }.join("-").gsub('-musl','')
else
[ :cpu, :os ].map { |m| Gem::Platform.local.send(m) }.join("-")
end
EXECUTABLE = File.expand_path(File.join(__dir__, EXECUTE_PLATFORM, "thrust"))

if File.exist?(EXECUTABLE)
exec(EXECUTABLE, *ARGV)
else
STDERR.puts("ERROR: Unsupported platform: #{PLATFORM}")
STDERR.puts("ERROR: Unsupported platform: #{EXECUTE_PLATFORM}")
exit 1
end
19 changes: 18 additions & 1 deletion rakelib/package.rake
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ namespace :build do
end
task :gem => "build:native"


NATIVE_PLATFORMS.each do |platform, executable|
BASE_GEMSPEC.dup.tap do |gemspec|
exedir = File.join(gemspec.bindir, platform)
exepath = File.join(exedir, "thrust")

gemspec.platform = platform
gemspec.files << exepath

gem_path = Gem::PackageTask.new(gemspec).define
desc "Build the #{platform} gem"
task "gem:#{platform}" => [gem_path]
Expand All @@ -43,4 +43,21 @@ NATIVE_PLATFORMS.each do |platform, executable|
end
end

gemspec = BASE_GEMSPEC.dup
exe_paths = NATIVE_PLATFORMS.map do |native_platform, native_executable|
exedir = File.join(gemspec.bindir, native_platform)
exepath = File.join(exedir, "thrust")
directory exedir
file exepath => [ exedir ] do
FileUtils.cp native_executable, exepath
FileUtils.chmod(0755, exepath )
end
exepath
end
gemspec.files += exe_paths
gemspec.platform = 'java'
gem_path = Gem::PackageTask.new(gemspec).define
desc "Build the java gem"
task "gem:java" => [gem_path]

CLOBBER.add("dist")
6 changes: 6 additions & 0 deletions thruster.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ Gem::Specification.new do |s|
"homepage_uri" => s.homepage,
"rubygems_mfa_required" => "true"
}


s.files = Dir[ "{lib}/**/*", "MIT-LICENSE", "README.md" ]
s.bindir = "exe"
if RUBY_PLATFORM =~ /java/
s.platform = 'java'
s.files + ["exe/aarch64-linux/thrust", "exe/arm64-darwin/thrust", "exe/x86_64-darwin/thrust", "exe/x86_64-linux/thrust"]
end

s.executables << "thrust"
end