xot 0.3.10 → 0.3.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a3ec9fd69e881ecb8a828cca918588b19a772dd024342e8b2a82f6e8365e8f7
4
- data.tar.gz: 8d40b3de7ef8c45a92e090c1c0b2b6920f607f0be4d4c681c0421ee00816e065
3
+ metadata.gz: 95e3e82cc5f95bba59970fbe97e36e28e4f2a454e4cd4e1faf0ecf4ef1937be7
4
+ data.tar.gz: 84f576eaa74fbd89e6f029a31ab1fdccf3b59fc64ce4d574191051d445736047
5
5
  SHA512:
6
- metadata.gz: 8a41380d0bdf8d0afa5a4948a5e431850c1ade73db5cd17181e6f2cc8a1684691ec17cd0bb85aff2963d8777fbcabab45b6bf40a434275e152509011330769f8
7
- data.tar.gz: deec3342fd9bc24d708988bacc75314c4d78d75412e725da8a8ea233668b36e52febe3e5465eeeaac47996e5351e8ecf0915514e400399a5edf90df1f4fce8c4
6
+ metadata.gz: ade52d927ea1a92a9a63dfa73ad98caf2868415accf4b0691328eced45aefe7bda9e9beead0ea3cf0329316f46635c7e7af1330b9a3fd2402bec2da8c05fb6a6
7
+ data.tar.gz: 783a40a3f5dfc1b4ce49eb578713ea74c0e1d7062b6b784914f208c1b02f20bbd89531c9ec965b1bebe194e587bbdc5d0da6c6b53606c8b5421d025e60a49c01
@@ -4,6 +4,9 @@ on:
4
4
  push:
5
5
  tags: ['v[0-9]*']
6
6
 
7
+ permissions:
8
+ contents: write
9
+
7
10
  jobs:
8
11
  release:
9
12
  runs-on: macos-latest
@@ -24,7 +27,7 @@ jobs:
24
27
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
25
28
 
26
29
  - name: test
27
- run: bundle exec rake quiet packages test
30
+ run: bundle exec rake packages test
28
31
 
29
32
  - name: create gem
30
33
  id: gem
@@ -25,13 +25,13 @@ jobs:
25
25
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
26
26
 
27
27
  - name: packages
28
- run: bundle exec rake packages
28
+ run: bundle exec rake verbose packages
29
29
 
30
30
  - name: lib
31
- run: bundle exec rake lib
31
+ run: bundle exec rake verbose lib
32
32
 
33
33
  - name: ext
34
- run: bundle exec rake ext
34
+ run: bundle exec rake verbose ext
35
35
 
36
36
  - name: test
37
- run: bundle exec rake test
37
+ run: bundle exec rake verbose test
@@ -1,3 +1,9 @@
1
+ require 'shellwords'
2
+
3
+ ALL_REPO = 'xord/all'
4
+ ALL_DIR = '../all'
5
+ ALL_FETCH_DEPTH = 100
6
+
1
7
  RENAMES = {reflex: 'reflexion'}
2
8
 
3
9
  def sh(cmd)
@@ -5,7 +11,7 @@ def sh(cmd)
5
11
  system cmd
6
12
  end
7
13
 
8
- def setup_dependencies(build: true, only: nil)
14
+ def setup_dependencies(only: nil)
9
15
  gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
10
16
  return unless gemspec_path
11
17
 
@@ -13,44 +19,109 @@ def setup_dependencies(build: true, only: nil)
13
19
  name = File.basename gemspec_path, '.gemspec'
14
20
 
15
21
  exts = File.readlines('Rakefile')
16
- .map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
22
+ .map {|l| l[%r|^\s*require\W+([\w\-\_]+)/extension\W+$|, 1]}
17
23
  .compact
18
24
  .reject {|ext| ext == name}
19
25
  exts = exts & [only].flatten.map(&:to_s) if only
