@@ -22,7 +22,8 @@ require "json"
2222Gem ::Specification . new do |spec |
2323 spec . name = "opendal"
2424 # RubyGems integrates and expects `cargo`.
25- # Read more about [Gem::Ext::CargoBuilder](https://github.com/rubygems/rubygems/blob/v3.5.23/lib/rubygems/ext/cargo_builder.rb)
25+ # Read more about
26+ # [Gem::Ext::CargoBuilder](https://github.com/rubygems/rubygems/blob/v3.5.23/lib/rubygems/ext/cargo_builder.rb)
2627 #
2728 # OpenDAL relies on "version" in `Cargo.toml` for the release process. You can read this gem spec with:
2829 # `bundle exec ruby -e 'puts Gem::Specification.load("opendal.gemspec")'`
@@ -54,40 +55,35 @@ Gem::Specification.new do |spec|
5455 # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
5556 spec . files = Dir . chdir ( __dir__ ) do
5657 git_files = `git ls-files -z` . split ( "\x0 " ) . reject do |f |
57- ( File . expand_path ( f ) == __FILE__ ) || f . start_with? ( *%w[ gems/ pkg/ target/ tmp/ .git ] ) || f == "core"
58+ f . start_with? ( *%w[ gems/ pkg/ target/ tmp/ .git ] )
5859 end
5960
60- # Copy core directory
61- src = "../../core"
62- dst = "./core"
63- `cp -RL #{ src } #{ dst } `
61+ # When building release package, include core directory files for rake build
62+ core_dir = "../../core"
63+ distributed_core_dir = "core"
6464
65- # Include core directory files, excluding symlinks
66- core_files = Dir . chdir ( "./core" ) do
67- `git ls-files -z` . split ( "\x0 " ) . reject do |f |
68- File . symlink? ( File . join ( "./core" , f ) )
69- end . map { |f | "core/#{ f } " }
70- end
65+ if Dir . exist? ( distributed_core_dir )
66+ # Core files should already be copied by the Rakefile's copy_core task
67+ core_files = `git -C #{ File . expand_path ( core_dir , __dir__ ) } ls-files -z`
68+ . split ( "\x0 " )
69+ . filter_map do |f |
70+ full_path = "#{ distributed_core_dir } /#{ f } "
71+ full_path if File . exist? ( full_path )
72+ end
7173
72- # Resolve symlinks: copy actual files from their target locations
73- # This handles recursive symbol link cases. e.g., core/CHANGELOG.md -> ../CHANGELOG.md
74- symlink_targets = Dir . chdir ( "./core" ) do
75- `git ls-files -z` . split ( "\x0 " ) . select do |f |
76- File . symlink? ( File . join ( "./core" , f ) )
77- end . filter_map do |f |
78- link_target = File . readlink ( File . join ( "./core" , f ) )
79- resolved_path = File . expand_path ( link_target , File . join ( __dir__ , "core" ) )
80- File . exist? ( resolved_path ) ? "core/#{ f } " : nil
81- end
74+ git_files + core_files
75+ else
76+ git_files
8277 end
83-
84- git_files + core_files + symlink_targets
8578 end
8679
8780 spec . require_paths = [ "lib" ]
8881
8982 spec . extensions = [ "./extconf.rb" ]
9083
84+ # Exclude non-Ruby files from RDoc to prevent parsing errors
85+ spec . rdoc_options = [ "--exclude" , "Cargo\\ ..*" , "--exclude" , "core/" , "--exclude" , "\\ .rs$" ]
86+
9187 spec . requirements = [ "Rust >= 1.85" ]
9288 # use a Ruby version which:
9389 # - supports Rubygems with the ability of compilation of Rust gem
0 commit comments