xot 0.3.11 → 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 +4 -4
- data/.github/workflows/release-gem.yml +3 -0
- data/.github/workflows/utils.rb +88 -17
- data/ChangeLog.md +14 -0
- data/VERSION +1 -1
- data/include/xot/util.h +8 -0
- data/include/xot.h +2 -2
- data/lib/xot/extconf.rb +66 -9
- data/lib/xot/extension.rb +8 -2
- data/lib/xot/rake/util.rb +5 -4
- data/lib/xot/rake.rb +25 -16
- data/lib/xot/util.rb +14 -6
- data/src/util.cpp +16 -0
- data/xot.gemspec +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95e3e82cc5f95bba59970fbe97e36e28e4f2a454e4cd4e1faf0ecf4ef1937be7
|
|
4
|
+
data.tar.gz: 84f576eaa74fbd89e6f029a31ab1fdccf3b59fc64ce4d574191051d445736047
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ade52d927ea1a92a9a63dfa73ad98caf2868415accf4b0691328eced45aefe7bda9e9beead0ea3cf0329316f46635c7e7af1330b9a3fd2402bec2da8c05fb6a6
|
|
7
|
+
data.tar.gz: 783a40a3f5dfc1b4ce49eb578713ea74c0e1d7062b6b784914f208c1b02f20bbd89531c9ec965b1bebe194e587bbdc5d0da6c6b53606c8b5421d025e60a49c01
|
data/.github/workflows/utils.rb
CHANGED
|
@@ -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(
|
|
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
|
|
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
|
-
|
|
36
|
-
|
|
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 {|
|
|
40
|
-
.select {|ver,
|
|
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
|
-
|
|
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[
|
|
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,20 @@
|
|
|
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
|
+
|
|
4
18
|
## [v0.3.11] - 2026-04-17
|
|
5
19
|
|
|
6
20
|
- Invert build script default verbosity: quiet by default, add verbose option
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
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
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
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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 <<
|
|
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
|
|
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
|
|
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 <<
|
|
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?
|
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
|
|
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 =
|
|
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
|
|
@@ -297,24 +305,25 @@ module Xot
|
|
|
297
305
|
file dir do
|
|
298
306
|
rake_puts "vendoring #{name}"
|
|
299
307
|
q = ::Rake.verbose ? '' : '-q'
|
|
300
|
-
opts = "#{q} -c advice.detachedHead=false --depth 1"
|
|
308
|
+
opts = "#{q} -c advice.detachedHead=false --depth 1 --no-tags"
|
|
301
309
|
opts += " --branch #{branch || tag}" if branch || tag
|
|
302
|
-
opts += " --recursive" if submodules.empty?
|
|
303
310
|
sh %( git clone #{opts} #{repos} #{dir} )
|
|
304
311
|
Dir.chdir dir do
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
sh %( git submodule #{q}
|
|
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 )
|
|
314
322
|
sh post_submodules if post_submodules
|
|
315
323
|
end
|
|
324
|
+
|
|
325
|
+
after_clone_block.call if after_clone_block
|
|
316
326
|
end
|
|
317
|
-
Dir.chdir(dir) {after_clone_block.call} if after_clone_block
|
|
318
327
|
unless get_env :VENDOR_NOCOMPILE, false
|
|
319
328
|
vendor_srcs_map(*srcdirs).each do |src, obj|
|
|
320
329
|
rake_puts "compiling #{src}"
|
data/lib/xot/util.rb
CHANGED
|
@@ -65,7 +65,7 @@ module Xot
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def osx?()
|
|
68
|
-
/darwin/.match?
|
|
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?
|
|
76
|
+
!wasm? && /mswin|ming|cygwin/.match?(RUBY_PLATFORM)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def mswin?()
|
|
80
|
-
/mswin/.match?
|
|
80
|
+
!wasm? && /mswin/.match?(RUBY_PLATFORM)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def mingw?()
|
|
84
|
-
/ming/.match?
|
|
84
|
+
!wasm? && /ming/.match?(RUBY_PLATFORM)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
def cygwin?()
|
|
88
|
-
/cygwin/.match?
|
|
88
|
+
!wasm? && /cygwin/.match?(RUBY_PLATFORM)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
def linux?()
|
|
92
|
-
/linux/.match?
|
|
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
|
|
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.
|
|
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-
|
|
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++.
|