26
+ return if exts.empty?
27
+
28
+ unless setup_dependencies_via_monorepo(exts)
29
+ setup_dependencies_via_each_repo_by_version(gemspec, exts)
30
+ end
31
+
32
+ exts.each {|ext| sh %( cd ../#{ext} && rake ext )}
33
+ end
34
+
35
+ def setup_dependencies_via_monorepo(exts)
36
+ return false unless checkout_monorepo
37
+ exts.each {|ext| sh %( ln -snf all/#{ext} ../#{ext} )}
38
+ true
39
+ end
40
+
41
+ def checkout_monorepo()
42
+ uuid = `git log -1 --format=%B`[/^\[\[([0-9a-fA-F-]+)\]\]$/, 1]
43
+ return false unless uuid
44
+
45
+ commit = setup_monorepo uuid
46
+ return false unless commit
47
+
48
+ Dir.chdir(ALL_DIR) {sh %( git checkout -q #{commit} )}
49
+ true
50
+ end
51
+
52
+ def setup_monorepo(uuid)
53
+ unless File.directory? ALL_DIR
54
+ url = "https://github.com/#{ALL_REPO}.git"
55
+ sh %( git clone --no-tags --depth #{ALL_FETCH_DEPTH} #{url} #{ALL_DIR} )
56
+ end
57
+ loop do
58
+ commit = find_monorepo_commit uuid
59
+ return commit if commit
60
+
61
+ deepened = Dir.chdir ALL_DIR do
62
+ before = `git rev-list --count HEAD`.to_i
63
+ sh %( git fetch --deepen #{ALL_FETCH_DEPTH} )
64
+ `git rev-list --count HEAD`.to_i > before
65
+ end
66
+ return nil unless deepened
67
+ end
68
+ end
69
+
70
+ def find_monorepo_commit(uuid)
71
+ Dir.chdir ALL_DIR do
72
+ out = `git log origin/HEAD -F --grep="[[#{uuid}]]" --format=%H -1`.strip
73
+ out.empty? ? nil : out
74
+ end
75
+ end
20
76
 
77
+ def setup_dependencies_via_each_repo_by_version(gemspec, exts)
21
78
  exts.each do |ext|
22
79
  gem = RENAMES[ext.to_sym].then {|s| s || ext}
23
- ver = gemspec[/add_dependency.*['"]#{gem}['"].*['"]\s*>=\s*([\d\.]+)\s*['"]/, 1]
80
+ ver = gemspec[/add_dependency.*['"]#{gem}['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/, 1]
24
81
  opts = '-c advice.detachedHead=false --depth 1'
25
82
  clone = "git clone #{opts} https://github.com/xord/#{ext}.git ../#{ext}"
26
83
 
27
84
  # 'rake subtree:push' pushes all subrepos, so cloning by new tag
28
85
  # often fails before tagging each new tag
29
86
  sh %( #{clone} --branch v#{ver} || #{clone} )
30
- sh %( cd ../#{ext} && rake ext )
31
87
  end
32
88
  end
33
89
 
34
90
  def tag_versions()
35
- tags = `git tag`.lines chomp: true
36
- vers = `git log --oneline ./VERSION`
91
+ changes = changelogs
92
+ tags = `git tag`.lines chomp: true
93
+ vers = `git log --oneline ./VERSION`
37
94
  .lines(chomp: true)
38
95
  .map {|line| line.split.first[/^\w+$/]}
39
- .map {|hash| [`git cat-file -p #{hash}:./VERSION 2>/dev/null`[/[\d\.]+/], hash]}
40
- .select {|ver, hash| ver && hash}
96
+ .map {|sha| [`git cat-file -p #{sha}:./VERSION 2>/dev/null`[/[\d\.]+/], sha]}
97
+ .select {|ver, sha| ver && sha}
41
98
  .reverse
42
99
  .to_h
43
100
 
44
- changes = File.read('ChangeLog.md')
45
- .split(/^\s*##\s*\[\s*v([\d\.]+)\s*\].*$/)
46
- .slice(1..-1)
47
- .each_slice(2)
48
- .to_h
49
- .transform_values(&:strip!)
50
-
51
- vers.to_a.reverse.each do |ver, hash|
101
+ vers.to_a.reverse.each do |ver, sha|
52
102
  tag = "v#{ver}"
53
103
  break if tags.include?(tag)
54
- sh %( git tag -a -m \"#{changes[ver]&.gsub '"', '\\"'}\" #{tag} #{hash} )
104
+ sh %( git tag -a -m \"#{changes[tag]&.gsub '"', '\\"'}\" #{tag} #{sha} )
55
105
  end
56
106
  end
107
+
108
+ def release(*paths)
109
+ tag = ENV['GITHUB_REF']&.sub(%r|^refs/tags/|, '') || raise('GITHUB_REF tag not set')
110
+ notes = (changelogs[tag] || '').shellescape
111
+ paths = paths.flatten.join ' '
112
+
113
+ sh(%( gh release create #{tag} #{paths} --notes #{notes} )) ||
114
+ sh(%( gh release upload #{tag} #{paths} --clobber )) ||
115
+ raise('failed to upload to releases')
116
+ end
117
+
118
+ def changelogs()
119
+ File.read('ChangeLog.md')
120
+ .split(/^\s*##\s*\[\s*(v[\d\.]+)\s*\].*$/)
121
+ .slice(1..)
122
+ .each_slice(2)
123
+ .to_h
124
+ .transform_values(&:strip!)
125
+ rescue Errno::ENOENT
126
+ raise 'failed to get changelogs'
127
+ end
data/ChangeLog.md CHANGED
@@ -1,6 +1,26 @@
1
1
  # xot ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3.12] - 2026-05-10
5
+
6
+ - Add hint_memory_usage callback for external memory GC integration
7
+ - Add release helper that uploads to GitHub Releases via gh CLI
8
+ - Add Extension.name(downcase) for kebab-case module naming
9
+ - Add lib_name to Extension and use import libraries on Windows
10
+ - Clear DEFFILE in generated Makefile on Windows
11
+ - Resolve dependencies by monorepo commit UUID in CI
12
+ - Remove deprecated has_rdoc= from gemspecs
13
+
14
+ - Skip linking dependency native extensions to avoid duplicate symbols
15
+ - Fix compiler and linker warnings
16
+
17
+
18
+ ## [v0.3.11] - 2026-04-17
19
+
20
+ - Invert build script default verbosity: quiet by default, add verbose option
21
+ - Improve vendor task output with quiet git and progress messages
22
+
23
+
4
24
  ## [v0.3.10] - 2026-04-09
5
25
 
6
26
  - Add minimal support for SDL2
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- power_assert (2.0.3)
5
- rake (13.1.0)
6
- test-unit (3.6.1)
4
+ power_assert (3.0.1)
5
+ rake (13.3.1)
6
+ test-unit (3.7.7)
7
7
  power_assert
8
- yard (0.9.34)
8
+ yard (0.9.39)
9
9
 
10
10
  PLATFORMS
11
11
  arm64-darwin-21
12
12
  arm64-darwin-23
13
+ arm64-darwin-24
13
14
 
14
15
  DEPENDENCIES
15
16
  rake
@@ -17,4 +18,4 @@ DEPENDENCIES
17
18
  yard
18
19
 
19
20
  BUNDLED WITH
20
- 2.4.13
21
+ 2.4.19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.10
1
+ 0.3.12
data/include/xot/util.h CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
  #include <stdint.h>
8
+ #include <sys/types.h>
8
9
  #include <math.h>
9
10
  #include <assert.h>
10
11
  #include <xot/defs.h>
@@ -124,6 +125,13 @@ namespace Xot
124
125
  }
125
126
 
126
127
 
128
+ typedef void (*HintMemoryUsageFun)(ssize_t);
129
+
130
+ void set_hint_memory_usage_fun (HintMemoryUsageFun fun);
131
+
132
+ void hint_memory_usage (ssize_t size);
133
+
134
+
127
135
  #if defined(OSX) || defined(IOS)
128
136
 
129
137
  void safe_cfrelease (const void* ref);
data/include/xot.h CHANGED
@@ -1,7 +1,7 @@
1
1
  // -*- c++ -*-
2
2
  #pragma once
3
- #ifndef __XOT_H__
4
- #define __XOT_H__
3
+ #ifndef __XOT_ALL_H__
4
+ #define __XOT_ALL_H__
5
5
 
6
6
 
7
7
  #include <xot/defs.h>
data/lib/xot/extconf.rb CHANGED
@@ -11,8 +11,6 @@ module Xot
11
11
  include Xot::Rake
12
12
  include Xot::Util
13
13
 
14
- attr_reader :extensions, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
15
-
16
14
  def initialize(*extensions, &block)
17
15
  @extensions = extensions.map {|x| x.const_get :Extension}
18
16
  @defs, @inc_dirs, @lib_dirs, @headers, @libs, @local_libs, @frameworks =
@@ -20,6 +18,12 @@ module Xot
20
18
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
21
19
  end
22
20
 
21
+ attr_reader :extensions, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
22
+
23
+ def my_ext()
24
+ extensions.last
25
+ end
26
+
23
27
  def debug()
24
28
  env :DEBUG, false
25
29
  end
@@ -28,19 +32,23 @@ module Xot
28
32
  yield if block_given?
29
33
 
30
34
  extensions.each do |ext|
31
- name = ext.name.downcase
32
- headers << "#{name}.h"
33
- local_libs << name
35
+ name = ext.name true
36
+ lib_name = ext == my_ext ? name : ext.lib_name
37
+ headers << "#{name}.h"
38
+ local_libs << lib_name if lib_name
34
39
  end
35
40
 
36
41
  ldflags = $LDFLAGS.dup
37
- if osx?
42
+ case
43
+ when osx?
38
44
  opt = '-Wl,-undefined,dynamic_lookup'
39
45
  ldflags << " #{opt}" unless ($DLDFLAGS || '').include?(opt)
40
46
  ldflags << ' -Wl,-bind_at_load' if osx? && debug?
47
+ when wasm?
48
+ build_lib_objs_for_wasm
41
49
  end
42
50
 
43
- local_libs << (clang? ? 'c++' : 'stdc++')
51
+ local_libs << 'stdc++' if gcc?
44
52
 
45
53
  $CPPFLAGS = make_cppflags $CPPFLAGS, defs, inc_dirs
46
54
  $CFLAGS = make_cflags $CFLAGS + ' -x c++'
@@ -51,13 +59,62 @@ module Xot
51
59
 
52
60
  def create_makefile(*args)
53
61
  extensions.each do |ext|
54
- dir_config ext.name.downcase, ext.inc_dir, ext.lib_dir
62
+ dir_config ext.name(true), ext.inc_dir, ext.lib_dir
55
63
  end
56
64
 
57
65
  exit 1 unless headers.all? {|s| have_header s}
58
- exit 1 unless libs.all? {|s| have_library s, 't'}
66
+ exit 1 unless libs.all? {|s| have_library s, 't'} unless wasm?
59
67
 
60
68
  super
69
+
70
+ export_all_symbols if mingw? || cygwin?
71
+ link_lib_objs_for_wasm if wasm?
72
+ end
73
+
74
+ def export_all_symbols()
75
+ name = my_ext.name true
76
+ opts = %W[
77
+ -Wl,--export-all-symbols,--whole-archive
78
+ -l#{name}
79
+ -Wl,--no-whole-archive
80
+ ].join ' '
81
+ filter_file('Makefile') {|s|
82
+ s.sub(/^DEFFILE\s*=.*$/, 'DEFFILE =')
83
+ .sub(/^(LOCAL_LIBS\s*=.*) -l#{name}\b/) {"#{$1} #{opts}"}
84
+ }
85
+ end
86
+
87
+ def build_lib_objs_for_wasm()
88
+ ruby_dirs = [
89
+ "#{ENV['extout']}/include/wasm32-emscripten",
90
+ "#{ENV['top_srcdir']}/include"
91
+ ]
92
+ envs = {
93
+ CC: '',
94
+ CXX: '',
95
+ AR: '',
96
+ RANLIB: '',
97
+ CPPFLAGS: ' -sUSE_SDL=2 -sUSE_SDL_TTF=2',
98
+ CFLAGS: ' -sUSE_SDL=2 -sUSE_SDL_TTF=2',
99
+ CXXFLAGS: '',
100
+ LDFLAGS: ' -sUSE_SDL=2 -sUSE_SDL_TTF=2',
101
+ INCDIRS: ruby_dirs.join(' ')
102
+ }.map {|k, v| "#{k}='#{(RbConfig::CONFIG[k.to_s] || '') + v}'"}
103
+
104
+ Dir.chdir target.root_dir do
105
+ cmd = "#{envs.join ' '} rake ext:lib_objs"
106
+ puts cmd
107
+ system cmd
108
+ end
109
+ end
110
+
111
+ def link_lib_objs_for_wasm()
112
+ lib_objs = Dir.glob "#{target.ext_dir}/**/__libobj_*.o"
113
+ filter_file 'Makefile' do |str|
114
+ str.sub(/^(\s*)(.*\$\(AR\).*)$/) {
115
+ "#{$1}#{$2}\n#{$1}$(Q) $(AR) r $@ #{lib_objs.join ' '}"
116
+ }
117
+ end
61
118
  end
62
119
 
63
120
  end# ExtConf
data/lib/xot/extension.rb CHANGED
@@ -5,8 +5,10 @@ module Xot
5
5
 
6
6
  module_function
7
7
 
8
- def name()
9
- super.split('::')[-2]
8
+ def name(downcase = false)
9
+ super().split('::')[-2].then {|s|
10
+ downcase ? s.gsub(/([a-z])([A-Z])/) {"#{$1}-#{$2}"}.downcase : s
11
+ }
10
12
  end
11
13
 
12
14
  def version()
@@ -29,6 +31,10 @@ module Xot
29
31
  root_dir 'ext'
30
32
  end
31
33
 
34
+ def lib_name()
35
+ name true
36
+ end
37
+
32
38
  end# Extension
33
39
 
34
40
 
data/lib/xot/rake/util.rb CHANGED
@@ -19,7 +19,7 @@ module Xot
19
19
  end
20
20
 
21
21
  def target_name()
22
- get_env :EXTNAME, target.name.downcase
22
+ get_env :EXTNAME, target.name(true)
23
23
  end
24
24
 
25
25
  def inc_dir()
@@ -81,7 +81,7 @@ module Xot
81
81
  paths.reject! {|path| path =~ %r(/osx/)} unless osx?
82
82
  paths.reject! {|path| path =~ %r(/ios/)} unless ios?
83
83
  paths.reject! {|path| path =~ %r(/win32/)} unless win32?
84
- paths.reject! {|path| path =~ %r(/sdl/)} unless linux?
84
+ paths.reject! {|path| path =~ %r(/sdl/)} unless linux? || wasm?
85
85
  make_path_map paths, src_ext_map
86
86
  end
87
87
 
@@ -186,12 +186,13 @@ module Xot
186
186
  def make_cppflags_defs(defs = [])
187
187
  a = defs.dup
188
188
  a << (debug? ? '_DEBUG' : 'NDEBUG')
189
- a << target.name.upcase
189
+ a << target_name.gsub('-', '_').upcase
190
190
  a << $~[0].upcase if RUBY_PLATFORM =~ /mswin|mingw|cygwin|darwin/i
191
191
  a << 'WIN32' if win32?
192
192
  a << 'OSX' if osx?
193
193
  a << 'IOS' if ios?
194
194
  a << 'LINUX' if linux?
195
+ a << 'WASM' if wasm?
195
196
  a << 'GCC' if gcc?
196
197
  a << 'CLANG' if clang?
197
198
  a << '_USE_MATH_DEFINES' if gcc?
@@ -221,7 +222,7 @@ module Xot
221
222
  s = flags.dup
222
223
  s << warning_opts.map {|s| " -W#{s}"}.join
223
224
  s << " -arch arm64" if osx? && arm64?
224
- s << ' -std=c++20' if gcc?
225
+ s << ' -std=c++20' if gcc? || emcc?
225
226
  s << ' -std=c++20 -stdlib=libc++ -mmacosx-version-min=10.10' if clang?
226
227
  s << ' ' + RbConfig::CONFIG['debugflags'] if debug?
227
228
  s.gsub!(/-O\d?\w*/, '-O0') if debug?
@@ -266,7 +267,7 @@ module Xot
266
267
  end
267
268
 
268
269
  def default_tasks(default = nil)
269
- verbose? get_env(:VERBOSE, true)
270
+ verbose? get_env(:VERBOSE, false)
270
271
 
271
272
  if default
272
273
  task :default => default
@@ -274,8 +275,8 @@ module Xot
274
275
  task :default
275
276
  end
276
277
 
277
- task :quiet do
278
- verbose? false
278
+ task :verbose do
279
+ verbose? true
279
280
  end
280
281
 
281
282
  task :debug do
data/lib/xot/rake.rb CHANGED
@@ -104,7 +104,7 @@ module Xot
104
104
  end
105
105
 
106
106
  def build_ruby_extension(dlname: nil, dlext: nil, liboutput: true)
107
- dlname = get_env :DLNAME, dlname || "#{target_name}_ext"
107
+ dlname = get_env :DLNAME, dlname || "#{target_name.gsub('-', '_')}_ext"
108
108
  dlext = get_env :DLEXT, dlext || RbConfig::CONFIG['DLEXT'] || 'so'
109
109
 
110
110
  extconf = File.join ext_dir, 'extconf.rb'
@@ -116,7 +116,7 @@ module Xot
116
116
  libout = File.join lib_dir, outname
117
117
 
118
118
  srcs = FileList["#{ext_dir}/**/*.cpp"]
119
- libs = extensions.map {|x| "#{x.lib_dir}/lib#{x.name.downcase}.a"}
119
+ libs = extensions.map {|x| "#{x.lib_dir}/lib#{x.name(true)}.a"}
120
120
 
121
121
  alias_task :ext => (liboutput ? libout : extout)
122
122
  alias_task :clean => 'ext:clean'
@@ -126,7 +126,7 @@ module Xot
126
126
  desc "build #{libout}"
127
127
  file libout => extout do
128
128
  libdir = File.dirname libout
129
- libimp = extout.sub /\.#{dlext}$/, '.dll.a'
129
+ libimp = File.join File.dirname(extout), "lib#{target_name}.dll.a"
130
130
  sh %( cp #{extout} #{libdir} )
131
131
  sh %( cp #{libimp} #{libdir} ) if mingw? || cygwin?
132
132
  end
@@ -150,9 +150,17 @@ module Xot
150
150
  sh %( cd #{ext_dir} && #{cxx} -M #{cppflags} #{inc} #{src} > #{dep} )
151
151
  end
152
152
 
153
+ desc "compile src/**/*"
154
+ task :lib_objs => :lib do
155
+ (srcs_map.values + vendor_srcs_map.values).each do |obj|
156
+ to = File.join ext_dir, "__libobj_#{obj.gsub '/', '_'}"
157
+ sh %( cp #{obj} #{to} )
158
+ end
159
+ end
160
+
153
161
  task :clean do
154
162
  sh %( cd #{ext_dir} && make clean ) if File.exist? makefile
155
- sh %( rm -rf #{libout} )
163
+ sh %( rm -rf #{libout} #{ext_dir}/__libobj_*.o )
156
164
  end
157
165
 
158
166
  task :clobber do
@@ -295,26 +303,30 @@ module Xot
295
303
  namespace name do
296
304
  desc "clone #{name}"
297
305
  file dir do
298
- opts = '-c advice.detachedHead=false --depth 1'
306
+ rake_puts "vendoring #{name}"
307
+ q = ::Rake.verbose ? '' : '-q'
308
+ opts = "#{q} -c advice.detachedHead=false --depth 1 --no-tags"
299
309
  opts += " --branch #{branch || tag}" if branch || tag
300
- opts += " --recursive" if submodules.empty?
301
310
  sh %( git clone #{opts} #{repos} #{dir} )
302
311
  Dir.chdir dir do
303
- sh %( git fetch --depth 1 origin #{commit} )
304
- sh %( git checkout #{commit} )
305
- end if commit
306
- unless submodules.empty?
307
- Dir.chdir dir do
308
- submodules.each do |path|
309
- sh %( git submodule init #{path} )
310
- end
311
- sh %( git submodule update --depth=1 )
312
+ if commit
313
+ sh %( git fetch #{q} --depth 1 origin #{commit} )
314
+ sh %( git checkout #{q} #{commit} )
315
+ end
316
+
317
+ if submodules.empty?
318
+ sh %( git submodule #{q} update --init --recursive --depth 1 )
319
+ else
320
+ submodules.each {|path| sh %( git submodule #{q} init #{path} )}
321
+ sh %( git submodule #{q} update --depth 1 )
312
322
  sh post_submodules if post_submodules
313
323
  end
324
+
325
+ after_clone_block.call if after_clone_block
314
326
  end
315
- Dir.chdir(dir) {after_clone_block.call} if after_clone_block
316
327
  unless get_env :VENDOR_NOCOMPILE, false
317
328
  vendor_srcs_map(*srcdirs).each do |src, obj|
329
+ rake_puts "compiling #{src}"
318
330
  sh %( #{cxx} -c #{cppflags} #{cxxflags false} -o #{obj} #{src} )
319
331
  end
320
332
  end
data/lib/xot/util.rb CHANGED
@@ -65,7 +65,7 @@ module Xot
65
65
  end
66
66
 
67
67
  def osx?()
68
- /darwin/.match? RUBY_PLATFORM
68
+ !wasm? && /darwin/.match?(RUBY_PLATFORM)
69
69
  end
70
70
 
71
71
  def ios?()
@@ -73,23 +73,27 @@ module Xot
73
73
  end
74
74
 
75
75
  def win32?()
76
- /mswin|ming|cygwin/.match? RUBY_PLATFORM
76
+ !wasm? && /mswin|ming|cygwin/.match?(RUBY_PLATFORM)
77
77
  end
78
78
 
79
79
  def mswin?()
80
- /mswin/.match? RUBY_PLATFORM
80
+ !wasm? && /mswin/.match?(RUBY_PLATFORM)
81
81
  end
82
82
 
83
83
  def mingw?()
84
- /ming/.match? RUBY_PLATFORM
84
+ !wasm? && /ming/.match?(RUBY_PLATFORM)
85
85
  end
86
86
 
87
87
  def cygwin?()
88
- /cygwin/.match? RUBY_PLATFORM
88
+ !wasm? && /cygwin/.match?(RUBY_PLATFORM)
89
89
  end
90
90
 
91
91
  def linux?()
92
- /linux/.match? RUBY_PLATFORM
92
+ !wasm? && /linux/.match?(RUBY_PLATFORM)
93
+ end
94
+
95
+ def wasm?()
96
+ emcc?
93
97
  end
94
98
 
95
99
  def gcc?()
@@ -100,6 +104,10 @@ module Xot
100
104
  /(^|\-)clang/i.match? cc
101
105
  end
102
106
 
107
+ def emcc?()
108
+ /(^|\-)emcc$/i.match? cc
109
+ end
110
+
103
111
  def github_actions?()
104
112
  ENV['GITHUB_ACTIONS'] == 'true'
105
113
  end
data/src/util.cpp CHANGED
@@ -53,6 +53,22 @@ namespace Xot
53
53
  }
54
54
 
55
55
 
56
+ static HintMemoryUsageFun hint_memory_usage_fun = NULL;
57
+
58
+ void
59
+ set_hint_memory_usage_fun (HintMemoryUsageFun fun)
60
+ {
61
+ hint_memory_usage_fun = fun;
62
+ }
63
+
64
+ void
65
+ hint_memory_usage (ssize_t size)
66
+ {
67
+ if (hint_memory_usage_fun && size != 0)
68
+ hint_memory_usage_fun(size);
69
+ }
70
+
71
+
56
72
  #if defined(OSX) || defined(IOS)
57
73
 
58
74
  void
data/xot.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  end
11
11
 
12
12
  ext = Xot::Extension
13
- name = ext.name.downcase
13
+ name = ext.name true
14
14
  rdocs = glob.call *%w[README]
15
15
 
16
16
  s.name = name
@@ -29,7 +29,6 @@ Gem::Specification.new do |s|
29
29
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
30
30
  s.test_files = s.files.grep %r{^(test|spec|features)/}
31
31
  s.extra_rdoc_files = rdocs.to_a
32
- s.has_rdoc = true
33
32
 
34
33
  s.extensions << 'Rakefile'
35
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-09 00:00:00.000000000 Z
11
+ date: 2026-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This library include some useful utility classes and functions for development
14
14
  with C++.