kanayago 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ --- patch/head/macos.patch
2
+ +++ patch/head/macos.patch
3
+ @@ -1,46 +0,0 @@
4
+ ---- a/ext/kanayago/ruby_parser.c
5
+ -+++ b/ext/kanayago/ruby_parser.c
6
+ -@@ -433,16 +433,21 @@
7
+ - return rb_stderr_tty_p();
8
+ - }
9
+ -
10
+ -+// Kanayago macOS: Use rb_reg_new_str instead of rb_reg_compile (not exported in Ruby head)
11
+ - static VALUE
12
+ - reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
13
+ - {
14
+ -- return rb_reg_compile(str, options, sourcefile, sourceline);
15
+ -+ (void)sourcefile;
16
+ -+ (void)sourceline;
17
+ -+ return rb_reg_new_str(str, options);
18
+ - }
19
+ -
20
+ -+// Kanayago macOS: Return Qnil instead of calling rb_reg_check_preprocess (not exported in Ruby head)
21
+ - static VALUE
22
+ - reg_check_preprocess(VALUE val)
23
+ - {
24
+ -- return rb_reg_check_preprocess(val);
25
+ -+ (void)val;
26
+ -+ return Qnil;
27
+ - }
28
+ - // End of Add for Kanayago
29
+ -
30
+ -@@ -985,7 +990,8 @@
31
+ - VALUE
32
+ - rb_str_new_parser_string(rb_parser_string_t *str)
33
+ - {
34
+ -- VALUE string = rb_enc_literal_str(str->ptr, str->len, str->enc);
35
+ -+ // Kanayago macOS: Use rb_enc_str_new instead of rb_enc_literal_str (not exported in Ruby head)
36
+ -+ VALUE string = rb_enc_str_new(str->ptr, str->len, str->enc);
37
+ - rb_enc_str_coderange(string);
38
+ - return string;
39
+ - }
40
+ -@@ -1167,7 +1173,8 @@
41
+ - rb_parser_string_t *string = node_reg->string;
42
+ - VALUE str = rb_enc_str_new(string->ptr, string->len, string->enc);
43
+ -
44
+ -- return rb_reg_compile(str, node_reg->options, NULL, 0);
45
+ -+ // Kanayago macOS: Use rb_reg_new_str instead of rb_reg_compile
46
+ -+ return rb_reg_new_str(str, node_reg->options);
47
+ - }
48
+ -
49
+ - VALUE
@@ -33,16 +33,33 @@ module KanayagoSetup
33
33
  private
34
34
 
35
35
  def detect_ruby_version
36
- if RUBY_DESCRIPTION.include?('dev')
36
+ # Ruby head (master branch) has 'dev' in description but not a release version
37
+ # Ruby 3.4.0 also had 'dev' in its preview/rc releases, so check RUBY_VERSION
38
+ if RUBY_DESCRIPTION.include?('dev') && !RUBY_VERSION.start_with?('3.4')
37
39
  'head'
38
40
  else
39
- RUBY_VERSION[0..2]
41
+ # Try exact version first (e.g., "3.4.1"), fallback to major.minor (e.g., "3.4")
42
+ exact_version = RUBY_VERSION
43
+ major_minor = RUBY_VERSION[0..2]
44
+
45
+ patch_dir = File.expand_path('../patch', __dir__)
46
+ if Dir.exist?(File.join(patch_dir, exact_version))
47
+ exact_version
48
+ else
49
+ major_minor
50
+ end
40
51
  end
41
52
  end
42
53
 
43
54
  def load_copy_targets(version)
55
+ # Try exact version first, then fallback to major.minor
44
56
  copy_target_path = File.expand_path("../patch/#{version}/copy_target.rb", __dir__)
45
57
 
58
+ unless File.exist?(copy_target_path)
59
+ fallback_version = version[0..2]
60
+ copy_target_path = File.expand_path("../patch/#{fallback_version}/copy_target.rb", __dir__)
61
+ end
62
+
46
63
  raise "Copy target file not found: #{copy_target_path}" unless File.exist?(copy_target_path)
