私は、C から構築されたバイナリに依存する Ruby コードを持っています。通常、バックティックを使用してバイナリを呼び出します。しかし、今では Warbler を使用して Ruby コードを jar にパッケージ化すると、どうすればバイナリにアクセスできるのかわかりません。
私のコード構造は次のようになります。
root/
|--bin/
|--exec.rb #This is the executable when I call java -jar example.jar
|--lib/
|--Module1.rb #This dir contains all the ruby modules my code requires
|--ext/
|--a.out #A binary compiled with gcc
|--.gemspec #A file to guide warbler into building this structure into a jar
以前warble
は、この構造全体を jar に構築していました。Ruby ではa.out
、exec.rb の次のステートメントを介してmy にアクセスできます。
exec = "#{File.expand_path(File.join(File.dirname(File.dirname(__FILE__)), 'ext'))}/a.out}";
`exec`
しかし、jar としてパッケージ化されたこのコードを試すと、次のエラーが発生します。
/bin/sh: file:/path/to/my/jar/example.jar!/root/ext/a.out: not found
では、jar にパッケージ化された実行可能ファイルにアクセスするにはどうすればよいでしょうか。