Skip to content
Merged
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 @@ -22,3 +22,4 @@ THIRD_PARTY_LICENSES.html
rust/THIRD_PARTY_LICENSES.html
lib/rubydex/*.dylib
lib/rubydex/*.so
lib/rubydex/bin/
17 changes: 17 additions & 0 deletions exe/rubydex_mcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "rbconfig"

host_os = RbConfig::CONFIG.fetch("host_os")
executable = host_os.match?(/mswin|mingw|cygwin/) ? "rubydex_mcp.exe" : "rubydex_mcp"
binary = File.expand_path("../lib/rubydex/bin/#{executable}", __dir__)

unless File.executable?(binary)
abort(<<~MESSAGE.chomp)
rubydex_mcp is not available at #{binary}.
Install a precompiled rubydex gem, or reinstall rubydex with Cargo available so the MCP executable can be built locally.
MESSAGE
end

exec(binary, *ARGV)
8 changes: 8 additions & 0 deletions ext/rubydex/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "mkmf"
require "fileutils"
require "pathname"

unless system("cargo", "--version", out: File::NULL, err: File::NULL)
Expand Down Expand Up @@ -81,6 +82,12 @@
end

lib_dir = gem_dir.join("lib").join("rubydex")
mcp_bin_dir = lib_dir.join("bin")
FileUtils.mkdir_p(mcp_bin_dir)

mcp_executable = Gem.win_platform? ? "rubydex_mcp.exe" : "rubydex_mcp"
mcp_src = target_dir.join(mcp_executable)
mcp_dst = mcp_bin_dir.join(mcp_executable)

copy_dylib_commands = if Gem.win_platform?
""
Expand All @@ -107,6 +114,7 @@
.rust_built: $(RUST_SRCS)
\t#{cargo_command} || (echo "Compiling Rust failed" && exit 1)
\t$(COPY) #{bindings_path} #{__dir__}
\t$(COPY) #{mcp_src} #{mcp_dst}
\ttouch $@

compile_rust: .rust_built
Expand Down
1 change: 1 addition & 0 deletions rubydex.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Gem::Specification.new do |spec|

if ENV["RELEASE"]
spec.files << "THIRD_PARTY_LICENSES.html"
spec.files << "lib/rubydex/bin/#{Gem.win_platform? ? "rubydex_mcp.exe" : "rubydex_mcp"}"
if RUBY_PLATFORM.include?("darwin")
spec.files << "lib/rubydex/librubydex_sys.dylib"
elsif RUBY_PLATFORM.include?("linux")
Expand Down
Loading