47
64
 
48
65
  require copy_target_path
@@ -54,7 +71,9 @@ module KanayagoSetup
54
71
  tar_name = if version == 'head'
55
72
  'snapshot/snapshot-master.tar.gz'
56
73
  else
57
- "#{version}/ruby-#{RUBY_VERSION}.tar.gz"
74
+ # Use major.minor for directory path (e.g., "3.4")
75
+ major_minor = RUBY_VERSION[0..2]
76
+ "#{major_minor}/ruby-#{RUBY_VERSION}.tar.gz"
58
77
  end
59
78
 
60
79
  # Get project root directory
@@ -127,8 +146,26 @@ module KanayagoSetup
127
146
  Dir.chdir(project_root) do
128
147
  system("patch -p1 < #{patch_file}") ||
129
148
  raise('Failed to apply patch')
149
+
150
+ # Apply macOS-specific patch if on macOS
151
+ apply_macos_patch(version)
130
152
  end
131
153
  end
154
+
155
+ def apply_macos_patch(version)
156
+ return unless macos?
157
+
158
+ macos_patch_file = File.expand_path("../patch/#{version}/macos.patch", __dir__)
159
+ return unless File.exist?(macos_patch_file)
160
+
161
+ puts "Applying macOS-specific patch for Ruby #{version}..."
162
+ system("patch -p1 < #{macos_patch_file}") ||
163
+ raise('Failed to apply macOS patch')
164
+ end
165
+
166
+ def macos?
167
+ RUBY_PLATFORM.include?('darwin')
168
+ end
132
169
  end
133
170
  end
134
171
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanayago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - S-H-GAMELINKS
@@ -71,10 +71,33 @@ files:
71
71
  - lib/kanayago/string_node.rb
72
72
  - lib/kanayago/variable_node.rb
73
73
  - lib/kanayago/version.rb
74
+ - patch/3.4.0/copy_target.rb
75
+ - patch/3.4.0/kanayago.patch
76
+ - patch/3.4.1/copy_target.rb
77
+ - patch/3.4.1/kanayago.patch
78
+ - patch/3.4.2/copy_target.rb
79
+ - patch/3.4.2/kanayago.patch
80
+ - patch/3.4.3/copy_target.rb
81
+ - patch/3.4.3/kanayago.patch
82
+ - patch/3.4.4/copy_target.rb
83
+ - patch/3.4.4/kanayago.patch
84
+ - patch/3.4.5/copy_target.rb
85
+ - patch/3.4.5/kanayago.patch
86
+ - patch/3.4.6/copy_target.rb
87
+ - patch/3.4.6/kanayago.patch
88
+ - patch/3.4.7/copy_target.rb
89
+ - patch/3.4.7/kanayago.patch
90
+ - patch/3.4.8/copy_target.rb
91
+ - patch/3.4.8/kanayago.patch
74
92
  - patch/3.4/copy_target.rb
75
93
  - patch/3.4/kanayago.patch
94
+ - patch/4.0.0/copy_target.rb
95
+ - patch/4.0.0/kanayago.patch
96
+ - patch/4.0.0/macos.patch
76
97
  - patch/head/copy_target.rb
77
98
  - patch/head/kanayago.patch
99
+ - patch/head/macos.patch
100
+ - patch/head/macos.patch.rej
78
101
  - sample/minitest_generator.rb
79
102
  - sample/test_generator.rb
80
103
  - script/setup_parser.rb
@@ -102,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
125
  - !ruby/object:Gem::Version
103
126
  version: '0'
104
127
  requirements: []
105
- rubygems_version: 4.0.0.dev
128
+ rubygems_version: 4.1.0.dev
106
129
  specification_version: 4
107
130
  summary: Trying to Make Ruby's Parser Available as a Gem
108
131
  test_files: []